@@ -107,4 +107,53 @@ var _ = framework.DescribeAnnotation("custom-headers-*", func() {
107107 Status (http .StatusOK ).
108108 Header ("My-Custom-Header-Dollar" ).Contains ("$remote_addr" )
109109 })
110+
111+ ginkgo .It (`should set "more_set_headers 'My-Custom-Header' '42';" when custom-headers annotation is added` , func () {
112+ f .CreateConfigMap ("custom-headers" , map [string ]string {
113+ "My-Custom-Header" : "42" ,
114+ "My-Custom-Header-Dollar" : "$remote_addr" ,
115+ })
116+ f .UpdateNginxConfigMapData ("global-allowed-response-headers" , "My-Custom-Header,My-Custom-Header-Dollar" )
117+
118+ annotations := map [string ]string {}
119+ ing := framework .NewSingleIngress (customHeaderHost , "/" , customHeaderHost , f .Namespace , framework .EchoService , 80 , annotations )
120+ f .EnsureIngress (ing )
121+
122+ f .WaitForNginxServer (customHeaderHost ,
123+ func (server string ) bool {
124+ return strings .Contains (server , "server_name custom-headers" )
125+ })
126+
127+ f .HTTPTestClient ().
128+ GET ("/" ).
129+ WithHeader ("Host" , customHeaderHost ).
130+ Expect ().
131+ Status (http .StatusOK ).
132+ Header ("My-Custom-Header" ).Equal ("" )
133+
134+ annotations = map [string ]string {
135+ "nginx.ingress.kubernetes.io/custom-headers" : f .Namespace + "/custom-headers" ,
136+ }
137+
138+ ing .Annotations = annotations
139+
140+ f .UpdateIngress (ing )
141+ f .WaitForNginxServer (customHeaderHost ,
142+ func (server string ) bool {
143+ return strings .Contains (server , `more_set_headers "My-Custom-Header: 42";` )
144+ })
145+
146+ f .HTTPTestClient ().
147+ GET ("/" ).
148+ WithHeader ("Host" , customHeaderHost ).
149+ Expect ().
150+ Status (http .StatusOK ).
151+ Header ("My-Custom-Header" ).Contains ("42" )
152+ f .HTTPTestClient ().
153+ GET ("/" ).
154+ WithHeader ("Host" , customHeaderHost ).
155+ Expect ().
156+ Status (http .StatusOK ).
157+ Header ("My-Custom-Header-Dollar" ).Contains ("$remote_addr" )
158+ })
110159})
0 commit comments