Skip to content

Commit

Permalink
Properly report Boulogne SIRI availability
Browse files Browse the repository at this point in the history
Fixes #4283
  • Loading branch information
thbar committed Oct 31, 2024
1 parent e07b830 commit 499c8cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/transport/lib/transport/availability_checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ defmodule Transport.AvailabilityChecker do
{:ok, %Response{status_code: code}} when (code >= 200 and code < 300) or code in [401, 405] ->
true

# At least one SIRI server returns a 500 despite being reachable and returning proper SOAP.
# Accept it, until we implement the better `CheckStatus` SIRI availability check.
# https://github.com/etalab/transport-site/issues/4283
{:ok, %Response{status_code: 500, body: body}} ->
body |> String.downcase() |> String.contains?("soap:envelope")

# Bug affecting Hackney (dependency of HTTPoison)
# 303 status codes on `GET` requests should be fine but they're returned as errors
# https://github.com/edgurgel/httpoison/issues/171#issuecomment-244029927
Expand Down
9 changes: 9 additions & 0 deletions apps/transport/test/transport/availability_checker_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ defmodule Transport.AvailabilityCheckerTest do

assert AvailabilityChecker.available?("SIRI", "url303")
end

test "500 response (but with SOAP body)" do
Transport.HTTPoison.Mock
|> expect(:get, fn "url500soap", [], [follow_redirect: true] ->
{:ok, %HTTPoison.Response{status_code: 500, body: "<soap:Envelope></soap:Envelope>"}}
end)

assert AvailabilityChecker.available?("SIRI", "url500soap")
end
end

test "HEAD NOT supported, fallback on stream method" do
Expand Down

0 comments on commit 499c8cc

Please sign in to comment.