forked from baron/baron-sso
린트 적용
This commit is contained in:
@@ -13,7 +13,7 @@ type KetoRelayWorker interface {
|
||||
}
|
||||
|
||||
type ketoRelayWorker struct {
|
||||
outboxRepo repository.KetoOutboxRepository
|
||||
outboxRepo repository.KetoOutboxRepository
|
||||
ketoService KetoService
|
||||
interval time.Duration
|
||||
maxRetries int
|
||||
|
||||
@@ -17,9 +17,11 @@ type MockKetoOutboxRepositoryShared struct {
|
||||
func (m *MockKetoOutboxRepositoryShared) Create(ctx context.Context, entry *domain.KetoOutbox) error {
|
||||
return m.Called(ctx, entry).Error(0)
|
||||
}
|
||||
|
||||
func (m *MockKetoOutboxRepositoryShared) CreateWithTx(tx *gorm.DB, entry *domain.KetoOutbox) error {
|
||||
return m.Called(tx, entry).Error(0)
|
||||
}
|
||||
|
||||
func (m *MockKetoOutboxRepositoryShared) FindPending(ctx context.Context, limit int) ([]domain.KetoOutbox, error) {
|
||||
args := m.Called(ctx, limit)
|
||||
if args.Get(0) == nil {
|
||||
@@ -27,9 +29,11 @@ func (m *MockKetoOutboxRepositoryShared) FindPending(ctx context.Context, limit
|
||||
}
|
||||
return args.Get(0).([]domain.KetoOutbox), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockKetoOutboxRepositoryShared) UpdateStatus(ctx context.Context, id string, status string, retryCount int, lastError string) error {
|
||||
return m.Called(ctx, id, status, retryCount, lastError).Error(0)
|
||||
}
|
||||
|
||||
func (m *MockKetoOutboxRepositoryShared) MarkProcessed(ctx context.Context, id string) error {
|
||||
return m.Called(ctx, id).Error(0)
|
||||
}
|
||||
|
||||
@@ -168,17 +168,17 @@ func (s *orgChartService) ensureOrgPath(ctx context.Context, rootTenantID string
|
||||
// In a real implementation, Repo should have a FindByParentAndName method
|
||||
// For this implementation, we'll try to find by Name and ParentID in TenantRepo or UserGroupRepo
|
||||
// Since we're using Polymorphic Tenants, let's assume we can lookup
|
||||
|
||||
|
||||
// For simplicity in this POC, let's just use Create logic if not in cache
|
||||
// In production, we MUST check DB first to avoid duplicates
|
||||
|
||||
|
||||
// [Placeholder] Lookup in DB logic...
|
||||
// existingID = s.lookupOrgUnit(ctx, rootTenantID, currentParentID, part)
|
||||
|
||||
if existingID == "" {
|
||||
// Create new unit
|
||||
unitID := uuid.NewString()
|
||||
|
||||
|
||||
// 1. Create Tenant (Type: USER_GROUP)
|
||||
newTenant := &domain.Tenant{
|
||||
ID: unitID,
|
||||
|
||||
@@ -71,9 +71,9 @@ func (s *tenantService) ListManageableTenants(ctx context.Context, userID string
|
||||
allIDsMap[id] = true
|
||||
}
|
||||
|
||||
// Note: 상속된 권한(부모의 어드민이 자식의 어드민)은 Keto의 OPL에서 처리되므로,
|
||||
// 특정 유저가 'view' 또는 'manage' 권한을 가진 테넌트를 모두 찾으려면
|
||||
// Keto의 'expand' 또는 'list objects' 기능을 더 고도화하거나,
|
||||
// Note: 상속된 권한(부모의 어드민이 자식의 어드민)은 Keto의 OPL에서 처리되므로,
|
||||
// 특정 유저가 'view' 또는 'manage' 권한을 가진 테넌트를 모두 찾으려면
|
||||
// Keto의 'expand' 또는 'list objects' 기능을 더 고도화하거나,
|
||||
// 여기서는 직접 할당된 부모 테넌트를 기준으로 하위 테넌트 정보를 추가 조회하는 로직이 필요할 수 있습니다.
|
||||
// 우선 직접 할당된 테넌트들만 반환합니다.
|
||||
|
||||
|
||||
@@ -103,13 +103,12 @@ func TestTenantService_ApproveTenant_UserNotFound(t *testing.T) {
|
||||
mockRepo.On("Update", ctx, mock.Anything).Return(nil)
|
||||
// User not found in DB
|
||||
mockUserRepo.On("FindByEmail", adminEmail).Return(nil, gorm.ErrRecordNotFound)
|
||||
|
||||
|
||||
// Outbox should not be called since user is not found
|
||||
|
||||
|
||||
err := svc.ApproveTenant(ctx, tenantID)
|
||||
assert.NoError(t, err) // Should succeed but just log that user is not found
|
||||
mockRepo.AssertExpectations(t)
|
||||
mockUserRepo.AssertExpectations(t)
|
||||
mockOutbox.AssertNotCalled(t, "Create")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user