Commit Graph

1783 Commits

Author SHA1 Message Date
Rebecca Law
6bdb8b7210 Rename the method for usage and update the tests. 2018-05-29 15:31:40 +01:00
Katie Smith
58cc1604a7 Bump utils and sanitise header values
Updated notifications-utils. This brings in
- the renamed character sanitization classes
- the change to allow unicode in letter addresses (this lets us delete
a test that is no longer relevant)

Also replaced non-ascii characters in headers. This fixes a bug where
non-ascii characters in a CSV filename were causing errors since the
filename is also used in the header.
2018-05-25 10:34:47 +01:00
Pete Herlihy
3459f74110 Merge pull request #2093 from alphagov/privacy-page
Privacy page
2018-05-23 15:42:18 +01:00
Pete Herlihy
aa8992c7b9 Testing that the privacy page exists 2018-05-23 14:36:36 +01:00
Rebecca Law
cd09c391e8 Letter have multliple rates, the agregate number was not taking that into account for the usage page. 2018-05-22 17:37:48 +01:00
Chris Hill-Scott
79314de817 Add page where users can say they want branding
At the moment branding is an undocumented feature. We get a bunch of
support tickets from teams asking its possible.

This commit:
- lets people know it’s possible, and what the options are
- is the first step towards making this process as self-service as
  possible

In some cases we will be able to infer a user’s organisation from there
email address, and Google image search their logo. So the experience for
them is that they press a button and government just sorts it out for
you (also known as "the dream").

In other cases we will have to get back to people asking for a copy of
their logo, or to find out about their service, but this is what we have
to do at the moment anyway.
2018-05-18 16:24:20 +01:00
Leo Hemsted
3097fb75ee fix usage page sms rate calculation
usage page used to make the assumption that the first row of the usage
stats would always be SMS. This now isn't always the case, so make sure
when working out the rate, it only looks at sms rows. Specifically, it
takes the rate from the first stats row. This makes a big assumption
that all the rows will have the same rate per financial year.
2018-05-17 10:40:48 +01:00
Rebecca Law
c721c40ec7 Ignore temporary endpoint in navigation test 2018-05-16 13:23:49 +01:00
Chris Hill-Scott
7b759963b7 Merge pull request #2073 from alphagov/back-to-only-authed
Only show ‘back to service name’ link if signed in
2018-05-14 15:36:16 +01:00
Chris Hill-Scott
fc87ec70a7 Merge pull request #2072 from alphagov/test-domains
Check that all domains in our lists are valid
2018-05-14 15:36:07 +01:00
Chris Hill-Scott
e5c1c68942 Merge pull request #2074 from alphagov/sign-in-for-agreement
Let people choose which agreement to download if signed in
2018-05-14 15:35:57 +01:00
Chris Hill-Scott
3a471e2f61 Stop overwriting S3 metadata with empty filename
When you upload a CSV the check page takes the file name from the URL
and writes it to the S3 metadata for that file.

This also happens when you go to the .png version of this page.

The .png version of the page doesn’t have the filename in the URL. So it
re-writes the S3 metadata with an empty filename.

This means that all letter jobs sent recently have no file names. This
commit fixes this problem.
2018-05-10 17:01:03 +01:00
Chris Hill-Scott
f9421789d0 Only show ‘back to service name’ link if signed in
When you’re not signed in you can still have a service in your session.
But there’s no point trying to get to its dashboard until you’re signed
in – you’ll just be sent back to the ‘sign in’ page.
2018-05-09 15:32:46 +01:00
Leo Hemsted
5f4d9a60da Merge pull request #2075 from alphagov/statistics-endpoint
use service statistics endpoint instead of detailed service
2018-05-09 14:46:56 +01:00
Leo Hemsted
78a6f86043 use service statistics endpoint instead of detailed service
we're not actually looking at the detailed service aspects - just
the stats. We're doing this in three places:

* dashboard
* notification activity page
* when checking jobs to see if we're over the daily limit

change these places to use a new api endpoint (service/id/statistics),
which hopefully be a little more performant, and will definitely be a
little more organised - moving away from generic endpoints with loads
of optional parameters.

We still need the detailed endpoints for the platform admin page tho.

Depends on https://github.com/alphagov/notifications-api/pull/1865
2018-05-09 14:00:24 +01:00
Chris Hill-Scott
220e11ccdd Customise download page if agreement signed
If the user’s organisation has already signed the agreement we shouldn’t
give them the instructions for how to sign it.
2018-05-09 13:44:33 +01:00
Chris Hill-Scott
dc6d66daba Make people sign in to get the agreement
Currently we have a bunch of users who aren’t signed in asking us for
the agreement.

This is bad because:
- it’s slower (for them) than just being able to download it
- it creates work for us

We can’t just offer the agreement to anyone, but we can offer to it to
anyone who’s signed in because we now let people self-select which
version to download when we can’t tell which one to give them.
2018-05-09 13:41:51 +01:00
Chris Hill-Scott
947b67ee1a Let people choose which agreement to download
If we don’t know whether people belong to a crown organisation we should
give them the option of self-selecting, because they might themselves
know.

This commit adds a new version of the ‘agreement’ page which gives
people exactly that choice. It doesn’t link to it yet.
2018-05-09 13:40:21 +01:00
Chris Hill-Scott
952a83f23a Merge pull request #2068 from alphagov/2fa-input
Improve 2fa code input
2018-05-08 16:53:54 +01:00
Chris Hill-Scott
060b93c4d4 Check that all domains in our lists are valid
Since we have too many to add individual tests every time we add a new
one now.
2018-05-08 15:25:41 +01:00
Chris Hill-Scott
3aa688d1e5 Merge pull request #2071 from alphagov/public-agreement
Add URLs to download the agreement without login
2018-05-08 14:56:47 +01:00
Chris Hill-Scott
771f916630 Add URLs to download the agreement without login
So that we can share these URLs in an email we’re sending out.
2018-05-08 14:49:06 +01:00
Chris Hill-Scott
0e1e5ccecc Merge pull request #2070 from alphagov/manheadschool
Adding mansheadschool to the whitelist of domains
2018-05-08 14:29:53 +01:00
Pete Herlihy
bb7973f753 Adding a test for mansheadschool whitelisting domain 2018-05-08 11:42:04 +01:00
Leo Hemsted
e47a459757 Merge pull request #2066 from alphagov/mock-tests
Make sure we always mock endpoints in tests
2018-05-08 11:37:51 +01:00
Leo Hemsted
4ddd3aa155 use client_request to always check the response
this'll avoid us accidentally 503ing and ignoring it in tests where we
check for "assert my_content not present"
2018-05-08 11:16:12 +01:00
Chris Hill-Scott
02907afce1 Refactor sms_code functionality into the class
So it’s all in one place, not two.
2018-05-08 11:03:01 +01:00
Chris Hill-Scott
063f9cc081 Enable numeric keypad for text message code
If you’re signing in on a phone, it’s easier to type the two factor code
with a numeric keypad. The most reliable way to get the numeric keypad
to show up on multiple devices is:
- `type='tel'` (not `type='number'` because that’s only meant for
  numbers, not string of digits, ie `01234` is not a number)
- `pattern='[0-9]*'`, without which it doesn’t work on iOS

Based on the guidance here:
- https://github.com/alphagov/govuk-design-system-backlog/issues/74
- https://docs.google.com/document/d/1wozIhOdt6wvlgqVReauUnlsJI-3fqUlNuQFwUI7tqAA/edit
2018-05-08 10:55:42 +01:00
Chris Hill-Scott
4d678aec93 Give better error messages for incorrect code
If we know the code won’t pass the validation on the API side, we might
as well tell the user before even passing it to the API.

So this commit:
- adds some more validators to the field
- rewrites the validation function on the form to actually call the
  field-level validators before hitting the API 🤦‍♂️
- refactors the tests to be parametrize, which means they can be
  shorter, easier to read, and more comprehensive
2018-05-08 10:53:22 +01:00
Leo Hemsted
7656d3d567 ensure create_email_branding is mocked in tests
also fix asserts to check status codes (to make sure it's not 500)
2018-05-03 16:33:37 +01:00
Leo Hemsted
236339435c conversations only looks for 404 errors from inbound sms
stops masking some 503s in tests
2018-05-03 16:33:37 +01:00
Leo Hemsted
09a8e863a4 in send flow replace suppress with try catch
suppress was suppressing 404 errors (the happy path) - but it was also
suppressing 503s from tests where we hadn't mocked endpoints
2018-05-03 16:33:32 +01:00
Leo Hemsted
e8ef6fa174 don't swallow HTTP errors from create_event
tests weren't patching out create_event (which is invoked every time a
user logs in). This was getting caught by our egress proxy on jenkins.
We didn't notice because the event handler code was swallowing all
exceptions and not re-raising.

This changes that code to no longer swallow exceptions. Since we did
that, we also need to update all the tests that test log-in to mock
the call
2018-05-03 16:14:13 +01:00
Chris Hill-Scott
793842bb3b Let users download the crown agreement
This (partially) reverts commit dca5546cbd

Depends on

- [ ] agreement being uploaded to the bucket in all environments as
      `crown.pdf`
2018-05-02 09:54:13 +01:00
Alexey Bezhan
f663092cf4 Add a button for switching 'upload_document' permission
Adds a platform admin button to the service settings to turn on/off
'upload_document' service permission. The permission allows uploading
documents to document-download-api through the post notification API
endpoint.
2018-05-01 16:53:21 +01:00
Chris Hill-Scott
054f75a8ed Don’t load the check page if a job exists already
If a user clicks ‘back’ once they’ve sent a job we don’t want them to
land on the ‘check’ page again. This would suggest that they can send
the same job again (they can’t because that `job_id` is in the database
already). That said, it’s confusing to see that page; the natural thing
is to go jump back another step, to where you uploaded the file.
2018-05-01 09:47:05 +01:00
Chris Hill-Scott
b44074bf3a Stop writing job metadata to the session
We’re not looking at the job metadata in the session any more (see
previous commits) so it’s safe to stop writing it.
2018-05-01 09:47:05 +01:00
Chris Hill-Scott
8c04f8f21a Stop checking the session to see if a file’s valid
We’re going to stop storing job metadata in the session. So we can’t
rely on it for checking whether a file is valid. That safeguard is
happening in the API instead now (because it’s looking at the metadata
stored in S3).
2018-05-01 09:47:04 +01:00
Chris Hill-Scott
98214884d3 Stop posting job metadata to the API
The API is looking at the S3 metadata for this information now, so
there’s no need for us to continue sending it through.
2018-05-01 09:47:04 +01:00
Katie Smith
0e370d511e Update service_api_client to use new endpoints
API now has separate endpoints to archive email reply-to addresses and
SMS senders, so we no longer need to use the endpoints for updating.
2018-05-01 08:38:54 +01:00
Chris Hill-Scott
965bc76c42 Allow delete email reply to address, SMS senders
For both SMS senders and email reply to addresses this commit adds:
- a delete link
- a confirmation loop

It doesn’t let users delete:
- default SMS senders or reply to addresses (they always have to have
  one)
- inbound numbers

It assumes that the API will allow updating of an attribute named
`active` on the respective database rows. It could work in a different
way. We can’t do complete deletion though because these will still be
keyed to notifications.
2018-05-01 08:38:54 +01:00
Leo Hemsted
b3101a08b0 Merge pull request #2037 from alphagov/strip-obscure-whitespace
Strip obscure whitespace from form submissions
2018-04-30 14:41:31 +01:00
Leo Hemsted
cae4cd69be Merge pull request #2055 from alphagov/reply-to-anyone
allow non-gov reply to email addresses
2018-04-30 14:39:48 +01:00
Leo Hemsted
60202cf5af allow non-gov reply to email addresses
we reckon users will like to see gov reply-to email addresses because
it will improve their confidence in the email.

however, some services, for a few complex reasons, don't want a gov
reply to address. rather than add their specific domains to the
whitelist for signups etc, just make reply tos allowed from any domain.

We vet reply-tos before services go live anyway.
2018-04-30 14:03:57 +01:00
Chris Hill-Scott
ef4dd9d126 Add some breathing room to file name length limit
Because Amazon stores metadata keys prefixed with `x-amz-` which might
get counted as part of the size.
2018-04-30 11:44:00 +01:00
Chris Hill-Scott
bc8bc727f3 Limit length of filename
S3 has a limit of 2kb for metadata:

> the user-defined metadata is limited to 2 KB in size. The size of
> user-defined metadata is measured by taking the sum of the number of
> bytes in the UTF-8 encoding of each key and value.

– https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-metadata

This means we have a limit of 1870 bytes for the filename:
```python
encoded = 'notification_count50000template_id665d26e7-ceac-4cc5-82ed-63d773d21561validTrueoriginal_file_name'.encode('utf-8')
sys.getsizeof(b)
>>> 130
2000-130
>>> 1870
```

Or, in other words, ~918 characters:
```python
sys.getsizeof(('ü'*918).encode('utf-8'))
>>> 1869
```
2018-04-30 11:44:00 +01:00
Chris Hill-Scott
66e6538d95 Store original filename as S3 metadata
By doing this we no longer have to store it in the session. This is the
last thing that’s currently in the session, so removing it means we can
drop session storage for file uploads entirely.
2018-04-30 10:06:33 +01:00
Chris Hill-Scott
4cc8f39231 Remove reference to removed endpoints 2018-04-27 16:50:09 +01:00
Chris Hill-Scott
48114f1836 Merge pull request #2047 from alphagov/store-s3-metadata
Store info about files as S3 metadata
2018-04-27 16:43:52 +01:00
Chris Hill-Scott
872d9ea62b Merge pull request #2033 from alphagov/selected-nav
Highlight selected navigation item
2018-04-27 16:38:27 +01:00