diff --git a/app/models/concerns/api_entreprise_token_concern.rb b/app/models/concerns/api_entreprise_token_concern.rb index ad1d0a41e..2cfacb346 100644 --- a/app/models/concerns/api_entreprise_token_concern.rb +++ b/app/models/concerns/api_entreprise_token_concern.rb @@ -18,10 +18,6 @@ module APIEntrepriseTokenConcern self[:api_entreprise_token].presence || Rails.application.secrets.api_entreprise[:key] end - def api_entreprise_token_expired? - APIEntrepriseToken.new(api_entreprise_token).expired? - end - def api_entreprise_token_expired_or_expires_soon? api_entreprise_token_expires_at && api_entreprise_token_expires_at <= SOON_TO_EXPIRE_DELAY.from_now end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index ae0179513..2453f7749 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -616,31 +616,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