2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-20 15:22:18 +02:00
|
|
|
describe APIEntreprise::PrivilegesAdapter do
|
|
|
|
let(:body) { File.read('spec/fixtures/files/api_entreprise/privileges.json') }
|
|
|
|
let(:status) { 200 }
|
|
|
|
let(:token) { "secret-token" }
|
|
|
|
let(:adapter) { described_class.new(token) }
|
|
|
|
|
|
|
|
subject { adapter }
|
|
|
|
|
|
|
|
before do
|
2023-11-14 17:22:18 +01:00
|
|
|
stub_request(:get, "https://entreprise.api.gouv.fr/privileges")
|
2022-07-20 15:22:18 +02:00
|
|
|
.to_return(body: body, status: status)
|
|
|
|
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_valid }
|
|
|
|
|
|
|
|
context 'when token is not valid or missing' do
|
|
|
|
let(:token) { nil }
|
|
|
|
let(:status) { 403 }
|
|
|
|
let(:body) { '' }
|
|
|
|
|
|
|
|
it { is_expected.not_to be_valid }
|
|
|
|
end
|
|
|
|
end
|