forked from baron/baron-sso
chore: snapshot local state before dev merge
This commit is contained in:
@@ -53,7 +53,11 @@ func (m *MockTenantRepoForSvc) FindByDomain(ctx context.Context, domainName stri
|
||||
}
|
||||
|
||||
func (m *MockTenantRepoForSvc) FindByIDs(ctx context.Context, ids []string) ([]domain.Tenant, error) {
|
||||
return nil, nil
|
||||
args := m.Called(ctx, ids)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).([]domain.Tenant), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockTenantRepoForSvc) AddDomain(ctx context.Context, tenantID string, domainName string, verified bool) error {
|
||||
@@ -343,3 +347,29 @@ func TestTenantService_ListTenants(t *testing.T) {
|
||||
assert.Equal(t, tenants, result)
|
||||
mockRepo.AssertExpectations(t)
|
||||
}
|
||||
|
||||
func TestTenantService_ListJoinedTenants_UsesOnlyMemberRelations(t *testing.T) {
|
||||
mockRepo := new(MockTenantRepoForSvc)
|
||||
mockKeto := new(MockKetoSvcForTenant)
|
||||
svc := NewTenantService(mockRepo, nil, nil, nil)
|
||||
svc.SetKetoService(mockKeto)
|
||||
ctx := context.Background()
|
||||
userID := "user-uuid"
|
||||
memberTenant := domain.Tenant{ID: "tenant-member", Slug: "actual-member"}
|
||||
|
||||
mockKeto.On("ListObjects", ctx, "Tenant", "members", "User:"+userID).
|
||||
Return([]string{memberTenant.ID}, nil).
|
||||
Once()
|
||||
mockRepo.On("FindByIDs", ctx, []string{memberTenant.ID}).
|
||||
Return([]domain.Tenant{memberTenant}, nil).
|
||||
Once()
|
||||
|
||||
result, err := svc.ListJoinedTenants(ctx, userID)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []domain.Tenant{memberTenant}, result)
|
||||
mockKeto.AssertNotCalled(t, "ListObjects", ctx, "Tenant", "owners", "User:"+userID)
|
||||
mockKeto.AssertNotCalled(t, "ListObjects", ctx, "Tenant", "admins", "User:"+userID)
|
||||
mockKeto.AssertExpectations(t)
|
||||
mockRepo.AssertExpectations(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user