Skip to content

Commit

Permalink
Remove wiremock (#1970)
Browse files Browse the repository at this point in the history
* remove references to wiremock

* remove proxy headers
  • Loading branch information
anthonyshull authored Apr 10, 2024
1 parent f385f50 commit e54ffca
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 172 deletions.
8 changes: 2 additions & 6 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ end
config :dotcom,
v3_api_base_url: System.get_env("V3_URL"),
v3_api_key: System.get_env("V3_API_KEY"),
v3_api_version: System.get_env("V3_API_VERSION", "2019-07-01"),
v3_api_wiremock_proxy_url: System.get_env("WIREMOCK_PROXY_URL"),
v3_api_wiremock_proxy: System.get_env("WIREMOCK_PROXY") || "false"
v3_api_version: System.get_env("V3_API_VERSION", "2019-07-01")

config :dotcom, aws_index_prefix: System.get_env("AWS_PLACE_INDEX_PREFIX") || "dotcom-dev"

Expand All @@ -130,9 +128,7 @@ end

config :dotcom, OpenTripPlanner,
timezone: System.get_env("OPEN_TRIP_PLANNER_TIMEZONE", "America/New_York"),
otp_url: System.get_env("OPEN_TRIP_PLANNER_URL"),
wiremock_proxy: System.get_env("WIREMOCK_PROXY", "false"),
wiremock_proxy_url: System.get_env("WIREMOCK_TRIP_PLAN_PROXY_URL")
otp_url: System.get_env("OPEN_TRIP_PLANNER_URL")

if config_env() != :test and System.get_env("OPEN_TRIP_PLANNER_URL") != "" do
config :open_trip_planner_client,
Expand Down
12 changes: 0 additions & 12 deletions docs/ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ This variable is used to specify which Open Trip Planner URL to use. For our dep

To make your local server externally visible (useful for testing on a real phone, for example), set this to your IP address, which you can find from `ifconfig`, probably under `en0`.

### `WIREMOCK_PATH`

The path to your wiremock `.jar` file. Currently, this optional variable is only used by `npm` tasks, and not `mix`.

### `WIREMOCK_PROXY_URL`

This is the `V3_URL` value that is used by wiremock when recording API requests.

### `WIREMOCK_TRIP_PLAN_PROXY_URL`

This is the `OPEN_TRIP_PLANNER_URL` value that is used by wiremock when recording Open Trip Planner API requests.

### `SUPPORT_TICKET_TO_EMAIL`

An email address to send support tickets to.
Expand Down
18 changes: 0 additions & 18 deletions lib/mbta/headers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ defmodule MBTA.Headers do
def build(api_key, opts) do
[]
|> api_key_header(api_key)
|> proxy_headers()
|> cache_headers(opts)
|> extra_headers()
end
Expand All @@ -27,23 +26,6 @@ defmodule MBTA.Headers do
[{"x-api-key", key}, {"MBTA-Version", api_version} | headers]
end

@spec proxy_headers(header_list) :: header_list
defp proxy_headers(headers) do
:dotcom
|> Util.config(:v3_api_wiremock_proxy)
|> do_proxy_headers(headers)
end

@spec do_proxy_headers(String.t() | nil, header_list) :: header_list
defp do_proxy_headers("true", headers) do
proxy_url = Util.config(:dotcom, :v3_api_wiremock_proxy_url)
[{"X-WM-Proxy-Url", proxy_url} | headers]
end

defp do_proxy_headers(_, headers) do
headers
end

@spec cache_headers(header_list, Keyword.t()) :: header_list
defp cache_headers(headers, opts) do
if Keyword.get(opts, :use_cache?, true) do
Expand Down
7 changes: 1 addition & 6 deletions lib/vehicles/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ defmodule Vehicles.Supervisor do
]
end

defp stream_children("false") do
# Wiremock does not support server-sent events,
# so starting the vehicle stream during tests using Wiremock
# causes the server to crash.
[]
end
defp stream_children("false"), do: []

defp stream_children(_) do
sses_opts =
Expand Down
121 changes: 0 additions & 121 deletions scripts/run_mock_server.sh

This file was deleted.

9 changes: 0 additions & 9 deletions test/mbta/headers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ defmodule MBTA.Api.HeadersTest do
]
end

test "adds wiremock proxy header if env var is set" do
reassign_env(:dotcom, :v3_api_wiremock_proxy_url, "proxy_url")
reassign_env(:dotcom, :v3_api_wiremock_proxy, "true")

assert Headers.build("API_KEY", use_cache?: false) |> Keyword.take(["X-WM-Proxy-Url"]) == [
{"X-WM-Proxy-Url", "proxy_url"}
]
end

test "calls cache header fn if use_cache? is true" do
opts = [
use_cache?: true,
Expand Down

0 comments on commit e54ffca

Please sign in to comment.