Merge pull request #10865 from demarches-simplifiees/fix-10799
ETQ Admin / Instructeur je veux être savoir si le jeton api entreprise d'une démarche a expiré ou va expirer prochainement
This commit is contained in:
commit
097074fdc7
25 changed files with 340 additions and 50 deletions
|
@ -621,31 +621,6 @@ describe Procedure do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'api_entreprise_token_expired?' do
|
||||
let(:token) { "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" }
|
||||
let(:procedure) { create(:procedure, api_entreprise_token: token) }
|
||||
let(:payload) {
|
||||
[
|
||||
{ "exp" => expiration_time }
|
||||
]
|
||||
}
|
||||
let(:subject) { procedure.api_entreprise_token_expired? }
|
||||
|
||||
before do
|
||||
allow(JWT).to receive(:decode).with(token, nil, false).and_return(payload)
|
||||
end
|
||||
|
||||
context "with token expired" do
|
||||
let(:expiration_time) { (1.day.ago).to_i }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context "with token not expired" do
|
||||
let(:expiration_time) { (1.day.from_now).to_i }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'clone' do
|
||||
let(:service) { create(:service) }
|
||||
let(:procedure) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue