1
0
forked from baron/baron-sso

Fix hydra consent session parsing and audit detail tests

This commit is contained in:
Lectom C Han
2026-02-06 17:29:27 +09:00
parent 3a6ae4948a
commit 226de652e3
2 changed files with 47 additions and 2 deletions

View File

@@ -240,14 +240,20 @@ func (s *HydraAdminService) ListConsentSessions(ctx context.Context, subject, cl
}
defer resp.Body.Close()
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
if resp.StatusCode == http.StatusNoContent {
return []domain.HydraConsentSession{}, nil
}
body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024*1024))
if resp.StatusCode >= 300 {
return nil, fmt.Errorf("hydra admin: list consent sessions failed status=%d body=%s", resp.StatusCode, string(body))
}
if len(body) == 0 {
return []domain.HydraConsentSession{}, nil
}
var sessions []domain.HydraConsentSession
if err := json.Unmarshal(body, &sessions); err != nil {
return nil, fmt.Errorf("hydra admin: decode consent sessions failed: %w", err)
return nil, fmt.Errorf("hydra admin: decode consent sessions failed: %w body=%s", err, string(body))
}
return sessions, nil
}