Module: OTP::JWT::TestHelpers
- Defined in:
- lib/otp/jwt/test_helpers.rb
Overview
Helpers to help you test the [JWT] requests.
Instance Method Summary collapse
-
#jwt_auth_header(entity_or_subject) ⇒ Hash
Helper to handle authentication requests easier.
-
#response_json ⇒ Hash
Parses and returns a deserialized JSON.
Instance Method Details
#jwt_auth_header(entity_or_subject) ⇒ Hash
Helper to handle authentication requests easier
10 11 12 13 14 15 16 17 |
# File 'lib/otp/jwt/test_helpers.rb', line 10 def jwt_auth_header(entity_or_subject) return {} unless entity_or_subject.present? token = entity_or_subject.try(:to_jwt) token ||= OTP::JWT::Token.sign(sub: entity_or_subject) { 'Authorization': "Bearer #{token}" } end |
#response_json ⇒ Hash
Parses and returns a deserialized JSON
22 23 24 |
# File 'lib/otp/jwt/test_helpers.rb', line 22 def response_json JSON.parse(response.body) end |