forked from baron/baron-sso
Fix hydra consent session parsing and audit detail tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user