Skip to content

Commit 0477e09

Browse files
committed
fix(test): update byok tests for renamed validate_claude_key
1 parent f3a682f commit 0477e09

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

apps/api/tests/modules/installation/test_byok_service.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
decrypt_byok_key,
1414
delete_byok_config,
1515
get_byok_config,
16-
validate_anthropic_api_key,
16+
validate_claude_key,
1717
)
1818

1919

20-
class TestValidateAnthropicApiKey:
20+
class TestValidateClaudeKey:
2121
async def test_valid_key(self):
2222
mock_response = MagicMock()
2323
mock_response.status_code = 200
@@ -29,7 +29,7 @@ async def test_valid_key(self):
2929
mock_client.__aexit__ = AsyncMock(return_value=False)
3030
mock_cls.return_value = mock_client
3131

32-
result = await validate_anthropic_api_key("sk-ant-valid-key")
32+
result = await validate_claude_key("sk-ant-valid-key")
3333
assert result is True
3434

3535
async def test_invalid_key_401(self):
@@ -43,9 +43,13 @@ async def test_invalid_key_401(self):
4343
mock_client.__aexit__ = AsyncMock(return_value=False)
4444
mock_cls.return_value = mock_client
4545

46-
result = await validate_anthropic_api_key("sk-ant-invalid")
46+
result = await validate_claude_key("sk-ant-invalid")
4747
assert result is False
4848

49+
async def test_oauth_token_accepted_without_api_call(self):
50+
result = await validate_claude_key("sk-ant-oat01-fakeoauthtoken")
51+
assert result is True
52+
4953
async def test_timeout_raises_external_service_error(self):
5054
with patch("helprs.modules.installation.service.httpx.AsyncClient") as mock_cls:
5155
mock_client = AsyncMock()
@@ -55,13 +59,13 @@ async def test_timeout_raises_external_service_error(self):
5559
mock_cls.return_value = mock_client
5660

5761
with pytest.raises(ExternalServiceError, match="temporarily unavailable"):
58-
await validate_anthropic_api_key("sk-ant-test")
62+
await validate_claude_key("sk-ant-test")
5963

6064

6165
class TestConfigureByok:
6266
async def test_success(self, db_session, test_installation, settings):
6367
with patch(
64-
"helprs.modules.installation.service.validate_anthropic_api_key",
68+
"helprs.modules.installation.service.validate_claude_key",
6569
return_value=True,
6670
):
6771
config = await configure_byok(
@@ -79,7 +83,7 @@ async def test_success(self, db_session, test_installation, settings):
7983
async def test_invalid_key_raises(self, db_session, test_installation, settings):
8084
with (
8185
patch(
82-
"helprs.modules.installation.service.validate_anthropic_api_key",
86+
"helprs.modules.installation.service.validate_claude_key",
8387
return_value=False,
8488
),
8589
pytest.raises(BYOKKeyInvalidError, match="validation failed"),
@@ -93,7 +97,7 @@ async def test_invalid_key_raises(self, db_session, test_installation, settings)
9397

9498
async def test_upsert_updates_existing(self, db_session, test_installation, settings):
9599
with patch(
96-
"helprs.modules.installation.service.validate_anthropic_api_key",
100+
"helprs.modules.installation.service.validate_claude_key",
97101
return_value=True,
98102
):
99103
config1 = await configure_byok(
@@ -138,7 +142,7 @@ def test_corrupted_raises(self, settings):
138142
class TestDeleteByokConfig:
139143
async def test_deletes_existing(self, db_session, test_installation, settings):
140144
with patch(
141-
"helprs.modules.installation.service.validate_anthropic_api_key",
145+
"helprs.modules.installation.service.validate_claude_key",
142146
return_value=True,
143147
):
144148
await configure_byok(

0 commit comments

Comments
 (0)