-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[auth] display status in claims configuration
[identity] validate user metadata
- Loading branch information
Showing
7 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,15 +158,53 @@ defmodule BorutaIdentity.AdminTest do | |
params = %{ | ||
username: "[email protected]", | ||
password: "a valid password", | ||
metadata: %{"attribute_test" => "attribute_test value"} | ||
metadata: %{ | ||
"attribute_test" => %{ | ||
"value" => "attribute_test value", | ||
"status" => "valid" | ||
} | ||
} | ||
} | ||
|
||
assert {:ok, | ||
%User{ | ||
metadata: %{"attribute_test" => "attribute_test value"} | ||
metadata: %{ | ||
"attribute_test" => %{ | ||
"value" => "attribute_test value", | ||
"status" => "valid" | ||
} | ||
} | ||
}} = Admin.create_user(backend, params) | ||
end | ||
|
||
test "returns an error with invalid metadata", %{backend: backend} do | ||
metadata_field = %{ | ||
"attribute_name" => "attribute_test" | ||
} | ||
|
||
{:ok, backend} = | ||
Ecto.Changeset.change(backend, %{ | ||
metadata_fields: [ | ||
metadata_field | ||
] | ||
}) | ||
|> Repo.update() | ||
|
||
params = %{ | ||
username: "[email protected]", | ||
password: "a valid password", | ||
metadata: %{ | ||
"attribute_test" => %{ | ||
"value" => "attribute_test value" | ||
} | ||
} | ||
} | ||
|
||
assert_raise Ecto.InvalidChangesetError, fn -> | ||
Admin.create_user(backend, params) | ||
end | ||
end | ||
|
||
test "creates a user with a group", %{backend: backend} do | ||
params = %{ | ||
username: "[email protected]", | ||
|
@@ -239,12 +277,37 @@ defmodule BorutaIdentity.AdminTest do | |
Ecto.Changeset.change(user.backend, %{metadata_fields: [%{attribute_name: "test"}]}) | ||
|> Repo.update() | ||
|
||
metadata = %{"test" => "test value"} | ||
metadata = %{ | ||
"attribute_test" => %{ | ||
"value" => "attribute_test value", | ||
"status" => "valid" | ||
} | ||
} | ||
|
||
user_params = %{metadata: metadata} | ||
|
||
assert {:ok, %User{metadata: ^metadata}} = Admin.update_user(user, user_params) | ||
end | ||
|
||
test "returns an error with invalid metadata", %{user: user} do | ||
{:ok, _backend} = | ||
Ecto.Changeset.change(user.backend, %{metadata_fields: [%{attribute_name: "test"}]}) | ||
|> Repo.update() | ||
|
||
metadata = %{ | ||
"attribute_test" => %{ | ||
"value" => "attribute_test value" | ||
} | ||
} | ||
|
||
user_params = %{metadata: metadata} | ||
|
||
assert {:error, | ||
%Ecto.Changeset{ | ||
errors: [metadata: {"Required property status was not present. at #", []}] | ||
}} = Admin.update_user(user, user_params) | ||
end | ||
|
||
test "returns an error if group is not unique", %{user: user} do | ||
{:ok, _backend} = | ||
Ecto.Changeset.change(user.backend, %{metadata_fields: [%{attribute_name: "test"}]}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters