@@ -252,6 +252,71 @@ func TestRedirectUri(t *testing.T) {
252
252
assert .Equal ("https" , uri .Scheme )
253
253
assert .Equal ("another.com" , uri .Host )
254
254
assert .Equal ("/_oauth" , uri .Path )
255
+
256
+ //
257
+ // With correct Auth URL + cookie domain, multiple AuthHosts and cookie domains
258
+ // - will use matching authHost
259
+ //
260
+ config .AuthHosts = CommaSeparatedList {"auth.example.com" , "auth.another.com" }
261
+ config .CookieDomains = []CookieDomain {* NewCookieDomain ("example.com" ), * NewCookieDomain ("another.com" )}
262
+
263
+ uri , err = url .Parse (redirectUri (r ))
264
+ assert .Nil (err )
265
+ assert .Equal ("https" , uri .Scheme )
266
+ assert .Equal ("auth.another.com" , uri .Host )
267
+ assert .Equal ("/_oauth" , uri .Path )
268
+
269
+ //
270
+ // With correct Auth URL + no cookie domains
271
+ // - will not use authHost
272
+ //
273
+ config .AuthHosts = CommaSeparatedList {"auth.example.com" , "auth.another.com" }
274
+ config .CookieDomains = []CookieDomain {}
275
+
276
+ uri , err = url .Parse (redirectUri (r ))
277
+ assert .Nil (err )
278
+ assert .Equal ("https" , uri .Scheme )
279
+ assert .Equal ("another.com" , uri .Host )
280
+ assert .Equal ("/_oauth" , uri .Path )
281
+
282
+ //
283
+ // With correct Auth URL + no matching cookie domains
284
+ // - will not use authHost
285
+ //
286
+ config .AuthHosts = CommaSeparatedList {"auth.example.com" , "auth.another.com" }
287
+ config .CookieDomains = []CookieDomain {* NewCookieDomain ("example.com" ), * NewCookieDomain ("another.example" )}
288
+
289
+ uri , err = url .Parse (redirectUri (r ))
290
+ assert .Nil (err )
291
+ assert .Equal ("https" , uri .Scheme )
292
+ assert .Equal ("another.com" , uri .Host )
293
+ assert .Equal ("/_oauth" , uri .Path )
294
+
295
+ //
296
+ // With no matching Auth Host + matching cookie domains
297
+ // - will not use authHost
298
+ //
299
+ config .AuthHosts = CommaSeparatedList {"auth.example.com" , "auth.another.example" }
300
+ config .CookieDomains = []CookieDomain {* NewCookieDomain ("example.com" ), * NewCookieDomain ("another.com" )}
301
+
302
+ uri , err = url .Parse (redirectUri (r ))
303
+ assert .Nil (err )
304
+ assert .Equal ("https" , uri .Scheme )
305
+ assert .Equal ("another.com" , uri .Host )
306
+ assert .Equal ("/_oauth" , uri .Path )
307
+
308
+ //
309
+ // With no matching Auth Host + no matching cookie domains
310
+ // - will not use authHost
311
+ //
312
+ config .AuthHosts = CommaSeparatedList {"auth.example.com" , "auth.another.example" }
313
+ config .CookieDomains = []CookieDomain {* NewCookieDomain ("example.com" ), * NewCookieDomain ("another.example" )}
314
+
315
+ uri , err = url .Parse (redirectUri (r ))
316
+ assert .Nil (err )
317
+ assert .Equal ("https" , uri .Scheme )
318
+ assert .Equal ("another.com" , uri .Host )
319
+ assert .Equal ("/_oauth" , uri .Path )
255
320
}
256
321
257
322
func TestAuthMakeCookie (t * testing.T ) {
0 commit comments