-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
97 lines (93 loc) · 1.36 KB
/
main_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package traefik_plugin_disable_graphql_introspection
import (
"testing"
)
func TestCheckIfRequestIsIntrospection(t *testing.T) {
tests := []struct {
desc string
result bool
body string
}{
{
desc: "user query without typename",
result: false,
body: `
query NotIntrospectionQuery{
users {
id
plans {
id
name
}
}
}
`,
},
{
desc: "user query with typename",
result: false,
body: `
query NotIntrospectionQuery{
users {
id
plans {
id
name
__typename
}
}
}
`,
},
{
desc: "user query with type and schema fields",
result: false,
body: `
query NotIntrospectionQuery{
users {
id
plans {
id
name
type
schema
}
}
}
`,
},
{
desc: "schema introspection request",
result: true,
body: `
__schema {
types {
name
}
}
`,
},
{
desc: "type introspection request",
result: true,
body: `
{
__type(name: "CustomUserType") {
name
fields {
name
}
}
}
`,
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
result := checkIfRequestIsIntrospection(test.body)
if result != test.result {
t.Fatal("Check is failed")
}
})
}
}