Add page to archive user

Users can only be archived by Platform Admin from the user page
(/users/<user_id>). This removes them from all services and orgs and
updates their details.
This commit is contained in:
Katie Smith
2019-05-22 11:38:47 +01:00
parent 7b3d522070
commit 00bb7a0ea0
6 changed files with 58 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
from bs4 import BeautifulSoup
from flask import url_for
from lxml import html
@@ -145,3 +146,33 @@ def test_user_information_page_displays_if_there_are_failed_login_attempts(
document = html.fromstring(response.get_data(as_text=True))
assert document.xpath("//p/text()[normalize-space()='2 failed login attempts']")
def test_archive_user_prompts_for_confirmation(
logged_in_platform_admin_client,
api_user_active,
mock_get_organisations_and_services_for_user,
):
response = logged_in_platform_admin_client.get(
url_for('main.archive_user', user_id=api_user_active.id)
)
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert 'Are you sure you want to archive this user?' in page.find('div', class_='banner-dangerous').text
def test_archive_user_posts_to_user_client(
logged_in_platform_admin_client,
api_user_active,
mocker,
):
mock_user_client = mocker.patch('app.user_api_client.post')
response = logged_in_platform_admin_client.post(
url_for('main.archive_user', user_id=api_user_active.id)
)
assert response.status_code == 302
assert response.location == url_for('main.user_information', user_id=api_user_active.id, _external=True)
mock_user_client.assert_called_once_with('/user/{}/archive'.format(api_user_active.id), data=None)