Skip to content
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

fix: Ensure CORS headers are still added when an error occurs in the authenticator #32

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

mattbearman
Copy link
Contributor

@mattbearman mattbearman commented Sep 11, 2024

Also fix CI issues:

  • rack.input is not longer set by default in mock request, so we need to always set it
  • Limiting issues:
    • add_runtime_dependency is deprecated in favour of add_dependency
    • params are not required for super when the method signature is unchanged

The `rack.input` header was made optional, so we need to always set an input in our mock requests
- add_runtime_dependency is deprecated in favour of add_dependency
- params are not required for `super` when the method signature is unchanged
@mattbearman mattbearman force-pushed the add-cors-headers-to-auth-errors branch from 5900b5c to 9a0b16d Compare September 12, 2024 09:09
@@ -36,7 +36,7 @@ def json_body
end

def body?
has_header?('rack.input')
has_header?(::Rack::RACK_INPUT)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ not strictly necessary, but I always prefer to use constants when they're available

Copy link

@jimehk jimehk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

Comment on lines 200 to 203
response = endpoint.execute(request)
expect(response.headers['Access-Control-Allow-Origin']).to eq 'example.com'
expect(response.headers['Access-Control-Allow-Methods']).to eq 'GET, POST'
expect(response.headers['Access-Control-Allow-Headers']).to eq 'X-Custom'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Just for the sake of completeness, might as well assert that response status is 500 :)

@mattbearman mattbearman merged commit 76cc18a into main Sep 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants