-
Notifications
You must be signed in to change notification settings - Fork 5
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
Prehook user creation #378
Conversation
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.
Great work. Even if temp url is not available right now, I think that we can do more stuff right now to be better prepared.
x.start() | ||
|
||
return webhook_app_instance | ||
|
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.
All the webhook_app
and handling of serve/threading can be simplified with TestApp
using same process as in get_test_magpie_app
.
Doesn't need extra waitress
and all other util functions will be available directly.
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.
@fmigneault
The problem I had for creating the webhook app is that the context was a bit different.
For the Magpie app in the tests, we create a TestApp, and we then access it directly to execute the multiple requests required.
For the webhook app, it has to be accessible via an URL from inside the Magpie app, so I couldn't use the TestApp approach, since that app would not be accessible where the webhooks requests would be called. I had to make it available via an URL, using waitress.
@@ -18,3 +18,4 @@ pyramid-twitcher==0.5.3 | |||
pytest | |||
tox>=3.0 | |||
webtest | |||
waitress |
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.
extra dependency not needed, see other comment
tests/test_magpie_api.py
Outdated
# Check if user deletion was successful even if the webhook failed | ||
sleep(1) | ||
utils.check_response_basic_info(resp, 200, expected_method="GET") | ||
utils.TestSetup.check_NonExistingTestUser(self) |
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.
There is nothing that seems to validate that Magpie sent the request to the webhook URL.
Should have some kind of mock of the error callback to ensure it was called.
tests/test_magpie_api.py
Outdated
# Check if user deletion was successful even if no webhooks were defined in the config | ||
sleep(1) | ||
utils.check_response_basic_info(resp, 200, expected_method="GET") | ||
utils.TestSetup.check_NonExistingTestUser(self) |
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.
idem as previous with validation mock
Version #2 of the PR🙂 Main changes are :
I did not change the app (the point about using TestApp instead of waitress), see the related response :
About the mocking aspect, I didn't use the suggested mock. I wasn't sure in what case to use it, but let me know if the new tests are okay. I will still have to merge Francis' new code after this and finish the part about the tmp_url. I will do another PR after this. |
@fmigneault There seems to already have other issues in other files, so do I just ignore this one too? |
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 although I suggest a snippet to simplify the replace_template function.
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 got a new small request for you.
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.
Ok I'm super happy with it now :)
…ehook-user_creation
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.
Should be good to go. Waiting for PR #383 with extra code on top of this one.
Fixes #343
@ChaamC
You can either change the base of #383 to be master, so that it includes both PRs, or merge it first and then this one after in master, as you prefer. Just make sure the whole test suites runs on both combined.
Finish the missing tmp_url part for the webhooks
…ehook-user_creation
…ehook-user_creation
Codecov Report
@@ Coverage Diff @@
## master #378 +/- ##
==========================================
+ Coverage 75.93% 76.13% +0.20%
==========================================
Files 65 66 +1
Lines 7882 7974 +92
Branches 1097 1118 +21
==========================================
+ Hits 5985 6071 +86
- Misses 1621 1622 +1
- Partials 276 281 +5
Continue to review full report at Codecov.
|
4dc4e0c
to
20c4380
Compare
This PR adds the webhook feature for user creation/deletion. We add the desired urls to the config.yml file.
Note that there is currently no error handling if the webhook fails, since it is not in Magpie's responsabilities.
Magpie only sends the webhook requests and continues with its current jobs. The webhook requests are non blocking.