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

Function TestDeleteSession

auth/session_test.go:89–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestDeleteSession(t *testing.T) {
90 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth)
91 ctx := base.TestCtx(t)
92 const username = "Alice"
93 testBucket := base.GetTestBucket(t)
94 defer testBucket.Close(ctx)
95 dataStore := testBucket.GetSingleDataStore()
96 auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx))
97
98 id, err := base.GenerateRandomSecret()
99 require.NoError(t, err)
100
101 mockSession := &LoginSession{
102 ID: id,
103 Username: username,
104 Expiration: time.Now().Add(2 * time.Hour),
105 Ttl: 24 * time.Hour,
106 }
107 const noSessionExpiry = 0
108 assert.NoError(t, dataStore.Set(auth.DocIDForSession(mockSession.ID), noSessionExpiry, nil, mockSession))
109 assert.NoError(t, auth.DeleteSession(ctx, mockSession.ID, ""))
110
111 session, _, err := auth.GetSession(mockSession.ID)
112 assert.Nil(t, session)
113 base.RequireDocNotFoundError(t, err)
114}
115
116// Coverage for MakeSessionCookie. The MakeSessionCookie should create a cookie
117// using the sessionID, username, expiration and TTL from LoginSession provided.

Callers

nothing calls this directly

Calls 14

SetUpTestLoggingFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
GenerateRandomSecretFunction · 0.92
RequireDocNotFoundErrorFunction · 0.92
NewTestAuthenticatorFunction · 0.85
DocIDForSessionMethod · 0.80
DeleteSessionMethod · 0.80
GetSessionMethod · 0.80
CloseMethod · 0.65
GetSingleDataStoreMethod · 0.45

Tested by

no test coverage detected