(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func TestWhitelistCheck(t *testing.T) { |
| 74 | node := &Node{ |
| 75 | Logger: log.NewEntry(log.New()), |
| 76 | } |
| 77 | tests := []struct { |
| 78 | name string |
| 79 | whitelist Whitelist |
| 80 | event *pipeline.Event |
| 81 | expected bool |
| 82 | }{ |
| 83 | { |
| 84 | name: "IP Whitelisted", |
| 85 | whitelist: Whitelist{ |
| 86 | Reason: "test", |
| 87 | Ips: []string{ |
| 88 | "127.0.0.1", |
| 89 | }, |
| 90 | }, |
| 91 | event: &pipeline.Event{ |
| 92 | Meta: map[string]string{ |
| 93 | "source_ip": "127.0.0.1", |
| 94 | }, |
| 95 | }, |
| 96 | expected: true, |
| 97 | }, |
| 98 | { |
| 99 | name: "IP Not Whitelisted", |
| 100 | whitelist: Whitelist{ |
| 101 | Reason: "test", |
| 102 | Ips: []string{ |
| 103 | "127.0.0.1", |
| 104 | }, |
| 105 | }, |
| 106 | event: &pipeline.Event{ |
| 107 | Meta: map[string]string{ |
| 108 | "source_ip": "127.0.0.2", |
| 109 | }, |
| 110 | }, |
| 111 | }, |
| 112 | { |
| 113 | name: "CIDR Whitelisted", |
| 114 | whitelist: Whitelist{ |
| 115 | Reason: "test", |
| 116 | Cidrs: []string{ |
| 117 | "127.0.0.1/32", |
| 118 | }, |
| 119 | }, |
| 120 | event: &pipeline.Event{ |
| 121 | Meta: map[string]string{ |
| 122 | "source_ip": "127.0.0.1", |
| 123 | }, |
| 124 | }, |
| 125 | expected: true, |
| 126 | }, |
| 127 | { |
| 128 | name: "CIDR Not Whitelisted", |
| 129 | whitelist: Whitelist{ |
| 130 | Reason: "test", |
nothing calls this directly
no test coverage detected
searching dependent graphs…