Commit Graph

701 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
Carlo Costino
d79e15c2a1 Clean up state of E2E tests
This changeset takes care of leaving E2E tests in a clean state so that
we can revisit the work later.  The efforts to add authentication
support did not pan out, so we will go a different route in the near
future.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-08-24 15:31:21 -04:00
Carlo Costino
9e609efa1c Remove webauthn hooks
This changeset removes webauthn from the Notify.gov admin app.  We are not using webauthn at all in our implementation and will be looking at an entirely different authentication system in the near future.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-08-14 16:59:38 -04:00
Carlo Costino
b5664c3d20 Add support for E2E (end-to-end) tests (#625)
This changeset lays the foundation for supporting E2E (end-to-end) integration tests for US Notify.  It brings in the Playwright testing framework along with the Playwright pytest plugin to make this possible, and includes the following adjustments:

- A new test session fixture for ensuring that Playwright authenticates with the sites that are currently behind HTTP Auth (requies env-var config)
- A new end_to_end test directory specifically for E2E tests
- Updates to the Makefile that make sure E2E tests are not run as a part of the normal test routine but can be run separately
- A new command in the Makefile to run E2E tests that will run in Chromium, Firefox, and Webkit headless browsers

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-07-28 09:31:45 -04:00
Steven Reilly
13d0e46b52 blunt rename of org (#620) 2023-07-12 12:09:44 -04:00
Jonathan Bobel
f342e0fb6c Updating site to use USWDS styles (#509)
* Updated header and footer
* Updated fonts
* Moved files around and updated gulpfile to correct the build process when it goes to production
* Adjusted grid templating
* Added images to assets
* Update app/templates/components/uk_components/footer/template.njk

Co-authored-by: Steven Reilly <stvnrlly@users.noreply.github.com>
2023-06-06 15:28:24 -04:00
Ryan Ahearn
a42617f776 Add logging around auth{entication,orization} calls 2023-04-26 11:25:24 -04:00
Ryan Ahearn
de668d7aba Remove contact-list references from code 2023-04-12 15:35:14 -04:00
Ryan Ahearn
2ad21a6f4f Replace UK phone numbers in tests with US numbers 2023-01-06 11:19:56 -05:00
stvnrlly
cc4f8916b3 remove letter template preview 2022-12-05 16:40:59 -05:00
stvnrlly
36e0e67afc remove pdf stuff 2022-12-05 16:22:19 -05:00
stvnrlly
944715ac46 big commit with letters removal 2022-12-05 15:33:44 -05:00
stvnrlly
a8b8d09fb7 post-gray test updates 2022-12-02 10:30:37 -05:00
stvnrlly
a2b58c926e more test fixes & letter trimming 2022-11-22 22:50:47 -05:00
stvnrlly
ca1897973a test time fixes and bonus letter removal 2022-11-22 17:03:42 -05:00
stvnrlly
f16b5dd1c4 remove broadcast-related code 2022-10-04 03:04:13 +00:00
Ryan Ahearn
5f1a1f083a Proactively specify aws region for s3 operations 2022-09-26 10:25:03 -04:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
Ben Thorner
1b96a13565 Add xfail tests for go-live reply-to/sender check
This represents a bug where a user can request to go live without
setting a reply-to email address or SMS sender despite the service
having one or more email or SMS templates, respectively.

We will make these tests pass in the next commit.
2022-05-27 12:46:36 +01:00
Ben Thorner
4abb6110c8 Fix keys used to render monthly usage
These were out-of-sync with the API.
2022-05-11 13:28:33 +01:00
Ben Thorner
bb0fb73bc8 Minor tweaks in response to PR comments
In response to [^1] and [^2].

[^1]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869181152
[^2]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869186063
2022-05-10 17:00:51 +01:00
Ben Thorner
3449ccd923 Support multiple SMS rates per month on usage page 2022-05-03 16:01:13 +01:00
Ben Thorner
fb7c116046 Finish migration from billing_units to API fields
This is now only used for letters and represents the number sent
[^1].  We could use the chargeable_units field, but using "_sent"
is more consistent with the annual attributes [^2].

In fact, chargeable_units isn't actually used anywhere, but I've
kept it in the test data as it is part of the real API and helps
clarify the other values for SMS - free vs. charged.

Note: for SMS I've used an arbitrary "1234" for "chargeable_units"
to indicate it's not used and may be different to the number sent -
for SMS it's related to the number of fragments.

[^1]: bb62d22f25/app/dao/fact_billing_dao.py (L339)
[^2]: 3a1ac189ff/app/main/views/dashboard.py (L339)
2022-05-03 16:01:08 +01:00
Ben Thorner
c0ee24ff19 Migrate letter cost calculation to use API field
The values in the tests are calculated manually from other fields
in the mocked API response.
2022-05-03 16:01:07 +01:00
Ben Thorner
d798a0d60f Replace manual SMS monthly calculations with API
This starts using the sms_{cost, charged, free_allowance_used}
fields in the new API to replace the "get_free_paid_breakdown"
function we had before, which could not support multiple rates.

In order to use "get_free_paid_breakdown" the calling method had
to store a "cumulative" variable to calculate the free allowance
used so far, which is now done by the API.

To calculate the data for conftest.py, I had to start from the
bottom ("April") and manually calculate the free allowance used
to emulate the API - this is what "cumulative" used to do.
2022-05-03 16:01:06 +01:00
Ben Thorner
ce8bdea9be Fix inaccurate test data for monthly usage API
It has never been possible to get multiple rows for the same month
and rate. This was making it hard to switch to the new API fields,
which will require some manual calculations. I've added the billing
units together in the remaining data so the tests still pass.

I've also moved the "April" row to the end as it was out-of-order
with all the others: it's the _start_ of the financial year.
2022-05-03 16:01:03 +01:00
Ben Thorner
4ab7e3ceec Rename billing API methods to be recognisable
I struggled to distinguish which was which as neither mentioned if
the data they returned was monthly or annual.
2022-05-03 16:00:57 +01:00
Ben Thorner
e6c04ef556 Support variable rates for annual usage stats
Note: I've removed the pricing assertion in the "0_free_allowance"
test as it's covered elsewhere - the value of the test is really to
check that we don't show the remainder if there never was any.
2022-04-27 17:06:17 +01:00
Ben Thorner
e0aa51c306 Use new "cost" field in usage APIs
The previous, manual calculation could be incorrect depending on
which SMS rates the free allowance was attributed to.

The new field also supersedes the old "letter_total" bolt-on so we
can get cost information consistently for both types.
2022-04-27 17:06:12 +01:00
Ben Thorner
82c3e8093d Remove redundant SMS test data for annual usage 2022-04-27 16:58:18 +01:00
Ben Thorner
c6f5467009 Extend main test for service usage page
This adds missing assertions for email and SMS usage, as well as
letters with the help of some additional test data.

Previously we were only checking monthly usage (in other tests).
2022-04-27 16:57:06 +01:00
Ben Thorner
55ea5d90c7 Migrate away from ambiguous "billing_units"
This uses two new fields in the annual usage API instead of the
old one, which was actually a mix of two kinds of data [^1].

[^1]: fc378fed96
2022-04-27 16:32:52 +01:00
Ben Thorner
a02e1adbc5 Tweak usage dashboard test to cover rate changes 2022-04-26 14:02:54 +01:00
Ben Thorner
411abb136a Make broadcast user fixtures realistic
A broadcast service user will have the permission on creation [^1].

[^1]: b145a29935/app/dao/broadcast_service_dao.py (L69)
2022-03-24 12:26:06 +00:00
Chris Hill-Scott
b998b6bb20 Remove methods for checking service/org name uniqueness
We don’t use these now – instead we try to update the name and see if
it works or not.
2022-01-13 10:16:07 +00:00
Chris Hill-Scott
0ad106f572 Mark client fixture as ‘private’
No tests are now using the `client` fixture directly so we can rename
it.

Python convention is to use an `_underscore` for things which should be
considered semi private.

This should discourage people from writing new tests with these old
fixtures.

New tests should always use `client_request`.

Want to be logged in with a different user? Call
`client_request.login(user)` first.

Don’t want to be logged in? Call `client_request.logout()` first (most
of our tests need to be logged in).

Need an instance of `Response` object not an instance of
`BeautifulSoup`? Use `client_request.get_response` or
`client_request.post_response`.

Need to pass in a URL, not arguments to `url_for`? Use
`client_request.get_url(…)` or `client_request.post_url(…)`.

Need to pass in a URL and get a response back? Use
`client_request.get_response_from_url(…)` or
`client_request.post_response_from_url(…)`.
2022-01-10 14:39:46 +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
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
Chris Hill-Scott
8b93a977a0 Remove temporary raw_response argument
We added a new argument to `client_request.get` and
`client_request.post` to specify that it should return a raw `Response`
object rather than an instance of `BeautifulSoup`.

This is useful because sometimes we need to look at stuff like the
response headers.

However it turns out we already have a separate method for this, so
rather than invent something new I think it’s better to stick with the
thing we already have.
2022-01-10 14:39:45 +00:00
Chris Hill-Scott
c37258fd0d Stop using logged_in_client_with_session fixture
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

A few of our tests still use an older fixture called
`logged_in_client_with_session`. It’s not clear how this is different
from `logged_in_client`, which we have replaced with `client_request`.

So this commit goes ahead and converts all the tests using
`logged_in_client_with_session` to use `client_request` instead.
2022-01-10 14:39:45 +00:00
Chris Hill-Scott
0706664be4 Stop using logged_in_client fixture
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 `logged_in_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 using `logged_in_client` to:
use `client_request` instead.
2022-01-10 14:39:44 +00:00
Chris Hill-Scott
50eae6f935 Stop using platform_admin_client fixture
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

For most tests of a platform admin view we used `platform_admin_client`
instead. This is not as good because it returns a raw `Response` object
and doesn’t do the additional checks.

This commit converts all the tests using `platform_admin_client` to:
use new `client_request` and log in as `platform_admin_user` before
making any requests.

This is also nice because it makes any test easy to parametrize with
additional users, for example to test differences in behaviour dependant
on being platform admin or not.
2022-01-10 14:39:40 +00:00
Chris Hill-Scott
474d7dfda8 Format phone numbers with spaces in download of received text messages
Some users have reported a problem with the received text message
report:

> I have tested the reply service but in the excel report the mobile
> number is showing as 4.47900E+23. How can I change the format so that
> it is show the mobile number that has replied?

This is happening because Excel is interpreting a phone number in the
format `447900900123` as a number in
[scientific notation](https://en.wikipedia.org/wiki/Scientific_notation),
in other words 4.479 &times; 10<sup>23</sup>.

`447900900123` is the format that our provider is giving us the number
in – there’s no guarantee it will always be in this format.

We can prevent this behaviour by putting spaces in the numbers. Excel
and Google Sheets won’t try to convert a string with spaces into a
number.

I think we used to do this for the sent text messages report but
probably stopped because we decided it was better to keep the phone
number in the same format as it had been supplied to us for
reconcilliation purposes.
2022-01-06 16:41:41 +00:00
Chris Hill-Scott
029682d561 Rename model to AllOrganisations
This makes it clearer that this model collection isn’t the organisations
for a user or a service or some other entity, like most model
collections are.

It will also lets us make a separate Organisations model, without the
name conflicting.
2021-11-09 15:05:42 +00: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
Chris Hill-Scott
5c1920fc20 Remove old method of updating email_access_validated_at
Previously we were passing a flag to the API which handled this. Now
we are doing it at the time of clicking the link, not at the time of
storing the new password. We don’t need to update the timestamp twice,
so this commit removes the code which tells the API to do it.
2021-08-19 11:14:47 +01:00
Katie Smith
761af69a00 Remove active_user_broadcast_permissions fixture
This wasn't adding anything now that we have two new and more specific
fixtures, `active_user_create_broadcasts_permission` and
`active_user_approve_broadcasts_permission`, that can be used instead.

`manage_templates` has now been removed from the `create_broadcasts`
permission, so this also adjusts the fixture for a user who can create
broadcasts.
2021-07-26 13:58:39 +01:00
Katie Smith
8b08661902 Remove check for send_messages permission from broadcast pages
The `send_messages` permission has been deprecated for use with
broadcast services, so we can drop support for it in the code. We
were supporting both the old permissions and new permissions
(`create_broadcasts` and `approve_broadcasts`) while we switched people
over.

This removes `send_messages` from the `user_has_permissions` decorator
around the broadcast routes and from the page to view a broadcast and
broadcast dashboards. We can now git rid of a lot of the parameterization
that was temporarily added to the tests.
2021-07-26 10:58:16 +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