Sha256: f2aa4d738d878dcdf1ce79cb22483deb2d2e6815d9d774bd09d92d8ada57a708

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true
require 'spec_helper'
require 'drillbit/tokens/json_web_tokens/password_reset'

module          Drillbit
module          Tokens
module          JsonWebTokens
RSpec.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

3 entries across 3 versions & 1 rubygems

Version Path
drillbit-1.1.0 spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb
drillbit-1.0.1 spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb
drillbit-1.0.0 spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb