Skip to content

Commit

Permalink
add test for get_client_secret/2
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Jul 24, 2020
1 parent c2f3d19 commit 0498e98
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/auth_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ defmodule AuthWeb.AuthControllerTest do
assert conn.resp_body =~ "state=http://localhost/admin"
end

test "get_client_secret(client_id, state) gets the secret for the given client_id" do

person = Auth.Person.create_person(%{
email: "[email protected]",
auth_provider: "email"
})

{:ok, key} = %{"name" => "test key", "url" => "example.com"}
|> AuthWeb.ApikeyController.make_apikey(person.id)
|> Auth.Apikey.create_apikey()

state = "https://www.example.com/profile?auth_client_id=#{key.client_id}"
secret = AuthWeb.AuthController.get_client_secret(key.client_id, state)

assert secret == key.client_secret
end

test "github_handler/2 github auth callback", %{conn: conn} do
baseurl = AuthPlug.Helpers.get_baseurl_from_conn(conn)

Expand Down

0 comments on commit 0498e98

Please sign in to comment.