@@ -141,3 +141,64 @@ auth:
141
141
t .Errorf ("unexpected api endpoint address: %s" , conf .Auth .Info .ApiEndpoint )
142
142
}
143
143
}
144
+
145
+ func TestParseNamebasedVhosts (t * testing.T ) {
146
+ f , err := ioutil .TempFile ("" , "" )
147
+ if err != nil {
148
+ t .Error (err )
149
+ }
150
+ defer func () {
151
+ f .Close ()
152
+ os .Remove (f .Name ())
153
+ }()
154
+
155
+ data := `---
156
+ address: ":9999"
157
+
158
+ auth:
159
+ session:
160
+ key: secret
161
+ cookie_domain: example.com
162
+
163
+ info:
164
+ service: 'google'
165
+ client_id: 'secret client id'
166
+ client_secret: 'secret client secret'
167
+ redirect_url: 'http://example.com/oauth2callback'
168
+
169
+ htdocs: ./
170
+
171
+ proxy:
172
+ - path: /
173
+ host: elasticsearch.example.com
174
+ dest: http://127.0.0.1:9200
175
+ - path: /
176
+ host: influxdb.example.com
177
+ dest: http://127.0.0.1:8086
178
+ `
179
+ if err := ioutil .WriteFile (f .Name (), []byte (data ), 0644 ); err != nil {
180
+ t .Error (err )
181
+ }
182
+
183
+ conf , err := ParseConf (f .Name ())
184
+ if err != nil {
185
+ t .Error (err )
186
+ }
187
+
188
+ if conf .Auth .Session .CookieDomain != "example.com" {
189
+ t .Errorf ("unexpected cookie_domain: %s" , conf .Auth .Session .CookieDomain )
190
+ }
191
+
192
+ if len (conf .Proxies ) != 2 {
193
+ t .Errorf ("insufficient proxy definions" )
194
+ }
195
+ es := conf .Proxies [0 ]
196
+ if es .Path != "/" || es .Host != "elasticsearch.example.com" || es .Dest != "http://127.0.0.1:9200" {
197
+ t .Errorf ("unexpected proxy[0]: %#v" , es )
198
+ }
199
+
200
+ ifdb := conf .Proxies [1 ]
201
+ if ifdb .Path != "/" || ifdb .Host != "influxdb.example.com" || ifdb .Dest != "http://127.0.0.1:8086" {
202
+ t .Errorf ("unexpected proxy[1]: %#v" , ifdb )
203
+ }
204
+ }
0 commit comments