Commit Graph

82 Commits

Author SHA1 Message Date
Carlo Costino
35ecd7006a Finally finished linting all the tests!
...Now to fix the ones I broke... :lolsob:

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-10-12 10:26:01 -04:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Steven Reilly
13d0e46b52 blunt rename of org (#620) 2023-07-12 12:09:44 -04:00
Kenneth Kehl
4882595a48 notify-245 update the allowlist for user domains (#510)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-05-19 16:54:27 -04:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
Ben Thorner
e0b62bed70 Group form tests in a directory
This makes it clearer we have tests for the code in forms.py, which
I missed initially. In future we could also split up forms.py in a
similar way, as it's currently _very long_.

As part of grouping tests for code in forms.py, I've extracted some
from test_validators.py, so that what remains is focussed on testing
the code in validators.py.
2022-03-11 11:17:43 +00:00
Chris Hill-Scott
6540701aa7 Replace uses of client to set request context
Some tests use the `client` fixture but don’t call any of its methods.
The reason for doing this is because the test depends on something in
the request context.

This commit replaces all those instances with `client_request`, which
also sets the request context.

These tests are the last ones that still use the `client` fixture. By
replacing it with `client_request` we will be able to say that no tests
should be using the `client` fixture directly.
2022-01-10 14:39:46 +00:00
David McDonald
a6cac27957 Allow straight single quote in sms sender names
This is so we can allow the sender name 'UC' for DWP.

Note, this is specifically only straight single quotes and not curly
quotes or double quotes. Curly quotes are not supported in the GSM
character set (https://en.wikipedia.org/wiki/GSM_03.38). There is
currently no defined user ask to support double quotes in sms sender
names.

I have tested this by sending a message through both Firetext and MMG to
make sure they both support the single quote character in SMS sender
names.

DWP also have had no particular issues using the SMS sender name with
their existing system in the past either.
2021-07-27 09:26:16 +01:00
David McDonald
65bdc7f5a4 Refactor of test cases into parametrized tests
No reason this shouldn't be parametrized. It will be neater, more
extendable and give better error messages

No functionality change, however I did slightly adapt one or two of the
test cases (for example to change the 11 characters or fewer test to
test on the boundary with 12 characters rather than many more).
2021-07-26 14:33:54 +01:00
Chris Hill-Scott
5c158891aa Prune the email domains list
We only need domains in here which either:
- don’t belong to a single organisation (eg gov.uk)

All other domains should be stored in the database.

This PR removes domains which are now in the database.

Before
---

```sql
select domain from domain where domain in ('gov.uk', 'mod.uk', 'mil.uk', 'd
 dc-mod.org', 'gov.scot', 'parliament.scot', 'parliament.uk', 'nhs.uk', 'nhs.net', 'nhs.scot', 'police.uk', 'scotent.c
 o.uk', 'assembly.wales', 'cjsm.net', 'gov.wales', 'ac.uk', 'sch.uk', 'onevoicewales.wales', 'mtvh.co.uk', 'wmca.org.u
 k', 'suttonmail.org');
 ```

+-----------------+
| domain          |
|-----------------+
| mtvh.co.uk      |
| wmca.org.uk     |
| gov.wales       |
| gov.scot        |
| parliament.uk   |
| assembly.wales  |
| mil.uk          |
| mod.uk          |
| ddc-mod.org     |
| parliament.scot |
| scotent.co.uk   |
+-----------------+

After
---

```sql
select domain from domain where domain in ('gov.uk', 'nhs.uk', 'nhs.ne
 t', 'nhs.scot', 'police.uk', 'cjsm.net', 'ac.uk', 'sch.uk', 'onevoicewales.wales', 'suttonmail.org') ;
```

+----------+
| domain   |
|----------|
+----------+
2021-06-04 11:45:48 +01:00
Chris Hill-Scott
e832d18002 Make error message specific to template type 2020-07-03 15:46:00 +01:00
David McDonald
9f557dd086 Reduce min sender length from 4 to 3
This is now supported at the network and aggregator level
2020-04-21 12:51:54 +01:00
Chris Hill-Scott
1fe3f1871e Allow underscores in SMS senders 2020-04-02 15:57:46 +01:00
Chris Hill-Scott
db2d312ba7 Link to ‘who it’s for’ when error creating account
If someone enters an email address from a domain we don’t recognise we
direct them straight to our support channel. This is causing increased
contact from suppliers and members of the public.

Now that we have a page which explains who can use Notify, let’s direct
people there first. Then if they really do need to contact support
(because we don’t recognise their organisation) then they can do so from
that page.
2020-03-26 14:55:51 +00:00
Pea Tyczynska
21e6d994b9 Validate service and organisation name 2019-11-20 13:31:01 +00:00
karlchillmaid
508ac04aa6 Replace negative contractions 2019-09-23 13:20:25 +01:00
Chris Hill-Scott
d9f885344c Remove domains that belong to an organisation
If a domain is already in our organisation list then we no longer need
to manually update it here. As part of this process I went and
proactively added some organisations, so I could remove more of them
from this file. I only did this where I could clearly determine from the
domain or a suppot ticket what the organisation was.
2019-06-03 13:21:29 +01:00
Chris Hill-Scott
8835486d4e Look in organisation for whitelisted domains
At the moment we have to update a YAML file and deploy the change to get
a new domain whitelisted.

We already have a thing for adding new domains – the organisation stuff.

This commit extends the validation to look in the `domains` table on the
API if it can’t find anything in the YAML whitelist.

This has the advantage of:
- not having to deploy code to whitelist a new domain
- forcing us to create new organisations as they come along, so that
  users’ services automatically get allocated to the organisation once
  their domain is whitelisted
2019-06-03 11:41:13 +01:00
Katie Smith
5be6b41195 Allow Welsh characters in SMS
- This brings in the latest version of notifications-utils which
allows Welsh characters in SMS templates.
- Updated the pricing page to show the new prices for SMS with certain
Welsh characters
2019-05-15 14:20:49 +01:00
Pea Tyczynska
3f6e0b6631 Update common passwords blacklist
I did the update following instructions from this commit:
https://github.com/alphagov/notifications-admin/
commit/136662bd309d986a9b7c3e0ee76588612c1ab761

Password repositiories I used were:
darkweb2017-top10000.txt
probable-v2-top12000.txt
twitter-banned.txt
2019-02-15 13:43:46 +00:00
Chris Hill-Scott
36eac9d031 Set min text message sender length to 4 characters
We’ve learned of a change implemented today by the UK mobile
network operators, to stop allowing text message sender names
of 3 or less characters.

Adding this validation will not affect existing senders, only those
users trying to add to or update their senders.
2018-09-19 16:32:34 +01:00
Pete Herlihy
bb7973f753 Adding a test for mansheadschool whitelisting domain 2018-05-08 11:42:04 +01:00
Katie Smith
11a6c8cfb5 Update SMS sender validation to reject senders starting with 00
Having SMS senders that start with 00 can cause issues with Firetext due
to Firetext's validation rules, so we shouldn't allow SMS senders to start
with 00.

Firetext treats a double 00 at the start of the senderID as an international
prefix, so removes them. A sender of 00447876574016 would become 447876574016.

Under Firetext's validation rules, an SMS sender of five 0s (00000) would
become  4400. This is because the first 00 are removed (as the international
prefix). The third 0 is seen as the start of a phone number, and becomes 44,
leaving the final 00 = 4400.
2018-02-28 13:40:20 +00:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
Rebecca Law
2b739535d4 Added an edge case test 2018-02-15 16:39:42 +00:00
Rebecca Law
6bd99e0599 Added a validation for a minimum of 3 character.
If the SMS sender is less than 3 characters one of our providers will return an error.
2018-02-15 16:06:44 +00:00
Pete Herlihy
57b711ebdc Adding Highways England to allowed domains tests 2018-01-30 11:22:17 +00:00
Leo Hemsted
b27eacb03b oops 2018-01-10 10:56:21 +00:00
Leo Hemsted
224b9e5098 Update test_validators.py 2018-01-10 10:48:58 +00:00
Chris Hill-Scott
1e7b330bd9 Add British Museum to whitelist
> BM is an executive non-departmental public body, sponsored by the
> Department for Digital, Culture, Media & Sport.
>
> British Museum has a separate website (http://www.britishmuseum.org)

– https://www.gov.uk/government/organisations/british-museum
2018-01-04 15:36:22 +00:00
Chris Hill-Scott
08c007d998 Add Marine Management Organisation as email domain
Seems like sometimes they use a Defra email address, sometimes their
own .org.uk one.
2017-12-18 11:52:56 +00:00
Chris Hill-Scott
eef66b70de Reword because ‘inbetween’ isn’t a word 2017-12-11 11:19:33 +00:00
Chris Hill-Scott
242a216c1b Update error message about commas in placeholders
We call the yellow things ‘double brackets’ on the frontend, not fields
or placeholders. This error message was a bit out of date.

Also refactored it to use the `Field` class; this code was probably
written before `Field` was factored out of `Template`.
2017-12-11 11:19:33 +00:00
Pete Herlihy
2b8fe86e36 Adding a test for the domain biglotterfund.org.uk 2017-11-21 13:58:49 +00:00
chrisw
d02cd67b0d Fixed broken edit functionality 2017-10-30 15:31:35 +00:00
Pete Herlihy
74992da1c8 Adding acas.org.uk to whitelist 2017-09-29 09:24:07 +01:00
Chris Hill-Scott
6d421a0424 Add Biotechnology and Biological Sciences Research Council to email domain list
> BBSRC is an executive non-departmental public body, sponsored by the
> Department for Business, Energy & Industrial Strategy.

– https://www.gov.uk/government/organisations/biotechnology-biological-sciences-research-council
2017-09-20 16:23:18 +01:00
Pete Herlihy
e9625cf54e Added West Midlands Fire Service 2017-09-07 16:46:32 +01:00
Chris Hill-Scott
e3d26bb2a2 Allow Science & Technology Facilities Council
> STFC is an executive non-departmental public body, sponsored by the
> Department for Business, Energy & Industrial Strategy.
> http://www.stfc.ac.uk/https://www.gov.uk/government/organisations/science-and-technology-facilities-council
2017-08-14 09:52:11 +01:00
Chris Hill-Scott
77452b1b25 Merge pull request #1418 from alphagov/local-email-address-for-local-government
Tell local government folk that they can sign up
2017-08-11 16:20:06 +01:00
Chris Hill-Scott
a10e76a9c2 Stop referring to central gov in error messages 2017-08-10 13:51:46 +01:00
Chris Hill-Scott
01d92fdbb3 Add British Library to email domain whitelist
I think that British Library can use Notify. Need to double check
though.

> BL is an executive non-departmental public body, sponsored by the
> Department for Digital, Culture, Media & Sport.
> https://www.bl.uk/https://www.gov.uk/government/organisations/british-library
2017-08-10 12:47:56 +01:00
Chris Hill-Scott
3d45454330 Add Care Quality Commission to email whitelist
CQC is an executive non-departmental public body, sponsored by the
Department of Health.

They have asked to be allowed to register for Notify using the
`cqc.org.uk` and `digital.cqc.org.uk` domains. We know that this really
is there domain because it’s linked to from here:

https://www.gov.uk/government/organisations/care-quality-commission
2017-06-05 13:51:53 +01:00
Rebecca Law
a1d004fa45 Add cjsm.net to whitelist 2017-05-26 10:40:48 +01:00
Chris Hill-Scott
ab150d876d Stop letting people enter empty SMS senders
This shouldn’t be deployed until we’ve migrated the database to default
to GOVUK.
2017-05-19 22:42:17 +01:00
Leo Hemsted
deb959e835 welsh assembly emails - foo@assembly.wales 2017-03-08 14:08:57 +00:00
Chris Hill-Scott
54a666e8e9 Add Scottish Enterprise to list of gov domains
> Scottish Enterprise is Scotland's main economic development agency
> and a non-departmental public body of the Scottish Government.

– https://www.scottish-enterprise.com/about-us

For some reason their email domain is `scotent.co.uk` (but it redirects
to www.scottish-enterprise.com on the web for the some reason
¯\_(ツ)_/¯)
2017-03-02 10:18:19 +00:00
Chris Hill-Scott
e909bce928 Make long SMS sender name error accurate
`<=11` not `< 11`
2017-02-27 15:56:58 +00:00
Leo Hemsted
f550699daf fix non-gsm error message
Use `it`/`they` depending on how many different characters you've used
Also don't wrap the message with quotes, as it looks confusing and
potentialy implies that you can't use apostrophes
2017-02-17 10:39:52 +00:00
Leo Hemsted
73a965a3c6 allow downgradeable unicode characters in SMS templates 2017-02-17 10:39:52 +00:00