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

Function TestLoginRequiredForAdmin

rest/admin_api_auth_test.go:1497–1518  ·  view source on GitHub ↗

Tests to make sure login required is returned when admin auth is enabled

(t *testing.T)

Source from the content-addressed store, hash-verified

1495
1496// Tests to make sure login required is returned when admin auth is enabled
1497func TestLoginRequiredForAdmin(t *testing.T) {
1498 if base.UnitTestUrlIsWalrus() {
1499 t.Skip("Hits CBS rest endpoint for permission check")
1500 }
1501
1502 rt := NewRestTester(t, &RestTesterConfig{
1503 AdminInterfaceAuthentication: true,
1504 })
1505 defer rt.Close()
1506
1507 username := "nonexistent"
1508 password := "nope"
1509
1510 response := rt.SendAdminRequestWithAuth(http.MethodGet, "/{{.db}}/", "", username, password)
1511
1512 RequireStatus(t, response, http.StatusUnauthorized)
1513 require.Contains(t, response.Body.String(), ErrInvalidLogin.Message)
1514
1515 response = rt.SendAdminRequestWithAuth(http.MethodGet, "/notadb/", "", username, password)
1516 RequireStatus(t, response, http.StatusUnauthorized)
1517 require.Contains(t, response.Body.String(), ErrInvalidLogin.Message)
1518}

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
ContainsMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected