MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / checkGoodAuthResponse

Function checkGoodAuthResponse

rest/oidc_api_test.go:1357–1391  ·  view source on GitHub ↗

checkGoodAuthResponse asserts expected session response values against the given response.

(t *testing.T, rt *RestTester, response *http.Response, username string)

Source from the content-addressed store, hash-verified

1355
1356// checkGoodAuthResponse asserts expected session response values against the given response.
1357func checkGoodAuthResponse(t *testing.T, rt *RestTester, response *http.Response, username string) {
1358 var responseBodyExpected map[string]interface{}
1359 dataStore := rt.GetSingleDataStore()
1360 require.Equal(t, http.StatusOK, response.StatusCode)
1361 assert.Equal(t, "application/json", response.Header.Get("Content-Type"))
1362 var responseBodyActual map[string]interface{}
1363 require.NoError(t, json.NewDecoder(response.Body).Decode(&responseBodyActual))
1364 sessionCookie := getCookie(response.Cookies(), auth.DefaultCookieName)
1365 require.NotNil(t, sessionCookie, "No session cookie found")
1366 require.NoError(t, response.Body.Close(), "error closing response body")
1367 if base.IsDefaultCollection(dataStore.ScopeName(), dataStore.CollectionName()) {
1368 responseBodyExpected = map[string]interface{}{
1369 "authentication_handlers": []interface{}{
1370 "default", "cookie",
1371 },
1372 "ok": true,
1373 "userCtx": map[string]interface{}{
1374 "channels": map[string]interface{}{"!": float64(1)},
1375 "name": username,
1376 },
1377 }
1378 } else {
1379 responseBodyExpected = map[string]interface{}{
1380 "authentication_handlers": []interface{}{
1381 "default", "cookie",
1382 },
1383 "ok": true,
1384 "userCtx": map[string]interface{}{
1385 "channels": interface{}(nil),
1386 "name": username,
1387 },
1388 }
1389 }
1390 assert.Equal(t, responseBodyExpected, responseBodyActual, "Session response mismatch")
1391}
1392
1393// E2E test that checks OpenID Connect Implicit Flow edge cases.
1394func TestOpenIDConnectImplicitFlowEdgeCases(t *testing.T) {

Calls 9

IsDefaultCollectionFunction · 0.92
getCookieFunction · 0.85
DecodeMethod · 0.65
CloseMethod · 0.65
GetSingleDataStoreMethod · 0.45
EqualMethod · 0.45
GetMethod · 0.45
ScopeNameMethod · 0.45
CollectionNameMethod · 0.45

Tested by

no test coverage detected