Skip to content

Commit

Permalink
address sourcelevel issues noted in PR #85 #104
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Sep 12, 2020
1 parent e5d8c5e commit a199c9e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
1 change: 0 additions & 1 deletion lib/auth_web/controllers/app_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ defmodule AuthWeb.AppController do
end
end


# @doc """
# approles/2 Return the (JSON) List of Roles for a given App based on apikey.client_id
# """
Expand Down
2 changes: 2 additions & 0 deletions lib/auth_web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ defmodule AuthWeb.AuthController do

# display welcome page on Auth site:
false ->
# Grant app_admin role to person who authenticated directly on auth app
# Auth.PeopleRoles.insert(1, person.id, 8)
conn
|> AuthPlug.create_jwt_session(person)
|> render(:welcome, person: person)
Expand Down
2 changes: 1 addition & 1 deletion priv/repo/default_roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"desc": "Can manage their own App(s).",
"person_id": "1",
"id": "8",
"permissions": "manage_apps, create_content, upload_images, edit_own_content, delete_own_content, invite_people"
"permissions": "manage_own_apps, create_content, upload_images, edit_own_content, delete_own_content, invite_people"
}
]
10 changes: 10 additions & 0 deletions test/auth_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ defmodule AuthWeb.AuthControllerTest do
end
end

# test "redirect_or_render assigns app_admin role if direct auth", %{conn: conn} do
# conn = non_admin_login(conn)
# IO.inspect(conn, label: "conn:96")
# person = conn.assigns.person
# IO.inspect(person, label: "person:98")

# AuthWeb.AuthController.redirect_or_render(conn, person, "")
# IO.inspect(conn, label: "conn:100")
# end

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

Expand Down
17 changes: 10 additions & 7 deletions test/auth_web/controllers/role_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ defmodule AuthWeb.RoleControllerTest do

test "non-admin person create role", %{conn: conn} do
conn = non_admin_login(conn)
{:ok, _app} = Auth.App.create_app(%{
"name" => "default system app",
"desc" => "Demo App",
"url" => "localhost:4000",
"person_id" => conn.assigns.person.id,
"status" => 3
})

{:ok, _app} =
Auth.App.create_app(%{
"name" => "default system app",
"desc" => "Demo App",
"url" => "localhost:4000",
"person_id" => conn.assigns.person.id,
"status" => 3
})

conn = get(conn, Routes.role_path(conn, :new))
assert html_response(conn, 200) =~ "New Role"
end
Expand Down
4 changes: 3 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ defmodule AuthTest do
end

def non_admin_person() do
rand = :rand.uniform(1000000)
rand = :rand.uniform(1_000_000)

Auth.Person.upsert_person(%{
email: "alex+#{rand}@gmail.com",
givenName: "Alexander McAwesome",
auth_provider: "email",
password: "thiswillbehashed"
})
Expand Down

0 comments on commit a199c9e

Please sign in to comment.