Module: PasskeysRails::Test::IntegrationHelpers

Defined in:
lib/passkeys_rails/test/integration_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



18
19
20
21
22
23
# File 'lib/passkeys_rails/test/integration_helpers.rb', line 18

def self.included(base)
  base.class_eval do
    setup :setup_integration_for_passkeys_rails
    teardown :teardown_integration_for_passkeys_rails
  end
end

Instance Method Details

#logged_in_headers(username, authenticatable = nil, headers: {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/passkeys_rails/test/integration_helpers.rb', line 25

def logged_in_headers(username, authenticatable = nil, headers: {})
  @agent = Agent.create(username:, registered_at: Time.current, authenticatable:)
  result = PasskeysRails::GenerateAuthToken.call(agent:)
  raise result.message if result.failure?

  headers.merge("X-Auth" => result.auth_token)
end