@@ -107,4 +107,49 @@ 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 , `more_set_headers "My-Custom-Header: 42";` )
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+
142+ f .HTTPTestClient ().
143+ GET ("/" ).
144+ WithHeader ("Host" , customHeaderHost ).
145+ Expect ().
146+ Status (http .StatusOK ).
147+ Header ("My-Custom-Header" ).Contains ("42" )
148+ f .HTTPTestClient ().
149+ GET ("/" ).
150+ WithHeader ("Host" , customHeaderHost ).
151+ Expect ().
152+ Status (http .StatusOK ).
153+ Header ("My-Custom-Header-Dollar" ).Contains ("$remote_addr" )
154+ })
110155})
0 commit comments