Commit Graph

11733 Commits

Author SHA1 Message Date
Katie Smith
0249f1602d Change hint text for the broadcast form 2021-07-19 14:40:14 +01:00
Katie Smith
103cf4890b Add paragraph to broadcast settings form
The form is going to change to remove all existing permissions when it
is submitted, so this adds a paragraph to explain that.
2021-07-19 14:40:14 +01:00
Katie Smith
7e8c638865 Change /broadcast/view-message.html page to work with both permissions
The buttons and links on this page now work with the original
permissions and the two new broadcast permissions. Since the new
broadcast permissions have the effect of splitting the `send_messages`
permission this means that additional sections of if/else logic were
required.
2021-07-19 14:40:14 +01:00
Katie Smith
7572a97436 Use new permissions for 'Prepare broadcast' button on templates page 2021-07-19 14:40:14 +01:00
Katie Smith
b6905c435b Use new permissions for the button on the broadcast dashboard
The broadcast dashboards contain a button to create a new broadcast.
This adds the new `create_broadcasts` permission as one of the
permissions needed to see the button.
2021-07-19 14:40:14 +01:00
Katie Smith
a84705f834 Update the broadcast roles
We've added new broadcast roles in the database (`create_broadcasts` and
`approve_broadcasts`).

Adding these has meant we've needed to do a bit of a rewrite of the roles and
permissions code since this had been based on the assumption that each
database permission only belongs to one admin role - this is no longer true.
This means that flipping the roles dict round to create a dict which
contains database permissions as the keys is no longer possible. We can't
necessarily tell which admin role someone has given a database permission.

To check if a user has an admin role given a list of database permissions,
the user must now have ALL the database permissions mapped to that role
(instead of just one). This works because no one has the `manage_users`
permission without also having the `manage_settings` (and similar for
the other admin roles which map to multiple database permissions).

Some test data was changed because it was using admin roles where
database permissions are actually used when the app is running. I've kept
the functionality of the `translate_permissions_from_db_to_admin_roles`
function passing through any unknown roles it is passed as an argument.
This is not necessary, so can be changed later if we decide it will not
ever be used. However, removing it would require updating a lot of
tests since the tests rely on this behaviour.
2021-07-19 14:40:13 +01:00
Katie Smith
a66a31c944 Allow users with new broadcast permissions access to routes
Added two new permissions - `create_broadcasts` and
`approve_broadcasts`. These new permissions get added to the
`has_permissions` decorator of the broadcast routes to allow the routes
to be accessed with either the old permissions on the new ones while we
switch over.

We were using the `send_messages` permission for the broadcast routes.
By having two new permissions we can allow a more granular control of
these routes.
2021-07-19 14:40:13 +01:00
Ben Thorner
078ac10c8d Merge pull request #3971 from alphagov/bump-python-client-178770155
Bump Python client version to 6.2.1
2021-07-19 13:27:29 +01:00
Ben Thorner
63926235cc Bump Python client version to 6.2.1
This is a prerequisite for [1]. I'd like to deploy it as a separate
change so it's easy to roll back if we need to.

[1]: https://github.com/alphagov/notifications-admin/pull/3970
2021-07-19 10:19:43 +01:00
Chris Hill-Scott
13745d812f Merge pull request #3965 from alphagov/refactor-org-invite-form
Refactor organisation invite form for reuse
2021-07-16 09:32:19 +01:00
Chris Hill-Scott
f8d4617672 Refactor organisation invite form for reuse
It’s exactly the same code as `BaseInviteUserForm` so there’s really no
need to duplicate it (and means that changes we make to
`BaseInviteUserForm` in the future will get inherited).
2021-07-16 09:20:06 +01:00
Chris Hill-Scott
f84f05191e Merge pull request #3968 from alphagov/forgotten-password-govuk-link
Style link in wrong password error
2021-07-16 09:16:53 +01:00
Chris Hill-Scott
93fbd1319c Merge pull request #3966 from alphagov/block-plus-addressing
Be strict about similar email addresses when inviting a user to an emergency alerts service
2021-07-16 09:16:47 +01:00
Rebecca Law
54787689c9 Merge pull request #3953 from alphagov/show_exceeded_daily_limit_on_page
Show status when job has exceeded the daily sending limit
2021-07-15 16:03:19 +01:00
Chris Hill-Scott
d749ee5cea Rename confusing variable
The reason the email address is considered invalid is because it is the
address of the person doing the inviting.

This commit renames the variable to be more specific and avoid confusion
with the email address of the person being invited.
2021-07-15 14:21:58 +01:00
Chris Hill-Scott
c3091223a9 Be strict about similar email addresses for alerts
We don’t want a single person to have two accounts on an emergency
alerts service because it would let them circumvent the two eyes
approval process.

We can go some way to mitigating against this by stopping people using
common methods that email providers use to alias email addresses. These
are:
- being case insensitive
- being insensitive to the position or number of dots in the local part
  of an email address
- using ‘plus addressing’

We already prevent the first one, this commit adds normalisation which
strip out the second two before doing the comparision with the current
user’s email address.
2021-07-15 13:55:50 +01:00
Ben Thorner
9170c0b175 Merge pull request #3969 from alphagov/fix-suspend-archive-perm-178770416
Fix backend permissions for stopping services
2021-07-15 09:29:20 +01:00
Katie Smith
9d4095074d Merge pull request #3967 from alphagov/broadcast-form-cache-clear
Clear user cache when broadcast service settings form is submitted
2021-07-14 16:02:14 +01:00
Ben Thorner
96a87e7cf2 Fix and test archive service permissions
Previously the backend would never validate permissions because the
"not service.active" part would (usually) fail. I've updated it to
match the (inverse of the) conditional we have in the HTML [1].

[1]: 6ac593aa5f/app/templates/views/service-settings.html (L455)
2021-07-14 14:51:33 +01:00
Ben Thorner
cd95a891a7 Enforce only Platform Admin can suspend / resume
This was previously out-of-sync with the superficial restriction in
the HTML [1][2].

[1]: 6ac593aa5f/app/templates/views/service-settings.html (L462-L468)
[2]: 6ac593aa5f/app/templates/views/service-settings.html (L471)
2021-07-14 14:51:32 +01:00
Rebecca Law
cca94e956b Update content 2021-07-14 09:55:20 +01:00
Rebecca Law
af7882e5a4 Show status when job has exceeded the daily sending limit
If a job exceeds the daily sending limit, show that on the job page. The job is only created if the sending limit has been reached when the delivery app is processing the job, usually this error is caught at the time the CSV is uploaded and the job is not created.
2021-07-14 09:55:20 +01:00
Chris Hill-Scott
db15e3ebb0 Style link in wrong password error
It was missing the class which gives it the correct colour and underline styles.

Also adds a little bit of spacing to make it look better.
2021-07-14 09:42:56 +01:00
Katie Smith
5b52b6f9bf Clear user cache when broadcast service settings form is submitted
When the broadcast service settings form is submitted it now removes all
permissions for users in notifications-api. This means it should be
clearing the user cache.
2021-07-13 17:06:35 +01:00
Chris Hill-Scott
9dd5c89252 Move two calls to str.lower next to each other
This means that we can rewrite `validate_email_address` to do a
different comparison without having to also change `__init__`

I’ve moved the platform admin check into its own conditional to keep the
line length manageable.
2021-07-13 15:38:13 +01:00
Ben Thorner
6ac593aa5f Merge pull request #3963 from alphagov/audit-service-resume-178770416
Audit when a service is resumed
2021-07-13 12:09:54 +01:00
Ben Thorner
1cde6ac686 Audit when a service is resumed
This could also be an issue if the service can send broadcasts, so
it's worth auditing who performed this action.
2021-07-13 10:57:23 +01:00
Ben Thorner
1fb529c448 Improve coverage of resume service tests
This makes the tests consistent with those for suspend / archive,
logging in with different users to make it clearer who can/not do
this action in the backend.

Note that we think this functionality may be too permissive [1],
so we may restrict it in a future PR.

[1]: https://github.com/alphagov/notifications-admin/pull/3959#issuecomment-878291295
2021-07-13 10:57:22 +01:00
Ben Thorner
d37c2abb9e DRY-up arg assertions in event handler tests
This will make it easier to add another handler in the next commit.
2021-07-13 10:57:21 +01:00
Ben Thorner
22ac1bfcae DRY-up and enforce kwargs for most events
For most events this makes the purpose of each argument clearer at
the point the event is called. It's still worth having a function
for each event type, as this abstracts knowledge of the event label.
Using a schema approach will make adding new events easier.

In the next commit we'll DRY-up the duplication in the tests as well.
2021-07-13 10:57:19 +01:00
Chris Hill-Scott
aefbe7709b Merge pull request #3951 from alphagov/hide-go-live-ticket-content
Hide details of go live request ticket from the user
2021-07-13 08:49:43 +01:00
Ben Thorner
cfe022bc7f Merge pull request #3959 from alphagov/audit-service-suspend-delete
Audit when services are suspended or archived
2021-07-12 14:50:07 +01:00
Pea Tyczynska
61e52faaee Merge pull request #3962 from alphagov/fix-bug-conditional-multiline
Bump utils to revert a bug to conditional multiline placeholders
2021-07-09 14:05:46 +01:00
Pea Tyczynska
7f08ae7c29 Bump utils to revert a bug to conditional multiline placeholders 2021-07-09 13:51:39 +01:00
Ben Thorner
9b62b7ccb0 DRY up mock event dict with a factory function 2021-07-08 17:17:25 +01:00
Ben Thorner
7e8b5d36be Remove redundant context for event handler tests
Just like the new tests for suspending and archiving services, we
can use the 'client' fixture instead of a context, which avoids
the extra nesting. Note that the first event handler doesn't use
its first argument, which I've tried to indicate with a string.
2021-07-08 17:17:24 +01:00
Ben Thorner
cd1fe0640c Improve coverage of suspend service tests
Previously these only tested with a Platform Admin user, but service
admins can suspend a service too. I've rewritten the tests to match
the 'archive_service' ones, which use the client_request fixture to
make changing the user easier.

Note that the return value of the service API client wasn't used for
anything, so it's safe to remove it from the mock.
2021-07-08 17:17:23 +01:00
Ben Thorner
301908460a Audit when a service is archived ("deleted")
This is similar to the previous commit. I've used the term 'archive'
to match the rest of the code - services aren't ever truly deleted.
2021-07-08 17:17:22 +01:00
Ben Thorner
bb4c86008a Add audit event for suspending a service
This is particularly important for broadcast services, where a rogue
service or platform admin could launch a DoS attack by suspending a
service at a critical moment when it needs to send alerts.
2021-07-08 15:29:52 +01:00
Ben Thorner
e72a260e13 Merge pull request #3947 from alphagov/allow-ccs
Allow other users to use security keys
2021-07-08 11:53:03 +01:00
Chris Hill-Scott
ceca92c84e Merge pull request #3952 from alphagov/emergency-alerts-content-review
Emergency alerts content review
2021-07-08 09:33:54 +01:00
Chris Hill-Scott
9ac51481d7 Remove most uses of broadcast from the tour
We prefer send now.

I think broadcast as a verb is still good in explaining how it coming
straight from the towers is different to a normal text message.
2021-07-07 16:31:28 +01:00
Ben Thorner
4c2915ce86 Use API flag to give users access to WebAuthn
This allows us to roll out the feature to other users. Note that
the flag is also "True" if the user has "webauthn_auth" as their
auth type, so this is compatible with the more fine-grained check
we have on the authentication parts of the feature. We could do a
more explicit "can_use_webauthn or webauthn_auth" check here, but
the idea is that we'll be able to get rid of this flag eventually,
so I've optimised for brevity instead.

I've modified a couple of the unhappy-path tests to make it more
explicit that the flag is false, since it can be true for Platform
Admins and "normal users" alike.
2021-07-07 15:04:48 +01:00
Ben Thorner
1a4dd04ab1 Add missing tests for authentication radios
Previously we only had one test for SMS auth not being disabled on
the invite version of the form. This modifies that test to fully
check what's displayed, and adds two more for the edit version of
the form.
2021-07-07 15:04:47 +01:00
Ben Thorner
a1b4ccc246 Prevent auth type changing for any WebAuthn user
Previously we applied this restriction to Platform Admins, on the
assumption that all of them use a security key to log in. Rather
than making that assumption, we can explicitly check their login
method, which also supports rolling out the feature to more users.
2021-07-07 15:04:43 +01:00
Ben Thorner
fab58b4e4e Merge pull request #3950 from alphagov/clarify-sms-prefix
Explain about text message prefixes when editing
2021-07-07 12:35:23 +01:00
Ben Thorner
a219de4fa3 Merge pull request #3958 from alphagov/update-roadmap
Remove March to June section from roadmap page
2021-07-07 09:59:53 +01:00
karlchillmaid
9a7008ba36 Update roadmap priorities 2021-07-06 17:57:14 +01:00
Chris Hill-Scott
cc4cc78d8c Hide details of go live request ticket from the user
We put some content in the go live ticket which is for our benefit, for
example notes about the organisation.

It’s hard for us to be able to say what we want here if we know that the
person making a go live request is going to see those notes.

This commit changes go live requests so that the initial content of the
ticket is hidden from the person raising it (in Zendesk it will appear
as an ‘internal note’, rather than a ‘public reply’).

---

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/877/files
2021-07-06 17:30:17 +01:00
Chris Hill-Scott
a4c461ed3f Merge pull request #3944 from alphagov/bump-utils-polygon-simplification
Bump utils to bring in new polygon simplification
2021-07-06 17:14:41 +01:00