Module: Fluence::Gateway::Auth::TestHelpers
- Defined in:
- lib/fluence/gateway/auth/test_helpers.rb
Overview
Test-only helpers for application specs that need to exercise controllers and channels behind the gateway middleware without signing every request.
Loading this file has a global side effect: it flips
Configuration#skip_middleware to true for the whole
process, so Middleware stops verifying HMAC signatures.
Require it only from a test boot file (typically
spec/rails_helper.rb or test/test_helper.rb) — never from
production code.
Once loaded, include the module in your example groups to get:
- #sign_in_as — remember a user for the rest of the example.
- #gateway_headers_for — build the headers the gateway would inject for that user, ready to hand to a Rack request helper.
Instance Method Summary collapse
-
#gateway_headers_for(user = @gateway_test_user, client_id: 'test-client') ⇒ Hash{String => String}
Builds the headers the Fluence Gateway would inject for the given user.
-
#sign_in_as(user) ⇒ Object
Remembers a user for subsequent calls to #gateway_headers_for that omit the
userargument.
Instance Method Details
#gateway_headers_for(user = @gateway_test_user, client_id: 'test-client') ⇒ Hash{String => String}
Builds the headers the Fluence Gateway would inject for the given user. Returns an empty hash when no user is available, so the call is safe in unauthenticated examples.
Only the headers backed by a responding method are emitted:
email, first_name, last_name and scopes are all
optional.
#sign_in_as(user) ⇒ Object
Remembers a user for subsequent calls to
#gateway_headers_for that omit the user argument.