Initial commit
This commit is contained in:
16
spec/lib/barong/jwt_spec.rb
Normal file
16
spec/lib/barong/jwt_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'barong/jwt'
|
||||
|
||||
describe Barong::JWT do
|
||||
let(:key) { OpenSSL::PKey::RSA.generate(2048) }
|
||||
|
||||
it 'should encode payload with claims' do
|
||||
codec = Barong::JWT.new(key: key)
|
||||
token = codec.encode({hello: 'world'})
|
||||
|
||||
decoded = ::JWT.decode(token, key.public_key,
|
||||
true, { algorithm: 'RS256' })
|
||||
expect(decoded.first.fetch('hello')).to eq('world')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user