NOISSUE - Fix Update User (#959)

* NOISSUE - Fix Update User

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm duplicated test

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix typo

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
This commit is contained in:
Manuel Imperiale 2019-11-20 14:03:17 +01:00 committed by Dušan Borovčanin
parent 52c4d4a824
commit 1b427f4396
2 changed files with 4 additions and 6 deletions

View File

@ -147,7 +147,7 @@ func (svc usersService) UserInfo(ctx context.Context, token string) (User, error
func (svc usersService) UpdateUser(ctx context.Context, token string, u User) error {
email, err := svc.idp.Identity(token)
if err != nil || email != u.Email {
if err != nil {
return ErrUnauthorizedAccess
}

View File

@ -141,12 +141,11 @@ func TestUserInfo(t *testing.T) {
}
}
// UpdateUser updates the user metadata
func TestUpdateUser(t *testing.T) {
svc := newService()
svc.Register(context.Background(), user)
key, _ := svc.Login(context.Background(), user)
user.Metadata = map[string]interface{}{"role": "test"}
cases := map[string]struct {
@ -154,9 +153,8 @@ func TestUpdateUser(t *testing.T) {
token string
err error
}{
"valid token update user": {user, key, nil},
"invalid token's update user": {user, "", users.ErrUnauthorizedAccess},
"non existing user update": {nonExistingUser, key, users.ErrUnauthorizedAccess},
"update user with valid token": {user, key, nil},
"update user with invalid token": {user, "non-existent", users.ErrUnauthorizedAccess},
}
for desc, tc := range cases {