Commit Graph

29 Commits

Author SHA1 Message Date
Kenneth Kehl
b777249b6f merge from main 2024-03-01 13:50:09 -08:00
Cliff Hill
8c6046b03b Cleaning up tests.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Kenneth Kehl
6dc9828663 fix tests 2024-01-22 10:55:09 -08:00
Kenneth Kehl
f9f1013f5b notify-api-742 don't write phone numbers to db 2024-01-16 11:21:24 -08:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Ryan Ahearn
82df01653f Update tests to focus on US numbers 2023-01-05 11:06:12 -05:00
Katie Smith
187e87c792 Remove one of our own jsonschema date-time formatters
We have three different ways of checking the formats of datetimes.
1. The built-in way that comes with the jsonschema package ("date-time")
2. A new way we added for broadcasts ("datetime") 61a5730596
3. An old way we defined in
   "/tests/app/public_contracts/schemas/v0/definitions.json"

In order to simplify things and make it clearer how datetimes are being
validated, this replaces the few places where we were using option 3 with option 1
instead. Option 3 was only being used to validate code that is no longer
used, the initial version of the API.
2022-04-14 14:47:45 +01:00
Katie Smith
b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00
Ben Thorner
0312e2a528 Split generating authorization headers by type
In response to [1].

[1]: https://github.com/alphagov/notifications-api/pull/3300#discussion_r681653248
2021-08-04 15:13:52 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Rebecca Law
3a66027d6a Refactor ApiKeys.secret and ServiceInboundApi.bearer_token to use the same encryption method and get rid of the duplicate code. 2017-06-19 14:32:22 +01:00
Martyn Inglis
5cd0507e99 Revert "Fixed faoiling jenkins tests. Mocked the required functions"
This reverts commit 4b60c8dada.
2017-03-30 10:46:15 +01:00
Martyn Inglis
4b60c8dada Fixed faoiling jenkins tests. Mocked the required functions 2017-03-23 15:05:56 +00:00
Paul Craig
ffb813bb3f Add get_notifications json schema + tests
Add a schema that corresponds to our response for returning lists
of notifications, and test with a contract test.
2016-11-25 16:50:20 +00:00
Paul Craig
ebfac180c0 Add contract test for 'v2' email notification
We don't have a way of creating letter notifications just yet, so
this is all we can test.
2016-11-22 13:40:55 +00:00
Paul Craig
7ae427c4ef Use jsonschema validation + remove 'v2' schema
Emualated the validation methods that exist [in the python-client](620e5f7014/integration_test/__init__.py).

The `validate_v0` function loads json schemas from a local
`/schemas` directory, whereas the new `validate` function (which
we're going to use for our v2 API calls) uses the common
`get_notification_response` python schema defined in
"app/v2/notifications/notification_schemas.py".

Removed the new `v2` schema from the last commit as it's no longer
being used.

Also, refactored common code in the GET and POST contract files
so that making requests and converting responses to JSON are
pulled out into common functions.
2016-11-22 13:40:22 +00:00
Paul Craig
fb50bb6325 Add 'v2' notification schema to contract tests
Converted python-based schema in
"app/v2/notifications/notification_schema.py" into a pure json
schema and tested it with the new "v2/" API route to confirm that
it validates.

Also refactored some common code in the public contract GET tests
that returns notifications.
2016-11-22 12:07:05 +00:00
Martyn Inglis
20ccdab3bd Contract tests mock the new deliver_email|sms tasks 2016-09-28 15:28:45 +01:00
Imdad Ahad
23998a4d55 Add additionalProperties to links object 2016-09-21 09:47:50 +01:00
Imdad Ahad
afd381badf Update links schema to be more strict and fix import 2016-09-20 10:39:15 +01:00
Imdad Ahad
5b0162cc60 Update schema to validate {notifications} contains a {links} object with expected properties 2016-09-16 14:56:14 +01:00
Martyn Inglis
e0d46d821d Merge branch 'master' into delete-csv-file-after-7-days
Conflicts:
	app/notifications/rest.py
2016-09-12 16:33:01 +01:00
Imdad Ahad
41681ac001 Fix mocker syntax issue 2016-09-07 11:17:27 +01:00
Leo Hemsted
7240df0641 replace mock with unittest.mock 2016-08-31 12:39:11 +01:00
Leo Hemsted
c91358673f add POST response tests
assert that the response for emails and sms is formatted as expected

also moved schemas into subdirectory to make folder more legible
2016-08-31 12:33:45 +01:00
Leo Hemsted
fabbb8b01b separate tests for api and job notifications 2016-08-31 11:53:54 +01:00
Leo Hemsted
cb0491cbff add test for GET /notification
simple schema with oneOf [email, sms].
also fixed error where ref'd schemas weren't being picked up
2016-08-30 19:07:46 +01:00
Leo Hemsted
1b7b4a2ccb separate definitions into separate files to allow reuse
see https://github.com/Julian/jsonschema/issues/98

took boring generic things (eg uuid) into definitions.json, and also
separated email and sms notification objects into respective files
2016-08-30 18:45:54 +01:00
Leo Hemsted
aebaea1072 add public contract tests
use jsonschema to test the GET /notification/{} endpoint to highlight any key name/format/type changes
2016-08-30 15:55:52 +01:00