Merge pull request #2287 from alphagov/remove-old-key-info-2

Remove old API key and service ID combo
This commit is contained in:
Chris Hill-Scott
2018-10-30 10:13:19 +00:00
committed by GitHub
2 changed files with 11 additions and 29 deletions

View File

@@ -32,17 +32,4 @@
</div>
<h2 class='heading-medium'>For older API clients</h2>
<p>
If the client youre using needs a service ID and an API key,
use these values:
</p>
<div class="bottom-gutter">
{{ api_key(service_id, 'Service ID', thing='service ID') }}
</div>
{{ api_key(secret, 'API key') }}
{% endblock %}

View File

@@ -248,7 +248,7 @@ def test_should_show_create_api_key_page(
def test_should_create_api_key_with_type_normal(
logged_in_client,
client_request,
api_user_active,
mock_login,
mock_get_api_keys,
@@ -258,27 +258,22 @@ def test_should_create_api_key_with_type_normal(
mocker,
):
post = mocker.patch('app.notify_client.api_key_api_client.ApiKeyApiClient.post', return_value={'data': fake_uuid})
service_id = str(uuid.uuid4())
response = logged_in_client.post(
url_for('main.create_api_key', service_id=service_id),
data={
page = client_request.post(
'main.create_api_key',
service_id=SERVICE_ONE_ID,
_data={
'key_name': 'Some default key name 1/2',
'key_type': 'normal'
}
},
_expected_status=200,
)
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
keys = page.find_all('span', {'class': 'api-key-key'})
for index, key in enumerate([
'some_default_key_name_12-{}-{}'.format(service_id, fake_uuid),
service_id,
fake_uuid
]):
assert keys[index].text.strip() == key
assert page.select_one('span.api-key-key').text.strip() == (
'some_default_key_name_12-{}-{}'.format(SERVICE_ONE_ID, fake_uuid)
)
post.assert_called_once_with(url='/service/{}/api-key'.format(service_id), data={
post.assert_called_once_with(url='/service/{}/api-key'.format(SERVICE_ONE_ID), data={
'name': 'Some default key name 1/2',
'key_type': 'normal',
'created_by': api_user_active.id