-
-
Notifications
You must be signed in to change notification settings - Fork 158
✅ Integration tests #98
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
Conversation
2386179 to
85f2f52
Compare
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.
Pull Request Overview
This PR adds OmniAuth 2.x compatibility, improves test infrastructure, and refactors code for better maintainability. The main focus is ensuring the LDAP strategy works correctly with both OmniAuth 1.x and 2.x versions, particularly around request method handling (GET vs POST).
- Adds version-aware request method handling for OmniAuth >= 2.0 (POST-only)
- Introduces new integration tests for Roda framework and middleware behavior
- Refactors code to use modern Ruby syntax and best practices (e.g.,
||instead ofor,class << self)
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/omniauth/strategies/ldap.rb | Core changes: adds OmniAuth 2.x compatibility with version detection, POST-only enforcement, auto-redirect on credential submission, refactors map_user to class method, improves code style |
| spec/spec_helper.rb | Adds CI detection logic to skip coverage checks in dev environments, fixes require logic to handle missing matches |
| spec/sample/roda_app.rb | New sample Roda application for integration testing |
| spec/omniauth/adaptor_spec.rb | New test coverage for LDAP adaptor internal methods |
| spec/integration/roda_integration_spec.rb | New integration tests for Roda framework compatibility |
| spec/integration/middleware_spec.rb | New integration tests for OmniAuth middleware behavior |
| spec/config/debug.rb | Removes debug print statement |
| omniauth-ldap.gemspec | Adds roda development dependency |
| Gemfile.lock | Updates with roda gem |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/omniauth/strategies/ldap.rb
Outdated
| # If credentials were POSTed directly to /auth/:provider, redirect to the callback path. | ||
| # This mirrors the behavior of many OmniAuth providers and allows test helpers (like | ||
| # OmniAuth::Test::PhonySession) to populate `env['omniauth.auth']` on the callback request. | ||
| if request.post? && (request.params["username"] || request.params["password"]) |
Copilot
AI
Nov 5, 2025
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.
The condition request.params['username'] || request.params['password'] will trigger a redirect even when only one credential is present or when either is an empty string. This could bypass the missing_credentials? check in callback_phase. Consider using a more precise condition like checking if both parameters are present (non-nil), or document why partial credentials should trigger a redirect.
| if request.post? && (request.params["username"] || request.params["password"]) | |
| if request.post? && request.params["username"].to_s != "" && request.params["password"].to_s != "" |
85f2f52 to
027e5d5
Compare
No description provided.