diff --git a/api/app/api/v1/api_keys.py b/api/app/api/v1/api_keys.py index 3533c75b..10ca78e0 100644 --- a/api/app/api/v1/api_keys.py +++ b/api/app/api/v1/api_keys.py @@ -13,9 +13,8 @@ from tools.viewdns.client import ViewDNSClient async def _test_viewdns(key_value: str) -> dict: client = ViewDNSClient(key_value) - raw = await client.ip_history("rengine.wiki") - record_count = len(raw.get("records", [])) - return {"message": f"OK — {record_count} IP history records for rengine.wiki"} + _ = await client.ip_history("rengine.wiki") + return {"message": "API Key is valid."} API_KEY_TESTERS = { diff --git a/frontend/src/lib/api/api-keys.ts b/frontend/src/lib/api/api-keys.ts index f2476056..60738afd 100644 --- a/frontend/src/lib/api/api-keys.ts +++ b/frontend/src/lib/api/api-keys.ts @@ -31,7 +31,7 @@ export const apiKeysApi = { return api.get(`/api-keys/${keyId}/reveal`); }, - async test(keyId: string): Promise<{ provider: string; status: string; message: string }> { + async test(keyId: string): Promise<{ provider: string; success: boolean; message: string }> { return api.post(`/api-keys/${keyId}/test`); } }; diff --git a/frontend/src/lib/components/settings/api-keys-tab.svelte b/frontend/src/lib/components/settings/api-keys-tab.svelte index 8aa322bb..3b60d8e8 100644 --- a/frontend/src/lib/components/settings/api-keys-tab.svelte +++ b/frontend/src/lib/components/settings/api-keys-tab.svelte @@ -73,6 +73,10 @@ let editPopoverOpen = $state(false); + let testDialogOpen = $state(false); + let testDialogKeyId = $state(null); + let testDialogProvider = $state(null); + async function fetchData() { isLoading = true; try { @@ -190,10 +194,10 @@ testingKeyId = keyId; try { const result = await apiKeysApi.test(keyId); - if (result.status === 'not_implemented') { - toast.info(result.message); + if (result.success) { + toast.success(result.message); } else { - toast.success('API key is valid'); + toast.error(result.message); } } catch (e) { toast.error(e instanceof Error ? e.message : 'Test failed'); @@ -490,7 +494,11 @@ size="sm" class="h-7 px-2 text-xs" disabled={testingKeyId === key.id} - onclick={() => handleTest(key.id)} + onclick={() => { + testDialogKeyId = key.id; + testDialogProvider = provider.provider; + testDialogOpen = true; + }} > {#if testingKeyId === key.id} @@ -631,3 +639,42 @@ + + + + + + + Test API Key + + This will make a live API call to verify the key works. It will consume 1 API call from your + ViewDNS quota. + + + + + + + +