-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance UX and add features to the Callback pages #1855
Conversation
- Added the [validators](https://yozachar.github.io/pyvalidators/stable/) lib to the project - Callback URLs are now checked for validity - Callback URLs are now tested to determine if they are reachable before saving the callback url - Validate that callback urls return 200 responses
🧪 Review environmenthttps://7vmedldf7xzv7o4lt64mbxyvzq0gusde.lambda-url.ca-central-1.on.aws/ |
- Update error messages - Add logic for catching 5xx and 4xx errors and raise the correct validation error + logging - Fixed ServiceReceiveCallbackMessagesForm validation
("http://not_https.com", "1234567890", "Must be a valid https URL"), | ||
("https://test.com", "123456789", "Must be at least 10 characters"), | ||
("https://example.com", "", None, "This cannot be empty"), | ||
("http://not_https.com", "1234567890", None, "Enter a URL that starts with https://"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on testing these validation messages in Cypress, and instead test that we're logging appropriately here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah its a good question. We could definitely test the error messages in Cypress, although you do already have it done here. I think if we were building up this feature from scratch we would probably have created a cypress test suite, but where we are just tacking something on, maybe this is fine?
I like the idea of testing the logging, especially if those logs' formats are tied to other parts of the system like alarms. Testing logging is pretty easy, I had to do it for system status here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this looks great overall, just the question on if we can actually enforce a particular response at setup time without advising the clients of this in advance.
validate_callback_url(field.data, form.bearer_token.data) | ||
|
||
|
||
def validate_callback_url(service_callback_url, bearer_token): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in slack, this might be an issue since here it expects the callback servers to respond with a 200 when we call them with {"health_check": "true"}
. If we want to do this we would probably have to advertise this in the docs so users are aware.
("http://not_https.com", "1234567890", "Must be a valid https URL"), | ||
("https://test.com", "123456789", "Must be at least 10 characters"), | ||
("https://example.com", "", None, "This cannot be empty"), | ||
("http://not_https.com", "1234567890", None, "Enter a URL that starts with https://"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah its a good question. We could definitely test the error messages in Cypress, although you do already have it done here. I think if we were building up this feature from scratch we would probably have created a cypress test suite, but where we are just tacking something on, maybe this is fine?
I like the idea of testing the logging, especially if those logs' formats are tied to other parts of the system like alarms. Testing logging is pretty easy, I had to do it for system status here.
🧪 Review environmenthttps://h446q5dcbyez4g5lyixah4gn5i0lshdx.lambda-url.ca-central-1.on.aws/ |
- We only want to verify that there's a service running at the specified callback URL. - Additionally we are sending a payload the service won't understand how to response to so a 5xx is likely
- There is now a dedicated delete button to remove a callback configuration instead of needing to empty the form and click save to delete a config - Users will receive a confirmation banner before deletion occurs - Saving, creating, and deleting a callback url now provide the user with a confirmation message that the operation succeeded
- Added a button to the callback config page so users can see the response times of their callback services - Added some translation stubs - The ping to their service takes place as part of the validation
application.py
Outdated
@@ -16,7 +16,7 @@ | |||
|
|||
application = Flask("app") | |||
application.wsgi_app = ProxyFix(application.wsgi_app) # type: ignore | |||
xray_recorder.configure(service='Notify-Admin') | |||
xray_recorder.configure(service="Notify-Admin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a formatting change here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - works as expected! Will test some scenarios in staging once its there.
timeout=2, | ||
) | ||
|
||
g.callback_response_time = response.elapsed.total_seconds() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say I was concerned that using the flask global object might leak the value here to other users, but just learned that values stored here are request-specific and last for only one request. Good to know!
- Add new message content
- Fix issue with text displaying incorrectly on the delete confirmation interstitial
Summary | Résumé
This PR contains UX and feature enhancements to the callbacks pages.
https://
and passes the URL format check in validators)http 200
by performing a small ping to their callback serviceTest instructions | Instructions pour tester la modification
New validation
Test 1 - Valid callback
Test 2 - Invalid URL
http://
instead ofhttps://
Enter a URL that starts with https://
Must start with https://
Test 3 - Valid URL but server doesn't exist
Check your service is running and not using a proxy we cannot access
Your service must be running and reachable from the internet.
Delete button
Test response time button
Test 1 - Button visibility
Test response time
buttonTest response time
button is visibleTest 2 - Response time button
Test response time
buttonAPI integration
page but remained on the Callback config pageTest 3 - Differing URLs
Test 4 - Validation
Test response time
button.Inbound SMS callbacks page
To be able to access the Inbound SMS Callbacks page we first need to enable the
Receive inbound SMS
setting for the service.inbound_numbers
table:service_permissions
add a row to give your service theinbound_sms
permissionservice-.*
keys in RedisReceive inbound SMS
setting is turned onAPI integration
->Callbacks
Delivery receipts
andReceived text messages
Received text messages
and repeat the validation & test response time button tests to ensure feature parity between the two pages.