FEATURE: Add scheduled Twitter login problem check - Part 1 (#25830)

This PR adds a new scheduled problem check that simply tries to connect to Twitter OAuth endpoint to check that it's working. It is using the default retry strategy of 2 retries 30 seconds apart.
This commit is contained in:
Ted Johansson
2024-02-26 12:08:12 +08:00
committed by GitHub
parent a1d7548869
commit ed2496c59d
8 changed files with 149 additions and 2 deletions

View File

@ -65,4 +65,37 @@ RSpec.describe Auth::TwitterAuthenticator do
expect(authenticator.description_for_user(user)).to eq("")
end
end
describe "#healthy?" do
let(:authenticator) { described_class.new }
let(:connection) { mock("Faraday::Connection") }
let(:response) { mock("Faraday::Response") }
before do
Faraday.stubs(:new).returns(connection)
connection.stubs(:post).returns(response)
response.stubs(:status).returns(status)
end
context "when endpoint is reachable" do
let(:status) { 200 }
it { expect(authenticator).to be_healthy }
end
context "when credentials aren't recognized" do
let(:status) { 403 }
it { expect(authenticator).not_to be_healthy }
end
context "when an unexpected error happens" do
let(:status) { anything }
before { connection.stubs(:post).raises(Faraday::ServerError) }
it { expect(authenticator).not_to be_healthy }
end
end
end