@@ -19,11 +19,12 @@ var (
19
19
filepath .Join (util .MustGetThisDir (), "testdata" , "setup.yaml" ),
20
20
e2edefaults .CurlPodManifest ,
21
21
}
22
- basicVhOManifest = filepath .Join (util .MustGetThisDir (), "testdata" , "basic-vho.yaml" )
23
- sectionNameVhOManifest = filepath .Join (util .MustGetThisDir (), "testdata" , "section-name-vho.yaml" )
24
- extraVhOManifest = filepath .Join (util .MustGetThisDir (), "testdata" , "extra-vho.yaml" )
25
- badVhOManifest = filepath .Join (util .MustGetThisDir (), "testdata" , "webhook-reject-bad-vho.yaml" )
26
- extraVhOMergeManifest = filepath .Join (util .MustGetThisDir (), "testdata" , "extra-vho-merge.yaml" )
22
+
23
+ manifestVhoRemoveXBar = filepath .Join (util .MustGetThisDir (), "testdata" , "vho-remove-x-bar.yaml" )
24
+ manifestVhoSectionAddXFoo = filepath .Join (util .MustGetThisDir (), "testdata" , "vho-section-add-x-foo.yaml" )
25
+ manifestVhoRemoveXBaz = filepath .Join (util .MustGetThisDir (), "testdata" , "vho-remove-x-baz.yaml" )
26
+ manifestVhoWebhookReject = filepath .Join (util .MustGetThisDir (), "testdata" , "vho-webhook-reject.yaml" )
27
+ manifestVhoMergeRemoveXBaz = filepath .Join (util .MustGetThisDir (), "testdata" , "vho-merge-remove-x-baz.yaml" )
27
28
28
29
// When we apply the setup file, we expect resources to be created with this metadata
29
30
glooProxyObjectMeta = metav1.ObjectMeta {
@@ -50,51 +51,72 @@ var (
50
51
},
51
52
}
52
53
53
- // VirtualHostOption resource to be created
54
- basicVirtualHostOptionMeta = metav1.ObjectMeta {
55
- Name : "remove-content-length " ,
54
+ // VHO to add a x-foo header
55
+ vhoRemoveXBar = metav1.ObjectMeta {
56
+ Name : "remove-x-bar-header " ,
56
57
Namespace : "default" ,
57
58
}
58
- // Extra VirtualHostOption resource to be created
59
- extraVirtualHostOptionMeta = metav1.ObjectMeta {
60
- Name : "remove-content-type " ,
59
+ // VHO to remove a x-baz header
60
+ vhoRemoveXBaz = metav1.ObjectMeta {
61
+ Name : "remove-x-baz-header " ,
61
62
Namespace : "default" ,
62
63
}
63
- // Extra VirtualHostOption resource to be created to test merging of options
64
- extraMergeVirtualHostOptionMeta = metav1.ObjectMeta {
65
- Name : "extra-vho -merge" ,
64
+ // VHO to remove a x-baz header
65
+ vhoMergeRemoveXBaz = metav1.ObjectMeta {
66
+ Name : "remove-x-baz -merge" ,
66
67
Namespace : "default" ,
67
68
}
68
- // SectionName VirtualHostOption resource to be created
69
- sectionNameVirtualHostOptionMeta = metav1.ObjectMeta {
70
- Name : "add-foo-header" ,
69
+ // VHO to add a x-foo header in a section
70
+ vhoSectionAddXFoo = metav1.ObjectMeta {
71
+ Name : "add-x- foo-header" ,
71
72
Namespace : "default" ,
72
73
}
73
- // Bad VirtualHostOption resource to be created
74
- badVirtualHostOptionMeta = metav1.ObjectMeta {
74
+ // VHO that should be rejected by the validating webhook
75
+ vhoWebhookReject = metav1.ObjectMeta {
75
76
Name : "bad-retries" ,
76
77
Namespace : "default" ,
77
78
}
78
79
79
- expectedResponseWithoutContentLength = & matchers.HttpResponse {
80
+ // Expects a 200 response with x-bar and x-baz headers
81
+ defaultResponse = & matchers.HttpResponse {
82
+ StatusCode : http .StatusOK ,
83
+ Custom : gomega .And (
84
+ gomega .Not (matchers .ContainHeaderKeys ([]string {"x-foo" })),
85
+ matchers .ContainHeaderKeys ([]string {"x-bar" , "x-baz" }),
86
+ ),
87
+ Body : gstruct .Ignore (),
88
+ }
89
+
90
+ // Expects default response with no x-bar header
91
+ expectedResponseWithoutXBar = & matchers.HttpResponse {
80
92
StatusCode : http .StatusOK ,
81
- Custom : gomega .Not (matchers .ContainHeaderKeys ([]string {"content-length" })),
82
- Body : gstruct .Ignore (),
93
+ Custom : gomega .And (
94
+ gomega .Not (matchers .ContainHeaderKeys ([]string {"x-bar" })),
95
+ matchers .ContainHeaderKeys ([]string {"x-baz" }),
96
+ ),
97
+ Body : gstruct .Ignore (),
83
98
}
84
99
85
- expectedResponseWithoutContentType = & matchers.HttpResponse {
100
+ // Expects default response with no x-baz header
101
+ expectedResponseWithoutXBaz = & matchers.HttpResponse {
86
102
StatusCode : http .StatusOK ,
87
- Custom : gomega .Not (matchers .ContainHeaderKeys ([]string {"content-type" })),
88
- Body : gstruct .Ignore (),
103
+ Custom : gomega .And (
104
+ matchers .ContainHeaderKeys ([]string {"x-bar" }),
105
+ gomega .Not (matchers .ContainHeaderKeys ([]string {"x-baz" })),
106
+ ),
107
+ Body : gstruct .Ignore (),
89
108
}
90
109
91
- expectedResponseWithFooHeader = & matchers.HttpResponse {
110
+ // Expects default response with x-foo header
111
+ expectedResponseWithXFoo = & matchers.HttpResponse {
92
112
StatusCode : http .StatusOK ,
93
113
Headers : map [string ]interface {}{
94
- "foo" : gomega .Equal ("bar " ),
114
+ "x- foo" : gomega .Equal ("foo " ),
95
115
},
96
- // Make sure the content-length isn't being removed as a function of the unwanted VHO
97
- Custom : matchers .ContainHeaderKeys ([]string {"content-length" }),
98
- Body : gstruct .Ignore (),
116
+ // Make sure the x-bar isn't being removed as a function of the unwanted VHO
117
+ Custom : gomega .And (
118
+ matchers .ContainHeaderKeys ([]string {"x-foo" , "x-bar" , "x-baz" }),
119
+ ),
120
+ Body : gstruct .Ignore (),
99
121
}
100
122
)
0 commit comments