-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update deps #146 #147
update deps #146 #147
Conversation
|
This comment has been minimized.
This comment has been minimized.
I've recreated a google oauth application and login works on localhost. However the test are still failing. def google_handler(conn, %{"code" => code, "state" => state}) do
{:ok, token} = ElixirAuthGoogle.get_token(code, conn) # error here
{:ok, profile} = ElixirAuthGoogle.get_user_profile(token.access_token)
# save profile to people:
app_id = get_app_id(state)
person = Person.create_google_person(Map.merge(profile, %{app_id: app_id}))
# render or redirect:
handler(conn, person, state)
end The function |
I think the issue is that we are running the test using request to Google instead of using mocks. The def get_token(code, conn) do
body = Jason.encode!(
%{ client_id: System.get_env("GOOGLE_CLIENT_ID") || Application.get_env(:elixir_auth_google, :client_id),
client_secret: System.get_env("GOOGLE_CLIENT_SECRET") || Application.get_env(:elixir_auth_google, :client_secret),
redirect_uri: generate_redirect_uri(conn),
grant_type: "authorization_code",
code: code
})
inject_poison().post(@google_token_url, body)
|> parse_body_response()
end Then the inject_poison().post(@google_token_url, body) This function is defined at compile time with: @httpoison Mix.env() == :test && ElixirAuthGoogle.HTTPoisonMock || HTTPoison
@doc """
`inject_poison/0` injects a TestDouble of HTTPoison in Test
so that we don't have duplicate mock in consuming apps.
see: https://github.com/dwyl/elixir-auth-google/issues/35
"""
def inject_poison(), do: @httpoison I think at this point the function run the real post request instead of the mock. It might be linked to dwyl/elixir-auth-google#37 and dwyl/elixir-auth-google#41 |
Updating manually the elixir-auth-google dependency and updating inject_poison to: def inject_poison() do
Mix.env() == :test && ElixirAuthGoogle.HTTPoisonMock || HTTPoison
end Make the current failing tests pass (there are two more failing test link to b58 that we can debug a bit later) edit:
|
@SimonLab the "Test Double" (mocked version) for Google Auth was deliberate: dwyl/elixir-auth-google#35 Thanks for diving into the the |
Codecov Report
@@ Coverage Diff @@
## main #147 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 544 545 +1
=========================================
+ Hits 544 545 +1
Continue to review full report at Codecov.
|
Hi @SimonLab hopefully this PR is self-explanatory and you've been following along. 😉 |
scope "/dev" do | ||
pipe_through :browser | ||
|
||
forward "/mailbox", Plug.Swoosh.MailboxPreview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to check Swoosh. Not sure if you wanted to add it to this PR or later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw it's part of the Phoenix 1.6 code 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, need to investigate it. Email in general. Specifically receiving replies. 💭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for debugging the test double 👍
Latest version deployed to Heroku: Going to test it on my side. 👨💻 |
This is a maintenance PR that revives the project and brings it up to date with the latest Elixir & Phoenix. 🙌
Elixir
version Update Elixir and dependencies #142 / Update Project to Elixir v1.12 #145