-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathmitm_test.go
52 lines (47 loc) · 890 Bytes
/
mitm_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"encoding/json"
"testing"
)
func TestIP(t *testing.T) {
err := json.Unmarshal([]byte(`{
"api": 8888,
"secret": "114514",
"domains": [
"netflix.com"
],
"allowedips": [
"114.114.114.114",
"114.114.115.115"
],
"address": "11.4.5.14",
"upstream": "1.1.1.1:53"
}`), &Data)
if err != nil {
t.Errorf("[TEST][json.Unmarshal] %v", err)
}
if !checkAllowIP("114.114.114.114") {
t.Error("[TEST][IP] Not Allow")
}
}
func TestDomain(t *testing.T) {
err := json.Unmarshal([]byte(`{
"api": 8888,
"secret": "114514",
"domains": [
"netflix.com"
],
"allowedips": [
"114.114.114.114",
"114.114.115.115"
],
"address": "11.4.5.14",
"upstream": "1.1.1.1:53"
}`), &Data)
if err != nil {
t.Errorf("[TEST][json.Unmarshal] %v", err)
}
if !checkAllowDomain("abcd.netflix.com") {
t.Error("[TEST][Domain] Not Allow")
}
}