-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
"""Tests for the account application.""" | ||
from django.contrib.auth.models import User | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from .models import Profile | ||
|
||
|
||
class AccountTests(TestCase): | ||
"""Main test class for the account application.""" | ||
|
@@ -132,3 +135,20 @@ def test_password_change_validation(self): | |
}, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_masked_api_keys(self): | ||
"""Verify that the masked API keys are returned correctly.""" | ||
username = 'test_user' | ||
password = 'test_password' | ||
email = '[email protected]' | ||
|
||
# Create a new user and profile | ||
user = User.objects.create_user(username, email, password) | ||
profile = Profile.objects.create( | ||
user=user, anthropic_api_key='anthropic123456', cohere_key='cohere123456', openai_api_key='openai123456' | ||
) | ||
|
||
# Check the masked API keys | ||
self.assertEqual(profile.masked_anthropic_api_key, 'anthro*********') | ||
self.assertEqual(profile.masked_cohere_key, 'cohere******') | ||
self.assertEqual(profile.masked_openai_api_key, 'openai******') |