mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
Add pages for create/view/revoke API keys
Copying what they’ve done on GOV.UK Pay, we should let users: - generate as many keys as they want - only see the key at time of creation - give keys a name - revoke any key at any time (this should be a one way operation) And based on discussions with @minglis and @servingUpAces, the keys should be used in conjunction with some kind of service ID, which gets encrypted with the key. In other words the secret itself never gets sent over the wire. This commit adds the UI (but not the underlying API integration) for doing the above.
This commit is contained in:
committed by
Rebecca Law
parent
5924500f3e
commit
9784a9936c
@@ -1,13 +1,87 @@
|
||||
from flask import url_for
|
||||
|
||||
|
||||
def test_should_show_api_keys_and_documentation_page(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
def test_should_show_documentation_page(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.get(url_for('main.documentation', service_id=123))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_show_api_keys_page(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.get(url_for('main.api_keys', service_id=123))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_show_name_api_key_page(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.get(url_for('main.create_api_key', service_id=123))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_redirect_to_new_api_key(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.post(url_for('main.create_api_key', service_id=123))
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.show_api_key', service_id=123, _external=True)
|
||||
|
||||
|
||||
def test_should_show_new_api_key(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.get(url_for('main.show_api_key', service_id=123))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_show_confirm_revoke_api_key(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.get(url_for('main.revoke_api_key', service_id=123, key_id=321))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_redirect_after_revoking_api_key(app_,
|
||||
db_,
|
||||
db_session,
|
||||
active_user):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user)
|
||||
response = client.post(url_for('main.revoke_api_key', service_id=123, key_id=321))
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('.api_keys', service_id=123, _external=True)
|
||||
|
||||
Reference in New Issue
Block a user