Appelle l'API entreprise avec le token en Header
This commit is contained in:
parent
8febbadad6
commit
f748ccfc9e
23 changed files with 42 additions and 41 deletions
|
@ -7,7 +7,7 @@ describe ApiEntreprise::API do
|
|||
subject { described_class.entreprise(siren, procedure_id) }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=#{token}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
.to_return(status: status, body: body)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ describe ApiEntreprise::API do
|
|||
|
||||
it 'call api-entreprise with specfic token' do
|
||||
subject
|
||||
expect(WebMock).to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=#{token}/)
|
||||
expect(WebMock).to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +78,7 @@ describe ApiEntreprise::API do
|
|||
|
||||
it 'call api-entreprise with specfic token' do
|
||||
subject
|
||||
expect(WebMock).to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=#{token}/)
|
||||
expect(WebMock).to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -87,7 +87,7 @@ describe ApiEntreprise::API do
|
|||
describe '.etablissement' do
|
||||
subject { described_class.etablissement(siret, procedure_id) }
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*non_diffusables=true&.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*non_diffusables=true/)
|
||||
.to_return(status: status, body: body)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -115,7 +115,7 @@ describe ApiEntreprise::API do
|
|||
|
||||
describe '.exercices' do
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\//)
|
||||
.to_return(status: status, body: body)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -147,7 +147,7 @@ describe ApiEntreprise::API do
|
|||
|
||||
describe '.rna' do
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||
.to_return(status: status, body: body)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -182,7 +182,7 @@ describe ApiEntreprise::API do
|
|||
before do
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(roles)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
|
@ -211,7 +211,7 @@ describe ApiEntreprise::API do
|
|||
before do
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(roles)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}?.*token=#{token}&user_id=#{user_id}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
|
@ -239,7 +239,7 @@ describe ApiEntreprise::API do
|
|||
before do
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(roles)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}?.*token=#{token}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
|
@ -268,7 +268,7 @@ describe ApiEntreprise::API do
|
|||
|
||||
it 'makes no call to api-entreprise' do
|
||||
subject
|
||||
expect(WebMock).not_to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=#{token}/)
|
||||
expect(WebMock).not_to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ describe ApiEntreprise::AttestationFiscaleAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}\?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_fiscales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
|
|
@ -6,7 +6,7 @@ describe ApiEntreprise::AttestationSocialeAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}\?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
|
|
@ -7,7 +7,7 @@ describe ApiEntreprise::BilansBdfAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}\?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
|
|
@ -9,7 +9,7 @@ describe ApiEntreprise::EffectifsAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}\?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ describe ApiEntreprise::EffectifsAnnuelsAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}\?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ describe ApiEntreprise::EntrepriseAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
subject { described_class.new(siret, procedure_id).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}/)
|
||||
.to_return(body: File.read(fixture, status: 200))
|
||||
end
|
||||
|
||||
|
@ -99,7 +99,7 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
subject { described_class.new(siret, procedure_id).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}/)
|
||||
.to_return(body: File.read('spec/fixtures/files/api_entreprise/etablissements_private.json', status: 200))
|
||||
end
|
||||
|
||||
|
@ -113,7 +113,7 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
subject { described_class.new(bad_siret, procedure_id).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{bad_siret}?.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{bad_siret}/)
|
||||
.to_return(body: 'Fake body', status: 404)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ describe ApiEntreprise::ExercicesAdapter do
|
|||
subject { described_class.new(siret, procedure.id).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\//)
|
||||
.to_return(body: File.read('spec/fixtures/files/api_entreprise/exercices.json', status: 200))
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ describe ApiEntreprise::RNAAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/.*token=/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue