remove api_up?

This commit is contained in:
simon lehericey 2024-04-05 12:26:25 +02:00
parent 7b33963a67
commit 42f0b87c39
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
5 changed files with 0 additions and 67 deletions

View file

@ -83,13 +83,6 @@ class APIEntreprise::API
call(url) call(url)
end end
def current_status
status_url = "https://status.entreprise.api.gouv.fr/summary.json"
response = Typhoeus.get(status_url, timeout: 1)
handle_response(response)
end
private private
def recipient_for(siret_or_siren) def recipient_for(siret_or_siren)

View file

@ -58,13 +58,6 @@ class APIEntrepriseService
APIEntreprise::AttestationFiscaleJob.set(wait:).perform_later(etablissement.id, procedure_id, user_id) APIEntreprise::AttestationFiscaleJob.set(wait:).perform_later(etablissement.id, procedure_id, user_id)
end end
def api_up?
APIEntreprise::API.new.current_status.fetch(:page).fetch(:status) == 'UP'
rescue => e
Sentry.capture_exception(e)
false
end
# See: https://entreprise.api.gouv.fr/developpeurs#surveillance-etat-fournisseurs # See: https://entreprise.api.gouv.fr/developpeurs#surveillance-etat-fournisseurs
def api_insee_up? def api_insee_up?
response = Typhoeus.get("https://entreprise.api.gouv.fr/ping/insee/sirene", timeout: 1) response = Typhoeus.get("https://entreprise.api.gouv.fr/ping/insee/sirene", timeout: 1)

View file

@ -1,7 +0,0 @@
{
"page": {
"name": "API Entreprise",
"url": "https://status.entreprise.api.gouv.fr",
"status": "UP"
}
}

View file

@ -323,18 +323,4 @@ describe APIEntreprise::API do
expect(WebMock).not_to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/) expect(WebMock).not_to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
end end
end end
describe 'current_status' do
subject { described_class.new.current_status }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/status.json').read }
before do
stub_request(:get, "https://status.entreprise.api.gouv.fr/summary.json")
.to_return(body: body)
end
it "returns the current status response" do
expect(subject).to eq(JSON.parse(body, symbolize_names: true))
end
end
end end

View file

@ -85,38 +85,6 @@ describe APIEntrepriseService do
it_behaves_like 'schedule fetch of all etablissement params' it_behaves_like 'schedule fetch of all etablissement params'
end end
describe "#api_up?" do
subject { described_class.api_up? }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/status.json').read }
let(:status) { 200 }
before do
stub_request(:get, "https://status.entreprise.api.gouv.fr/summary.json")
.to_return(body: body, status: status)
end
it "returns true when api etablissement is up" do
expect(subject).to be_truthy
end
context "when api entreprise is down" do
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/status.json').read.gsub('UP', 'HASISSUES') }
it "returns false" do
expect(subject).to be_falsey
end
end
context "when api entreprise status is unknown" do
let(:body) { "" }
let(:status) { 0 }
it "returns nil" do
expect(subject).to be_falsey
end
end
end
describe "#api_insee_up?" do describe "#api_insee_up?" do
subject { described_class.api_insee_up? } subject { described_class.api_insee_up? }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/ping.json').read } let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/ping.json').read }