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

Function TestSessionFail

rest/session_test.go:213–237  ·  view source on GitHub ↗

Try to create session with invalid cert but valid credentials

(t *testing.T)

Source from the content-addressed store, hash-verified

211
212// Try to create session with invalid cert but valid credentials
213func TestSessionFail(t *testing.T) {
214 rt := NewRestTester(t, nil)
215 defer rt.Close()
216
217 rt.CreateUser("user1", []string{"user1"})
218
219 id, err := base.GenerateRandomSecret()
220 require.NoError(t, err)
221
222 // Create fake, invalid session
223 fakeSession := auth.LoginSession{
224 ID: id,
225 Username: "user1",
226 Expiration: time.Now().Add(4 * time.Hour),
227 Ttl: 24 * time.Hour,
228 }
229
230 reqHeaders := map[string]string{
231 "Cookie": auth.DefaultCookieName + "=" + fakeSession.ID,
232 }
233
234 // Attempt to create session with invalid cert but valid login
235 response := rt.SendRequestWithHeaders("POST", "/db/_session", `{"name":"user1", "password":"letmein"}`, reqHeaders)
236 RequireStatus(t, response, http.StatusOK)
237}
238
239func TestSessionLogin(t *testing.T) {
240 rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: false})

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
CreateUserMethod · 0.95
GenerateRandomSecretFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected