Skip to content

Commit

Permalink
raindrop is configured only in runtime now
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Oct 19, 2024
1 parent f841939 commit 2d4a140
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
9 changes: 0 additions & 9 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ config :logger, :console,
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

config :radiator, :service,
raindrop: %{
client_id: System.get_env("RAINDROP_CLIENT_ID"),
client_secret: System.get_env("RAINDROP_CLIENT_SECRET"),
options: [],
url: "https://raindrop.io/oauth/access_token",
redirect_url: "https://radiator.metaebene.net/api/raindrop/auth/redirect"
}

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
29 changes: 21 additions & 8 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,26 @@ if config_env() == :prod do
port: String.to_integer(System.get_env("SMTP_PORT")),
retries: 2,
no_mx_lookups: false
end

services = %{
raindrop: %{
client_id: System.get_env("RAINDROP_CLIENT_ID"),
client_secret: System.get_env("RAINDROP_CLIENT_SECRET"),
options: [],
url: "https://raindrop.io/oauth/access_token",
redirect_url: "https://radiator.metaebene.net/api/raindrop/auth/redirect"
}
}

config :radiator, raindrop: services.raindrop

config :radiator, :service,
raindrop: %{
client_id: System.get_env("RAINDROP_CLIENT_ID"),
client_secret: System.get_env("RAINDROP_CLIENT_SECRET"),
options: [],
url: "https://raindrop.io/oauth/access_token",
redirect_url: "https://radiator.metaebene.net/api/raindrop/auth/redirect"
}
if config_env() == :test do
config :radiator,
raindrop:
Map.merge(services.raindrop, %{
client_id: "2sxB9zzcQ6u2GtozA2cOJeq04",
client_secret: "BZ0Tug8KPjXMO9zeBB231X5Z8AL0nvL5EoENMN",
options: [plug: {Req.Test, RadiatorWeb.Api.RaindropController}]
})
end
8 changes: 0 additions & 8 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ config :phoenix_live_view,

# Enable tree consistency validator: crashes when tree is not valid!
config :radiator, tree_consistency_validator: true

config :radiator, :service,
raindrop: %{
client_id: "2sxB9zzcQ6u2GtozA2cOJeq04",
client_secret: "BZ0Tug8KPjXMO9zeBB231X5Z8AL0nvL5EoENMN",
options: [plug: {Req.Test, RadiatorWeb.Api.RaindropController}],
url: "https://raindrop.io/oauth/access_token"
}
3 changes: 1 addition & 2 deletions lib/radiator/raindrop_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule Radiator.RaindropClient do
@moduledoc """
Client for Raindrop API
"""
@config Application.compile_env(:radiator, [:service, :raindrop])

def config, do: @config
def config, do: Application.fetch_env!(:radiator, :raindrop)
end
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
defmodule RadiatorWeb.Api.RaindropControllerTest do
use RadiatorWeb.ConnCase, async: true

@raindrop Application.compile_env(:radiator, [:service, :raindrop])

alias Radiator.AccountsFixtures

describe "GET /raindrop/auth/redirect/:user_id" do
setup %{conn: conn} do
%{host: host, path: path} = URI.parse(@raindrop.url)
raindrop = Radiator.RaindropClient.config()
%{host: host, path: path} = URI.parse(raindrop.url)

%{
conn: conn,
code: "some_random_string",
client_id: @raindrop.client_id,
client_secret: @raindrop.client_secret,
client_id: raindrop.client_id,
client_secret: raindrop.client_secret,
host: host,
path: path
}
Expand Down

0 comments on commit 2d4a140

Please sign in to comment.