mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 17:38:50 -04:00
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:
@@ -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)
|
||||
|
||||
@@ -194,6 +194,7 @@ def test_returns_value_from_cache(
|
||||
(user_api_client, 'add_user_to_organisation', [sample_uuid(), user_id], {}),
|
||||
(user_api_client, 'set_user_permissions', [user_id, SERVICE_ONE_ID, []], {}),
|
||||
(user_api_client, 'activate_user', [api_user_pending(sample_uuid())['id']], {}),
|
||||
(user_api_client, 'archive_user', [user_id], {}),
|
||||
(service_api_client, 'remove_user_from_service', [SERVICE_ONE_ID, user_id], {}),
|
||||
(service_api_client, 'create_service', ['', '', 0, False, user_id, sample_uuid()], {}),
|
||||
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, user_id], {}),
|
||||
|
||||
Reference in New Issue
Block a user