From 1b427f4396eda6d2a10bc186ecc4de0f6cbc2beb Mon Sep 17 00:00:00 2001 From: Manuel Imperiale Date: Wed, 20 Nov 2019 14:03:17 +0100 Subject: [PATCH] NOISSUE - Fix Update User (#959) * NOISSUE - Fix Update User Signed-off-by: Manuel Imperiale * Rm duplicated test Signed-off-by: Manuel Imperiale * Fix typo Signed-off-by: Manuel Imperiale --- users/service.go | 2 +- users/service_test.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/users/service.go b/users/service.go index c4235fcc..4f235b04 100644 --- a/users/service.go +++ b/users/service.go @@ -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 } diff --git a/users/service_test.go b/users/service_test.go index cfdf5a06..903e6c19 100644 --- a/users/service_test.go +++ b/users/service_test.go @@ -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 {