mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Removed all govuk css (#2814)
* Removed all govuk css * Updated reference files * Removing govuk js * Fixed casing for modules, removed unused page * Got more reference images * Updated template page * Removed govuk padding util * Updated hint to uswds hint * More govuk cleanup * Commiting backstopjs ref files * Fixed all unit tests that broke due to brittleness around govuk styling * Added new ref images * Final removal of govuk * Officially removed all govuk references * Updated reference file * Updated link to button * UI modernization * Cleanup * removed govuk escaping tests since they are no longer needed * Fix CodeQL security issue in escapeElementName function - Escape backslashes first before other special characters - Prevents potential double-escaping vulnerability - Addresses CodeQL alert about improper string escaping * Found more govuk removal. Fixed unit tests * Add missing pipeline check to pre-commit * updated test * Updated e2e test * More update to e2e test * Fixed another e2e test * Simple PR comments addressed * More updates * Updated backstop ref files * Refactored folder selection for non-admins * Updated redundant line * Updated tests to include correct mocks * Added more ref files * Addressing carlos comments * Addressing Carlo comments, cleanup of window initing * More cleanup and addressing carlo comments * Fixing a11 scan * Fixed a few issues with javascript * Fixed for pr * Fixing e2e tests * Tweaking e2e test * Added more ref files and cleaned up urls.js * Fixed bug with creating new template * Removed brittle test - addressed code ql comment * e2e race condition fix * More e2e test fixes * Updated e2e tests to not wait for text sent * Updated test to not wait for button click response * Made tear down more resilent if staging is down * reverted e2e test to what was working before main merge * Updated backstopRef images * Updated gulp to include job-polling differently
This commit is contained in:
77
tests/app/notify_client/test_api_key_api_client_coverage.py
Normal file
77
tests/app/notify_client/test_api_key_api_client_coverage.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.enums import ApiKeyType
|
||||
from app.notify_client.api_key_api_client import (
|
||||
KEY_TYPE_NORMAL,
|
||||
KEY_TYPE_TEAM,
|
||||
KEY_TYPE_TEST,
|
||||
ApiKeyApiClient,
|
||||
)
|
||||
|
||||
|
||||
class TestApiKeyApiClientCoverage:
|
||||
"""Coverage tests for api_key_api_client.py"""
|
||||
|
||||
def test_key_type_constants(self):
|
||||
"""Test that key type constants are properly set"""
|
||||
assert KEY_TYPE_NORMAL == ApiKeyType.NORMAL
|
||||
assert KEY_TYPE_TEAM == ApiKeyType.TEAM
|
||||
assert KEY_TYPE_TEST == ApiKeyType.TEST
|
||||
|
||||
@patch("app.notify_client.api_key_api_client._attach_current_user")
|
||||
def test_get_api_keys(self, mock_attach_user, mocker):
|
||||
"""Test get_api_keys method"""
|
||||
client = ApiKeyApiClient()
|
||||
mock_get = mocker.patch.object(client, "get", return_value={"keys": []})
|
||||
|
||||
result = client.get_api_keys("service-123")
|
||||
|
||||
mock_get.assert_called_once_with(url="/service/service-123/api-keys")
|
||||
assert result == {"keys": []}
|
||||
|
||||
@patch("app.notify_client.api_key_api_client._attach_current_user")
|
||||
def test_create_api_key(self, mock_attach_user, mocker):
|
||||
"""Test create_api_key method"""
|
||||
client = ApiKeyApiClient()
|
||||
mock_attach_user.return_value = {
|
||||
"name": "Test Key",
|
||||
"key_type": "normal",
|
||||
"created_by": "user-123",
|
||||
}
|
||||
mock_post = mocker.patch.object(
|
||||
client, "post", return_value={"data": {"id": "key-123", "name": "Test Key"}}
|
||||
)
|
||||
|
||||
result = client.create_api_key("service-123", "Test Key", "normal")
|
||||
|
||||
mock_attach_user.assert_called_once_with(
|
||||
{"name": "Test Key", "key_type": "normal"}
|
||||
)
|
||||
mock_post.assert_called_once_with(
|
||||
url="/service/service-123/api-key",
|
||||
data={"name": "Test Key", "key_type": "normal", "created_by": "user-123"},
|
||||
)
|
||||
assert result == {"id": "key-123", "name": "Test Key"}
|
||||
|
||||
@patch("app.notify_client.api_key_api_client._attach_current_user")
|
||||
def test_revoke_api_key(self, mock_attach_user, mocker):
|
||||
"""Test revoke_api_key method"""
|
||||
client = ApiKeyApiClient()
|
||||
mock_attach_user.return_value = {"created_by": "user-123"}
|
||||
mock_post = mocker.patch.object(client, "post", return_value={"success": True})
|
||||
|
||||
result = client.revoke_api_key("service-123", "key-456")
|
||||
|
||||
mock_attach_user.assert_called_once_with({})
|
||||
mock_post.assert_called_once_with(
|
||||
url="/service/service-123/api-key/revoke/key-456",
|
||||
data={"created_by": "user-123"},
|
||||
)
|
||||
assert result == {"success": True}
|
||||
|
||||
def test_api_key_api_client_singleton(self):
|
||||
"""Test that api_key_api_client is created"""
|
||||
from app.notify_client.api_key_api_client import api_key_api_client
|
||||
|
||||
assert api_key_api_client is not None
|
||||
assert isinstance(api_key_api_client, ApiKeyApiClient)
|
||||
@@ -106,7 +106,7 @@ def test_client_parses_job_stats(mocker):
|
||||
],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
@@ -145,7 +145,7 @@ def test_client_parses_empty_job_stats(mocker):
|
||||
"statistics": [],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
@@ -195,7 +195,7 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
@@ -222,7 +222,7 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
@@ -272,7 +272,7 @@ def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
"statistics": [],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
@@ -290,7 +290,7 @@ def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
"statistics": [],
|
||||
"original_file_name": "test-notify-email.csv",
|
||||
"created_by": {
|
||||
"name": "test-user@digital.cabinet-office.gov.uk",
|
||||
"name": "test-user@example.com",
|
||||
"id": "3571f2ae-7a39-4fb4-9ad7-8453f5257072",
|
||||
},
|
||||
"created_at": "2016-08-24T08:09:56.371073+00:00",
|
||||
|
||||
Reference in New Issue
Block a user