Commit Graph

11940 Commits

Author SHA1 Message Date
Chris Hill-Scott
e457ccdf02 Merge pull request #4042 from alphagov/bump-werkzeug-v2.0.2
Bump Werkzeug to version 2.0.2
2021-10-13 12:10:43 +01:00
Chris Hill-Scott
c3bbc427e2 Check that user isn’t signed in before registering
Previously this test asserted on `current_user.is_authenticated`. That
isn’t possible now because the object imported into tests isn’t the same
one the app is using.

A different proxy for whether the user is signed in is whether they have
a user id in their session, because we set this every time they sign in:
ff32e73d9b/app/models/user.py (L162)
2021-10-13 11:31:27 +01:00
Chris Hill-Scott
c2d9a56ff4 Bump Werkzeug to version 2.0.2
This is the newest version.

Pyup is complaining about vulnerabilities in version 1.0.1, specifically
> Werkzeug version 2.0.2 improves the security of the debugger cookies.
> "SameSite" attribute is set to "Strict" instead of "None", and the
> secure flag is added when on HTTPS.

Previously we were using whatever version of Werkzeug that Flask
specified this pins it to get rid of the vulnerability without having to
upgrade everything at once.

This requires a few changes to tests which were relying on importing
`session` and `current_user` from Flask. Previously it seemed that
importing these in the tests referred to the same object that was being
used in the app. This appears to no longer be the case. This commit
works around that by:
- using a context manager to get the contents of the session, like we
  already do in most tests
- asserting that the mock which logs the user in is being called with
  the right values, rather than looking at the state of the
  `current_user` object (which was probably giving false certainty
  anyway)
2021-10-12 10:39:19 +01:00
Chris Hill-Scott
ff32e73d9b Merge pull request #4037 from alphagov/move-tour-end
Move end of tour route into `tour.py`
2021-10-07 10:51:19 +01:00
Chris Hill-Scott
1cc087b8de Move end of tour route into tour.py
In https://github.com/alphagov/notifications-admin/pull/3663/files we
made specific routes for sending the ‘tour’ text message, rather than
sharing the ‘one-off’ routes in `send.py`.

This commit moves the final route in the tour journey into `tour.py` as
well, which is where I expected to find it when I was looking for it
just now.
2021-10-06 13:57:03 +01:00
Tom Byers
1c68e4bb43 Merge pull request #4036 from alphagov/better-messages-alpha-how-to-pay
Update the How to pay page
2021-10-05 15:11:24 +01:00
karlchillmaid
2949f2b61c Remove contact us link 2021-10-05 12:55:06 +01:00
karlchillmaid
67b8c7166f Add introduction 2021-10-05 12:54:14 +01:00
karlchillmaid
8bed53e6d1 Merge pull request #4031 from alphagov/better-messages-alpha-sprint-2
Update introduction
2021-10-05 12:22:16 +01:00
Katie Smith
aeb3db583e Merge pull request #4035 from alphagov/no-webauthn-🤖s
Ensure only logged in users can see /webauthn/register
2021-10-05 11:47:47 +01:00
Katie Smith
5885110360 Ensure only logged in users can see /webauthn/register
There are no links to the `webauthn_begin_register` route - you are only
taken there if you are logged in and have clicked to register a key.
However, we have seen this route being crawled by bots making a GET
request which gives a `500` status code error because there isn't a
logged in current_user. For consistency, this also adds teh decorator to
the POST route.
2021-10-05 11:38:12 +01:00
karlchillmaid
825d4ecf96 Close <a> tag 2021-10-05 10:31:29 +01:00
Chris Hill-Scott
64c16cccb1 Merge pull request #4033 from alphagov/isort-no-rc
Remove deprecated command line flag to `isort`
2021-10-05 09:18:56 +01:00
Chris Hill-Scott
5c94aa004e Remove deprecated command line flag to isort
> Prior to version 5.0.0, isort wouldn't automatically traverse directories. The --recursive option was necessary to tell it to do so. In 5.0.0 directories are automatically traversed for all Python files, and as such this option is no longer necessary and should simply be removed.

— https://github.com/PyCQA/isort/blob/main/docs/upgrade_guides/5.0.0.md#--recursive-or--rc

***

We moved to version `> 5.0.0` of isort in March 2021: https://github.com/alphagov/notifications-admin/pull/3828/files
2021-10-04 14:58:29 +01:00
karlchillmaid
3cb7ecd90e Update introduction 2021-10-01 15:08:41 +01:00
Chris Hill-Scott
1fde4b99d9 Merge pull request #4013 from alphagov/webauthn-illustration-fixed-size
Give WebAuthn illustration a fixed size
2021-09-30 15:21:05 +01:00
Chris Hill-Scott
975088308a Put media query after default CSS
Specificity means that the media query will always override, but this is
more obvious with the order this way around.
2021-09-30 15:07:22 +01:00
Chris Hill-Scott
eee4cdd0a7 Rewrite media queries to be mobile-first
Also adds height: 100% which forces the SVG to scale, rather than just
setting width which widens the viewbox.
2021-09-30 14:19:27 +01:00
Chris Hill-Scott
c63313e839 Give WebAuthn illustration a fixed size
The browser uses the `width` and `height` attributes of the image tag to
allocate space on the page for the image.

If these aren’t provided then the browser will assume the image takes up
no space, until it’s downloaded it and had a look at what the file’s
dimensions are. This causes the layout of the page to jump once the
image downloads.

`149 × 150px` is the native size of the image. But we don’t want it to
display at that size, so this commit also adds some extra CSS which
keeps it looking the same, namely:
- the full width of the 1/4 page column on desktop
- the full width of the column minus a `40px` gutter either side on
  mobile (by using `box-sizing: border-box` the `40px` of padding is
  subtracted from the 100% width, rather than added to it)
2021-09-30 14:19:27 +01:00
Chris Hill-Scott
28f26e0056 Merge pull request #4029 from alphagov/copy-clipboard-key-value-styles
Fix styles for API key value not being applied
2021-09-30 11:09:22 +01:00
Katie Smith
aedffbc570 Merge pull request #4027 from alphagov/use-zendesk-form-everywhere
Use new Zendesk form everywhere
2021-09-29 10:51:47 +01:00
Katie Smith
a5723b64e3 Change mocks for the go live Zendesk tests
This updates the tests to use the same way of mocking the
`NotifySupportTicket` that we're now using in other tests.
2021-09-29 10:37:01 +01:00
Katie Smith
a54b3c9f77 Pass valid ticket type to Zendesk
The feedback endpoints use `ticket_type` to decide what to display and
whether or not a ticket should be escalated. We were using the
ticket_type as the value for the Zendesk ticket_type. However, the Zendesk
API accepts 4 values for its ticket_type and these are different from
the ticket_type values we use in our code.

This change converts the Notify ticket_type value to a valid Zendesk
ticket_type value when creating a Notify feedback ticket.
2021-09-29 10:37:01 +01:00
Katie Smith
437af32d82 Use Zendesk form for general enquiries 2021-09-29 10:30:32 +01:00
Katie Smith
e9948a0234 Use Zendesk form for branding requests
This changes the Zendesk tickets created when an email or letter
branding request is submitted to use the new Zendesk Form that was
introduced in https://github.com/alphagov/notifications-utils/pull/899
2021-09-29 10:30:32 +01:00
Chris Hill-Scott
bc5745c77b Fix styles for API key value not being applied
When the component was renamed from ‘API key’ to ‘Copy to clipboard’ the class for the thing to be copied changed from `api-key__key` to `copy-to-clipboard__value`. While the CSS was updated to reflect the change from `api-key` to `copy-to-clipboard` the change from `__key` to `__value` was not made.

Before: 4921e6d46e/app/templates/components/api-key.html
After: 85f6881a56/app/templates/components/copy-to-clipboard.html

This commit changes updates the CSS to reflect the latter change, so that the styles get applied properly.
2021-09-28 15:30:44 +01:00
Katie Smith
c76cd82a97 Merge pull request #4024 from alphagov/new-zendesk-form
Use Zendesk form for go live requests
2021-09-23 09:20:47 +01:00
Tom Byers
a06a1b1672 Merge pull request #4023 from alphagov/bump-npm-modules
Bump gulp & gulp-sass to latest versions
2021-09-22 14:23:20 +01:00
Tom Byers
37ae04f67e Make test comments explain use of require better
Based on comments on the pull request associated
with this work:

https://github.com/alphagov/notifications-admin/pull/4023#discussion_r711156154
2021-09-22 12:05:48 +01:00
Tom Byers
5115344927 Remove rebuild of node-sass from bootstrap
We now use `sass`, a JavaScript version of Sass,
compiled from dart-sass*, so shouldn't need to
rebuild it to solve issues with C libraries.

*https://github.com/sass/dart-sass
2021-09-22 12:05:48 +01:00
Tom Byers
c61698753f Remove version restrictions for NPM
We do need NPM to be run above those versions but
I'd rather enforce that here after I'm sure this
app will run on images that have a valid version.
2021-09-22 12:05:47 +01:00
Tom Byers
aeaa96124c Fix node version & lock down npm version
The intention behind the version of node in the
engines property was for that version to be the
minimum required so it was always missing the `>=`
prefix.

This adds that prefix and also adds a setting for
npm, to prevent use of insecure versions. See this
article for details:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/
2021-09-22 12:05:47 +01:00
Tom Byers
55287e944d Update updateContent tests to reflect its use
The way we're using the updateContent.js code is
slightly different to expected and to the
scenarios in our tests. This changes the
tests to match that use.

The expected behaviour was for updates to a
module's HTML to happen to the HTML inside of the
div[data-module=update-content] element.

So with initial HTML of:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    Existing content
  </div>
</div>

...should be updated to be:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    New content
  </div>
</div>

Instead the HTML returned by the AJAX requests
replaced the div[data-module=update-content]
element.

So with initial HTML of:

<div data-module="update-content" ..>
  <div class="ajax-block-container">
    Existing content
  </div>
</div>

...will be updated to be:

<div class="ajax-block-container">
  New content
</div>

This doesn't seem to create any noticable changes
to the visual interface so, I think, went
unnoticed. The assumption I am making, of this
being unintended, is based on the fact that the
div[data-module=update-content] element has an
aria-live attribute, which authors would normally
want to stay in the page when updates happen.

Note: This commit doesn't try and fix the problem,
as the behaviour still largely works and the lack
of aria-live actually seems to be a positive
thing, meaning non-visual users aren't told of
every update but can discover it themselves if
needed.
2021-09-22 12:05:47 +01:00
Tom Byers
87f54d1e88 Replace diffDOM library with domdiff
A while ago diffDOM moved its code to use ES6
modules and started using various language
features specific to ES6. These two things
happened independently btw.

The result of this is that the version of diffDOM
suitable for our build pipeline, structured as an
immediately invoked function evocation (IIFE),
now requires polyfills of some ES6 features to
work in the older browsers we support, like IE11.

It's also worth noting that in the move to ES6
the maintainers of diffDOM have adopted a process
whereby users who need to support older browsers
now have to add polyfill code for any ES6 features
they choose to use.

This commmit proposes a move to the domdiff
library instead because:
- it runs on all javascript runtimes with no
  polyfills
- it is 2KB instead of diffDOM's 25KB

Domdiff takes a different approach to diffDOM, in
that it compares existing nodes and new nodes and
replaces the existing ones with the new ones if
there are differences. By contrast, diffDOM will
make in-place changes to nodes if there are enough
similarities. In other words, in most situations,
diffDOM won't change the node in $component
whereas domdiff will.

Because of this, I've had to change the
updateContent.js code to cache the data-key
attribute's value so we don't lose access to it by
overwrite the $component variable with a different
jQuery selection.
2021-09-22 12:05:47 +01:00
Tom Byers
bec77a2c66 Bump gulp-sass
Intended to deal with this security vulnerability:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/

Bumping gulp-sass to version 5 removes its
dependency on the tar package mentioned in that
article.

Version 5 requires you to specify a compiler
directly in the gulpfile so that code is changed
in line with this guidance:

https://github.com/dlmanning/gulp-sass/tree/master#migrating-to-version-5

Note: node-sass is now deprecated so this also
changes the sass compiler gulp-sass uses to
dart-sass (aka 'sass'), the compiler now
recommended by the Sass project:

https://sass-lang.com/dart-sass

This also bumps gulp and all its plugin modules to
their latest versions, for parity.
2021-09-22 12:05:47 +01:00
Katie Smith
d41185db5f Delete unused template
`delete.html` hasn't been used since e89f89bd11
2021-09-22 12:00:05 +01:00
Katie Smith
39c26f5bfb Create go-live support tickets using the new way
The new way of creating support tickets can be seen in
[notifications-utils](https://github.com/alphagov/notifications-utils/pull/899).

This changes tickets created when making a request to go live to use
the new way, while other tickets stay the same for now.

The go live tags have been removed. Some of these had become
unneccessary since you can't make the request to go live unless they are
true (e.g. `notify_go_live_email_reply_to`). Others will always get
added by a Zendesk macro when the ticket is replied to, so we don't need
to add them here.
2021-09-22 12:00:05 +01:00
Katie Smith
a8deec1b9f Bump utils to 46.1.0 2021-09-22 12:00:05 +01:00
Ben Thorner
a02596c481 Merge pull request #4025 from alphagov/fix-showing-radios-on-error
Fix showing service type radios on error
2021-09-17 15:20:31 +01:00
Ben Thorner
41f44c51fe Fix showing service type radios on error
The radio buttons to select the type of service - central, etc. -
are only shown if we can't infer the type based on the user's email
/ default organisation. However, the code to render the page in the
error case didn't accommodate this, nor did it show the version of
the page for adding a local government service.

This fixes the bug by DRYing-up the logic to render the pages. I've
not added a test for this for a couple of reasons:

- It's not a critical bug: no one has complained about it and it
doesn't block the user from adding service.

- It's unlikely to reoccur because the bug involved writing _more_
code than was necessary.

- It's not trivial to test this due to the 3 versions of the page
involved - these are tested for the happy path.
2021-09-16 12:07:03 +01:00
Leo Hemsted
6ef39e2ebf Merge pull request #4022 from alphagov/contact-list-bst
fix contact list bst bug
2021-09-15 16:48:42 +01:00
Leo Hemsted
2494d6ce31 move contact list json to a constructor
reduces some duplication
2021-09-15 15:57:49 +01:00
Leo Hemsted
9e915703fd fix contact list bst bug
the api returns UTC timestamps, we should keep them as UTC timestamps
until the very last moment, and only convert them into BST when we know
we want to return to a user (ie: in contact-list.html and other places
like that)
2021-09-15 15:12:13 +01:00
Leo Hemsted
96b91f9e1a Merge pull request #3973 from alphagov/error-handling-js-178466639
show error banner rather than alert when registering an invalid key
2021-09-15 13:57:59 +01:00
Leo Hemsted
a96bfdb16e remove server-side error messages for webauthn
since we are hard-coding a generic error message on the front-end, we
have no need to do anything on the back end. This is also nice as it
standardises the two flows to behave more like each other (rather than
previously where one would `flash` an error message and the other would
return CBOR for the js to decode).

Note that the register flow returns 400 while the auth flow returns 403.
The js for both just checks `response.ok` so will handle both. The JS
completely discards any body returned if the status isn't 200 now.
2021-09-15 11:43:41 +01:00
Leo Hemsted
2c55f4d0ce hard-code html error message for errorBanner
turns out that we're only using errorBanner with a static message, and
it's also full of rich html content. This means that it's probably
better to put it in the html templates with other content, rather than
hidden away in js files if we can help it.

Since there are two places, had to dupe the error message but i think
that's fine as i don't anticipate this error message being used in
significantly more places.

making it a string is a bit gross and means we don't get nice syntax
highlighting on it, but as it needs to be passed in to a jinja macro
that's the way it has to go unfortunately.
2021-09-14 18:43:27 +01:00
Leo Hemsted
b7e50fc638 redirect non logged in users
previously it'd show an error because non logged in users don't have the
can_use_webauthn attribute. now we can just bounce them to the sign-in
page
2021-09-14 18:43:26 +01:00
Leo Hemsted
0b27d7e0a9 show error message in banner rather than an alert
the banner is a nicer user experience, and consistent with how we
display errors elsewhere in notify. For now pass through the error
message from JS, but we'll probably want to change that since the erorr
messages themselves are often a bit cryptic and unhelpful
2021-09-14 18:43:26 +01:00
Leo Hemsted
c96a1dc0b7 add new error banner module for showing users js errors
this ensures it's reusable by other components, and easier to unit test
by isolating the separate concerns

note: this is not in Modules since that's designed for classes that are
then bound to an element in the DOM as indicated by a data-module
attribute. This will just live at the window.GOVUK level since we want
there to only ever be one `.banner-dangerous` warning.
2021-09-14 18:43:25 +01:00
Pea Tyczynska
c42fc071b5 Merge pull request #4020 from alphagov/update-service-name-hint-text
Add additional instructions for the service name
2021-09-14 12:18:46 +01:00