Created
January 5, 2019 10:48
-
-
Save v-kolesnikov/b125f7f5e8e2daff11bb9033092b422a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'bundler/inline' | |
gemfile(true) do | |
gem 'jwt' | |
gem 'rspec' | |
end | |
require 'jwt' | |
require 'openssl' | |
require 'rspec/autorun' | |
RSpec.describe do | |
subject(:cookie) do | |
{ | |
access_token: json_web_token, | |
refresh_token: json_web_token | |
}.to_json | |
end | |
let(:json_web_token) do | |
JWT.encode( | |
payload, key, 'RS256', | |
iat: Time.now, | |
exp: Time.now.to_i + (_120_minutes = 2 * 60 * 60) | |
) | |
end | |
let(:payload) do | |
{ user_id: SecureRandom.uuid } | |
end | |
let(:key) do | |
OpenSSL::PKey::RSA.new(_size = 2048) | |
end | |
it { expect(cookie.size).to eql 2 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment