Sha256: bc7b8637037be603221d5120fc283a26907fec703416b0a1ccdb8795f08987d0

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true
require 'rspeckled/spec_helpers/rspeckled'
require 'drillbit/tokens/json_web_tokens/password_reset'

module    Drillbit
module    Tokens
module    JsonWebTokens
describe  PasswordReset do
  it 'can build a token that expires during the password reset timeframe', :time_mock do
    token = JsonWebToken.build(id:                'test_id',
                               subject_id:        'subject_id',
                               token_private_key: test_private_key)

    jwe_s = token.to_jwe_s

    converted_token = JsonWebToken.from_jwe(jwe_s,
                                            private_key: test_private_key)

    expect(converted_token.to_h).to eql(
      [
        {
          'aud' => 'public',
          'exp' => 1_343_930_400,
          'iat' => 1_343_325_600,
          'iss' => 'drillbit',
          'jti' => 'test_id',
          'nbf' => 1_343_325_600,
          'own' => 'subject_id',
          'rol' => 'standard',
          'sid' => 'subject_id',
          'sub' => 'User',
        },
        {
          'typ' => 'JWT',
          'alg' => 'RS256',
        },
      ],
    )
  end
end
end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drillbit-2.11.0 spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb
drillbit-2.10.0 spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb