Repository navigation
Answer CORS preflight OPTIONS on the enquiry endpoint #562
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,6 @@ async def test_post_enquiry_success(cli, company, other_server, worker): | |
|
|
||
|
|
||
| async def test_post_enquiry_long_grecaptcha_response(cli, company, other_server, worker): | ||
| other_server.app['extra_attributes'] = 'default' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claude Says: this line made the options define a required attribute (tell-us-about-yourself) that the posted data never included, so the test could only ever get a 400 — it merged green because CI's setup-python step was broken and tests never ran. The test only checks that a long grecaptcha token passes validation, so the attribute setup is dropped.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright |
||
| data = { | ||
| 'client_name': 'Cat Flap', | ||
| 'grecaptcha_response': 'good' * 1000, | ||
|
|
@@ -386,3 +385,18 @@ async def test_post_all_optional(cli, company, other_server): | |
| assert r.status == 201, await r.text() | ||
| data = await r.json() | ||
| assert data == {'status': 'enquiry submitted to TutorCruncher'} | ||
|
|
||
|
|
||
| async def test_options_enquiry_preflight(cli, company): | ||
| r = await cli.options( | ||
| cli.server.app.router['enquiry'].url_for(company=company.public_key), | ||
| headers={ | ||
| 'Origin': 'https://tutorcruncher.com', | ||
| 'Access-Control-Request-Method': 'POST', | ||
| 'Access-Control-Request-Headers': 'content-type', | ||
| }, | ||
| ) | ||
| assert r.status == 204, await r.text() | ||
| assert r.headers['Access-Control-Allow-Origin'] == '*' | ||
| assert r.headers['Access-Control-Allow-Methods'] == 'POST' | ||
| assert r.headers['Access-Control-Allow-Headers'] == 'Content-Type' | ||
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.
Outdated test runner