create SQL function "change_user_password"
This commit is contained in:
@@ -2,6 +2,7 @@ do
|
||||
$$
|
||||
declare
|
||||
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
|
||||
user_with_other_password json;
|
||||
selected_user json;
|
||||
exist_user json;
|
||||
begin
|
||||
@@ -24,6 +25,12 @@ begin
|
||||
assert exist_user->>'username' = 'george', format('the function check_user must be return user object with username is "george", %s is return', exist_user::text);
|
||||
assert exist_user->>'password' is null, format('the function check_user must not be return the password, %s is return', exist_user::text);
|
||||
|
||||
-- test change password
|
||||
user_with_other_password = jsonb_set(created_user::jsonb, '{plain_password}', '"qwerty"'::jsonb);
|
||||
perform change_user_password(user_with_other_password);
|
||||
select check_user('george', 'qwerty') into exist_user;
|
||||
assert exist_user->>'username' = 'george', format('the function change_user_password must change password: %s', exist_user::text);
|
||||
|
||||
-- delete user and check if user is really not exists
|
||||
delete from "user" where username = 'george';
|
||||
select check_user('george', 'azerty') into exist_user;
|
||||
|
||||
Reference in New Issue
Block a user