Try to create session with invalid cert but valid credentials
(t *testing.T)
| 211 | |
| 212 | // Try to create session with invalid cert but valid credentials |
| 213 | func 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 | |
| 239 | func TestSessionLogin(t *testing.T) { |
| 240 | rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: false}) |
nothing calls this directly
no test coverage detected