|
79 | 79 | end |
80 | 80 |
|
81 | 81 | it 'should be verifiable with the application public key' do |
82 | | - expect { JWT.decode(subject.serialize, public_key) }.not_to raise_error |
| 82 | + expect { JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512') } |
| 83 | + .not_to raise_error |
83 | 84 | end |
84 | 85 |
|
85 | 86 | it 'should be tamper-resistant' do |
86 | 87 | header, _, signature = subject.serialize.split('.') |
87 | | - tampered_claim = JWT.base64url_encode({ foo: 'bar' }.to_json) |
| 88 | + tampered_claim = JWT::Base64.url_encode({ foo: 'bar' }.to_json) |
88 | 89 | tampered_token = [header, tampered_claim, signature].join('.') |
89 | 90 |
|
90 | 91 | expect do |
91 | | - JWT.decode(tampered_token, public_key) |
| 92 | + JWT.decode(tampered_token, public_key, true, algorithm: 'RS512') |
92 | 93 | end.to raise_error JWT::DecodeError |
93 | 94 | end |
94 | 95 |
|
95 | 96 | it 'should represent :exp in seconds since the epoch' do |
96 | | - hash, = JWT.decode(subject.serialize, public_key) |
| 97 | + hash, = JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512') |
97 | 98 | expect(hash['exp']).to be_a Integer |
98 | 99 | end |
99 | 100 |
|
|
133 | 134 | # test that, although eventually we'll want to see symbols back. |
134 | 135 | actor_s = { 'sub' => 'foo', 'username' => 'test', |
135 | 136 | 'act' => { 'sub' => 'bar' } } |
136 | | - hash, = JWT.decode(subject.serialize, public_key) |
| 137 | + hash, = JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512') |
137 | 138 | expect(hash['act']).to eq(actor_s) |
138 | 139 |
|
139 | 140 | # Now, check that we properly get symbols back |
|
0 commit comments