MCPcopy
hub / github.com/Infisical/agent-vault / TestLoginSuccess

Function TestLoginSuccess

internal/server/server_test.go:1285–1309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1283}
1284
1285func TestLoginSuccess(t *testing.T) {
1286 ms := setupMockStoreWithUser(t, "admin@test.com", "test-password-123")
1287 srv := newTestServer(withStore(ms))
1288
1289 body := `{"email":"admin@test.com","password":"test-password-123"}`
1290 req := httptest.NewRequest(http.MethodPost, "/v1/auth/login", strings.NewReader(body))
1291 rec := httptest.NewRecorder()
1292
1293 srv.httpServer.Handler.ServeHTTP(rec, req)
1294
1295 if rec.Code != http.StatusOK {
1296 t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String())
1297 }
1298
1299 var resp loginResponse
1300 if err := json.NewDecoder(rec.Body).Decode(&resp); err != nil {
1301 t.Fatalf("decode response: %v", err)
1302 }
1303 if resp.Token == "" {
1304 t.Fatal("expected non-empty token")
1305 }
1306 if resp.ExpiresAt == "" {
1307 t.Fatal("expected non-empty expires_at")
1308 }
1309}
1310
1311func TestLoginRecordsDeviceMetadata(t *testing.T) {
1312 ms := setupMockStoreWithUser(t, "admin@test.com", "test-password-123")

Callers

nothing calls this directly

Calls 4

setupMockStoreWithUserFunction · 0.85
newTestServerFunction · 0.85
withStoreFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected