1
0
forked from baron/baron-sso

lint 실패 해결

This commit is contained in:
Lectom C Han
2026-02-23 22:11:27 +09:00
parent 2bdfc2eb51
commit bb3231effe
8 changed files with 53 additions and 7 deletions

View File

@@ -299,3 +299,44 @@ func TestPasswordLogin_NoOIDC_Success(t *testing.T) {
t.Errorf("expected no redirectTo, got %s", got["redirectTo"])
}
}
func TestPasswordLogin_InvalidCredentials_ReturnsCode(t *testing.T) {
mockIdp := new(MockIdentityProvider)
mockIdp.On("SignIn", "user@example.com", "wrong-password").Return(nil, errors.New("비밀번호가 일치하지 않습니다"))
h := &AuthHandler{
IdpProvider: mockIdp,
KratosAdmin: service.NewKratosAdminService(),
Hydra: service.NewHydraAdminService(),
}
app := newAuthLoginTestApp(h)
body, _ := json.Marshal(map[string]string{
"loginId": "user@example.com",
"password": "wrong-password",
})
req := httptest.NewRequest(http.MethodPost, "/api/v1/auth/login", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
resp, err := app.Test(req)
if err != nil {
t.Fatalf("request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusUnauthorized {
t.Fatalf("expected 401, got %d", resp.StatusCode)
}
var got map[string]any
if err := json.NewDecoder(resp.Body).Decode(&got); err != nil {
t.Fatalf("failed to decode response: %v", err)
}
if got["code"] != "password_or_email_mismatch" {
t.Fatalf("expected code=password_or_email_mismatch, got=%v", got["code"])
}
if got["error"] != "Invalid credentials" {
t.Fatalf("expected error=Invalid credentials, got=%v", got["error"])
}
}