Commit Graph

51 Commits

Author SHA1 Message Date
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Jonathan Bobel
e0d2d74067 Update dashboard and template flow (#514)
* Updated header and footer
* Moved files around and updated gulpfile to correct the build process when it goes to production
* Updated fonts
* Adjusted grid templating
* Adding images to assets
* Updated account pages, dashboard, and pages in message sending flow
* Updated the styling for the landing pages in the account section once logged in
2023-06-08 13:12:00 -04:00
Ryan Ahearn
2ad21a6f4f Replace UK phone numbers in tests with US numbers 2023-01-06 11:19:56 -05:00
Chris Hill-Scott
8b7f2fbf04 Stop using _external=True in tests
It looks like, by default, Flask no longer makes full URLs, for example
`https://example.com/path`. Instead it does `/path`. This will still
work fine, and if anything is better because it reduces the number of
bytes of HTML we are sending.

It won’t mean that requests go over `http` instead of `https` without
the protocol because we set the appropriate HSTS header here:
0c57da7781/ansible/roles/paas-proxy/templates/admin.conf.j2 (L11)

This commit changes all our tests to reflect that URLs no longer have
the protocol and domain in them. `_external=True` is Flask’s way of
saying whether a URL should be generated with the domain and protocol
(`True`) or without it (`False`).

Again, I can’t find the changelog or diff where this was introuduced,
but if you’d like to go spelunking then here’s a starting point:
50374e3cfe/src/flask/helpers.py (L192)
2022-06-06 12:12:52 +01:00
Chris Hill-Scott
7e707db4b2 Replace uses of client.get and client.post
We have a `client_request` fixture which does a bunch of useful stuff
like:
- checking the status code of the response
- returning a `BeautifulSoup` object

Lots of our tests still use an older fixture called `client`. This is
not as good because it:
- returns a raw `Response` object
- doesn’t do the additional checks
- means our tests contain a lot of repetetive boilerplate like `page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')`

This commit converts all the tests which had a `client.get(…)` or
`client.post(…)` statement to use their equivalents on `client_request`
instead.

Subsequent commits will remove uses of `client` in other tests, but
doing it this way means the work can be broken up into more manageable
chunks.
2022-01-10 14:39:45 +00:00
Leo Hemsted
c203f624ca rename two_factor to two_factor_sms
it's a bit confusing now that there are three endpoints. the other two
are already renamed two_factor_email and two_factor_webauthn
2021-06-01 19:08:57 +01:00
Pea Tyczynska
6578719103 Test next redirects with realistic URL
This change has been made following PR review, to ensure
that special signs are transformed correctly when passing
through the next URL.
2020-10-12 12:01:39 +01:00
Pea Tyczynska
b0db60e417 Turn on redirects for email_not_received
This is part of the work to make sure user is redirected
to the page they initially were meant to visit after
they sign in.
2020-10-09 11:52:19 +01:00
Pea Tyczynska
1dd8b08042 Turn on redirects for check_and_resend_verification_code
This is part of the work to make sure user is redirected
to the page they initially were meant to visit after
they sign in.
2020-10-09 11:51:15 +01:00
Pea Tyczynska
c3b7481e11 Turn on redirects for check_and_resend_text_code
This is part of the work to make sure user is redirected
to the page they initially were meant to visit after
they sign in.
2020-10-09 11:49:48 +01:00
Tom Byers
28140104f1 Fix python tests broken by cookie banner 2020-01-20 10:03:19 +00:00
Leo Hemsted
66db735e09 Revert "Merge pull request #3238 from alphagov/cookies-update"
This reverts commit eec4bec761, reversing
changes made to 64480e2fff.
2020-01-15 14:40:48 +00:00
Tom Byers
beeb273d6c Fix python tests broken by cookie banner 2020-01-03 17:28:33 +00:00
Chris Hill-Scott
628e344b36 Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
                         API (returns JSON)
                                  ⬇
          API client (returns a built in type, usually `dict`)
                                  ⬇
          Model (returns an instance, eg of type `Service`)
                                  ⬇
                         View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:

```
                         API (returns JSON)
                                  ⬇
    API client (returns a model, of type `User`, `InvitedUser`, etc)
                                  ⬇
                         View (returns HTML)
```

This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.

It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.

For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-06-05 11:13:41 +01: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
Leo Hemsted
cbf1b3ec38 replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled
fine by update_user_attribute. Reduce complexity in the API by killing
the PUT, which is more dangerous (might silently overwrite things that
shouldn't be, like "last_logged_in_at" etc).

Had to change the code not received mobile number form, and the
activate user function.
2017-11-09 14:58:33 +00:00
Leo Hemsted
bfa6980913 Revert "replace user PUT with POSTs" 2017-11-09 14:57:01 +00:00
Leo Hemsted
302a024d3b replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled
fine by update_user_attribute. Reduce complexity in the API by killing
the PUT, which is more dangerous (might silently overwrite things that
shouldn't be, like "last_logged_in_at" etc).

Had to change the code not received mobile number form, and the
activate user function.
2017-11-09 12:30:12 +00:00
Chris Hill-Scott
188ce5e5a7 Let users register with int’national phone numbers
Right now Notify restricts you to registering with a UK mobile number.
This is because when we built the user registration stuff we couldn’t
send to international mobiles.

However we can send to international mobile numbers, and it’s totally
reasonable to expect employees of the UK government to be working
abroad, and have a foreign mobile phone – we’ve heard from one such
user.

So this commit:
- changes all places where users enter their own phone number to use
  the validation function which allows international phone numbers
- renames the `mobile_number` validation to `uk_mobile_number` to make
  it explicit, and force it to break the tests if there’s somewhere it’s
  being used that I haven’t thought of
2017-08-29 14:52:24 +01:00
Chris Hill-Scott
f3b0c0a556 Use client and logged_in_client fixtures
Wherever possible, because Don’t Repeat Yourself.
2017-02-06 10:44:38 +00:00
Chris Hill-Scott
929dc45224 Normalize whitespace in test arguments
We have a bunch of different styles of handling when function
definitions span multiple lines, which they almost always do with tests.

Here’s why an argument per line, single indent is best:
- cleaner diffs when you change the name of a method (one line change
  instead of multiple lines)
- works better on narrow screens, eg Github’s diff view, or with two
  terminals side by side on a laptop screen
- works with any editor’s indenting shortcuts, no need for an IDE

Also, trailing comma in the list of arguments is good because adding a
new argument to a method becomes a one line, not two line diff.
2017-02-06 10:44:37 +00:00
Chris Hill-Scott
9865c2916f Reword resend email page
Changes the wording to match: 166870c536/app/templates/views/registration-continue.html (L10)

We don’t use ‘we‘.

The ‘in order to‘ bit is unnecessarily verbose.
2016-09-06 16:59:26 +01:00
Martyn Inglis
5666719a92 Merge branch 'master' into more_wording_changes
Conflicts:
	app/templates/views/verify-mobile.html
2016-08-22 12:54:10 +01:00
Martyn Inglis
380a6526c4 Changed some more instances of "confirmation" code to "security" code 2016-08-22 12:52:05 +01:00
Chris Hill-Scott
aa166856b4 Change 'verification code' to 'security code'
Extensive testing on Verify has shown that this is understood better.
2016-08-22 11:46:07 +01:00
Leo Hemsted
539950d772 when not logged in, redirect to sign-in
parts of the initial setup/login stages were throwing 500s if user
not already in process (ie: user directly navigated to url):
* /resend-email-verification
* /text-not-received
* /send-new-code
* verify
2016-06-17 13:53:48 +01:00
Adam Shimali
56c3401a39 Requesting a resend of verify code for a user that has not completed
registration will allow user to check and modify mobile number.

Registered (active) users will only be able to request resend to their
existing registered number.
2016-06-13 16:31:54 +01:00
Adam Shimali
b775b60633 In registration flow then request resend of sms should
redirect to verify not two-factor.
2016-03-21 14:00:05 +00:00
Adam Shimali
792b42017a Revert "In registration flow If new sms requested then check and send redirected to two factor" 2016-03-21 13:44:53 +00:00
Adam Shimali
c2c98248a1 If new sms requested, then check and send redirected to two factor
in all cases but should have redirected to verify for pending users.
2016-03-21 12:32:07 +00:00
Martyn Inglis
b8db00d4d9 Fixing tests broken by bad revert 2016-03-18 11:46:17 +00:00
Adam Shimali
a1203d75ea Unit test bug fix. Page structure change. 2016-03-18 11:20:08 +00:00
Adam Shimali
2792bece54 Changed registration flow to first send email verification link that
when visited sends sms code for second step of account verification.

At that second step user enters just sms code sent to users mobile
number.

Also moved dao calls that simply proxied calls to client to calling
client directly.

There is still a place where a user will be a sent a code for
verification to their email namely if they update email address.
2016-03-17 15:19:51 +00:00
Nicholas Staples
2d35f5f36a All tests passing and merged with master. 2016-01-27 16:30:33 +00:00
Nicholas Staples
6959d695d3 Working tests, hopefully all code changes done. 2016-01-27 12:22:32 +00:00
Adam Shimali
4674bd6b68 Reintroduce some tests. A bit of cleanup of mocks.
User object fields made a bit clearer and simple test to
verify user added.
2016-01-23 23:14:50 +00:00
Adam Shimali
856b6adb56 First slice full sign in flow 2016-01-21 11:33:53 +00:00
Adam Shimali
fcedae5fe1 Merge conflicts and test fixes 2016-01-20 15:40:06 +00:00
Adam Shimali
ca3d3240a6 Verify activate and login user with sms and email code 2016-01-20 15:34:42 +00:00
Nicholas Staples
75d7110642 Updated to send email through the client send_email. 2016-01-20 14:45:50 +00:00
Nicholas Staples
4e2019c949 Work in progress, all tests passing and implemented mocks for services_dao. 2016-01-15 17:46:09 +00:00
Nicholas Staples
3b1d521c10 Tests added for dao. 2016-01-15 15:15:35 +00:00
Nicholas Staples
d42ee85f93 Added new notification-python-client removed check on old one, fixed tests, live service will be broken. 2016-01-14 14:55:07 +00:00
Chris Hill-Scott
aa43bd9e75 Add the new field to the application
This commit replaces the previous `StringField` used for collecting mobile
phone numbers with the `UKMobileNumber` field.

This means changing a few of the preexisting tests to have more realistic mobile
numbers so that they still pass.
2016-01-13 09:43:32 +00:00
Nicholas Staples
7001d8261d Fix for security hole with setting session['user_id'] before second factor of authentication has been authorised. 2016-01-07 12:43:10 +00:00
Nicholas Staples
0ebacd6929 Refactor for code_not_received, sign_in, two_factor and verify. 2016-01-05 17:08:50 +00:00
Rebecca Law
b2f544a165 110880218: Completed implementation of resend the verificaton code 2015-12-31 13:16:59 +00:00
Rebecca Law
fb5e80e0d4 110880218: Implementation to resend the verification code.
Added implementation for GET/POST for the /verification-not-received endpoint.
2015-12-31 11:13:42 +00:00
Rebecca Law
64812c1614 109898688: All codes are valid until one code is used, then they are all marked used.
Fixed the is_active() method on the Users model, if the user was pending they would come back as active, allowing a user to sign in before being active.
There is still a problem with the validate_sms_code and validate_email_code method.
2015-12-17 14:33:20 +00:00
Rebecca Law
bd8bb3c926 109898688: Implementation of text-not-received and email-not-received 2015-12-17 14:33:20 +00:00