feat: add CrowdSec API key status handling and warning component

- Implemented `getCrowdsecKeyStatus` API call to retrieve the current status of the CrowdSec API key.
- Created `CrowdSecKeyWarning` component to display warnings when the API key is rejected.
- Integrated `CrowdSecKeyWarning` into the Security page, ensuring it only shows when relevant.
- Updated i18n initialization in main.tsx to prevent race conditions during rendering.
- Enhanced authentication setup in tests to handle various response statuses more robustly.
- Adjusted security tests to accept broader error responses for import validation.
This commit is contained in:
GitHub Actions
2026-02-04 09:17:25 +00:00
parent 1267b74ace
commit 6351a9bba3
32 changed files with 4409 additions and 544 deletions
@@ -235,11 +235,18 @@ func TestGenerateConfig_HTTPChallenge_ExcludesIPDomains(t *testing.T) {
}
func TestGetCrowdSecAPIKey_EnvPriority(t *testing.T) {
// Skip if bouncer_key file exists (file takes priority over env vars per Phase 1 of LAPI auth fix)
const bouncerKeyFile = "/app/data/crowdsec/bouncer_key"
if _, err := os.Stat(bouncerKeyFile); err == nil {
t.Skip("Skipping env priority test - bouncer_key file exists (file takes priority over env vars)")
}
_ = os.Unsetenv("CROWDSEC_API_KEY")
_ = os.Unsetenv("CROWDSEC_BOUNCER_API_KEY")
t.Setenv("CROWDSEC_BOUNCER_API_KEY", "bouncer")
t.Setenv("CROWDSEC_API_KEY", "primary")
// CHARON_SECURITY_CROWDSEC_API_KEY has highest priority among env vars
require.Equal(t, "primary", getCrowdSecAPIKey())
_ = os.Unsetenv("CROWDSEC_API_KEY")