mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Sort API keys alphabetically
Currently the order of API keys seems to be non-deterministic:
d46caa184e/app/dao/api_key_dao.py (L32-L39)
Generally we sort things alphabetically, unless there’s a good reason to
do otherwise.
This commit sorts the API keys alphabetically.
This commit is contained in:
@@ -340,7 +340,10 @@ class Service():
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def api_keys(self):
|
def api_keys(self):
|
||||||
return api_key_api_client.get_api_keys(self.id)['apiKeys']
|
return sorted(
|
||||||
|
api_key_api_client.get_api_keys(self.id)['apiKeys'],
|
||||||
|
key=lambda key: key['name'].lower(),
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def api_key_names(self):
|
def api_key_names(self):
|
||||||
|
|||||||
@@ -190,22 +190,17 @@ def test_should_show_empty_api_keys_page(
|
|||||||
|
|
||||||
|
|
||||||
def test_should_show_api_keys_page(
|
def test_should_show_api_keys_page(
|
||||||
logged_in_client,
|
client_request,
|
||||||
api_user_active,
|
|
||||||
mock_login,
|
|
||||||
mock_get_api_keys,
|
mock_get_api_keys,
|
||||||
mock_get_service,
|
|
||||||
mock_has_permissions,
|
|
||||||
fake_uuid,
|
|
||||||
):
|
):
|
||||||
response = logged_in_client.get(url_for('main.api_keys', service_id=fake_uuid))
|
page = client_request.get('main.api_keys', service_id=SERVICE_ONE_ID)
|
||||||
|
rows = [normalize_spaces(row.text) for row in page.select('main tr')]
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert rows[0] == 'API keys Action'
|
||||||
resp_data = response.get_data(as_text=True)
|
assert rows[1] == 'another key name Revoked 1 January at 1:00am'
|
||||||
assert 'some key name' in resp_data
|
assert rows[2] == 'some key name Revoke'
|
||||||
assert 'another key name' in resp_data
|
|
||||||
assert 'Revoked 1 January at 1:00am' in resp_data
|
mock_get_api_keys.assert_called_once_with(SERVICE_ONE_ID)
|
||||||
mock_get_api_keys.assert_called_once_with(fake_uuid)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('service_mock, expected_options', [
|
@pytest.mark.parametrize('service_mock, expected_options', [
|
||||||
|
|||||||
Reference in New Issue
Block a user