forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: principal check before create relation
- Loading branch information
1 parent
d141af5
commit ae2a0d9
Showing
2 changed files
with
33 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import ( | |
"github.com/goto/shield/core/activity" | ||
"github.com/goto/shield/core/user" | ||
"github.com/goto/shield/core/user/mocks" | ||
"github.com/goto/shield/pkg/logger" | ||
shieldlogger "github.com/goto/shield/pkg/logger" | ||
"github.com/goto/shield/pkg/uuid" | ||
) | ||
|
@@ -39,7 +38,7 @@ func TestService_Create(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{ | ||
|
@@ -80,7 +79,7 @@ func TestService_Create(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, user.ErrNotExist) | ||
|
@@ -117,7 +116,7 @@ func TestService_Create(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, user.ErrNotExist) | ||
|
@@ -135,7 +134,7 @@ func TestService_Create(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, ""). | ||
Return(user.User{}, user.ErrMissingEmail) | ||
|
@@ -188,7 +187,7 @@ func TestService_CreateMetadataKey(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, nil) | ||
|
@@ -223,7 +222,7 @@ func TestService_CreateMetadataKey(t *testing.T) { | |
}, | ||
setup: func(t *testing.T) *user.Service { | ||
t.Helper() | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
activityService := &mocks.ActivityService{} | ||
repository := &mocks.Repository{} | ||
repository.EXPECT(). | ||
|
@@ -280,7 +279,7 @@ func TestService_List(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, nil) | ||
|
@@ -315,7 +314,7 @@ func TestService_List(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, nil) | ||
|
@@ -375,7 +374,7 @@ func TestService_UpdateByID(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, nil) | ||
|
@@ -446,7 +445,7 @@ func TestService_UpdateByEmail(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{}, nil) | ||
|
@@ -511,7 +510,7 @@ func TestService_GetByEmail(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{ | ||
|
@@ -571,7 +570,7 @@ func TestService_GetByID(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByID(mock.Anything, "qwer-1234-tyui-5678-opas-90"). | ||
Return(user.User{ | ||
|
@@ -631,7 +630,7 @@ func TestService_FetchCurrentUser(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository.EXPECT(). | ||
GetByEmail(mock.Anything, "[email protected]"). | ||
Return(user.User{ | ||
|
@@ -657,7 +656,7 @@ func TestService_FetchCurrentUser(t *testing.T) { | |
t.Helper() | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
return user.NewService(logger, user.AppConfig{}, repository, activityService) | ||
}, | ||
wantErr: user.ErrMissingEmail, | ||
|
@@ -702,7 +701,7 @@ func TestService_DeleteUser(t *testing.T) { | |
name: "return error from delete by id", | ||
setup: func(t *testing.T) *user.Service { | ||
t.Helper() | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
repository.EXPECT(). | ||
|
@@ -717,7 +716,7 @@ func TestService_DeleteUser(t *testing.T) { | |
name: "return error from delete by email", | ||
setup: func(t *testing.T) *user.Service { | ||
t.Helper() | ||
logger := shieldlogger.InitLogger(logger.Config{}) | ||
logger := shieldlogger.InitLogger(shieldlogger.Config{}) | ||
repository := &mocks.Repository{} | ||
activityService := &mocks.ActivityService{} | ||
repository.EXPECT(). | ||
|
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