Module: Yes::Core::TestSupport::JwtHelpers
- Defined in:
- lib/yes/core/test_support/jwt_helpers.rb
Overview
Helpers for generating JWT tokens in API tests.
Instance Method Summary collapse
- #generate_spec_token(expires_at, data) ⇒ String
- #jwt_sign_in(expires_at: 1.hour.from_now, host: nil, identity_id: nil) ⇒ String
Instance Method Details
#generate_spec_token(expires_at, data) ⇒ String
19 20 21 22 23 24 25 26 |
# File 'lib/yes/core/test_support/jwt_helpers.rb', line 19 def generate_spec_token(expires_at, data) private_key = RbNaCl::Signatures::Ed25519::SigningKey.new( ENV.fetch('JWT_TOKEN_AUTH_PRIVATE_KEY') ) JWT.encode( data.merge(exp: expires_at.to_i), private_key, 'ED25519' ) end |
#jwt_sign_in(expires_at: 1.hour.from_now, host: nil, identity_id: nil) ⇒ String
12 13 14 |
# File 'lib/yes/core/test_support/jwt_helpers.rb', line 12 def jwt_sign_in(expires_at: 1.hour.from_now, host: nil, identity_id: nil) generate_spec_token(expires_at, host:, identity_id:) end |