mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-17 18:41:41 +02:00
@ -29,7 +29,7 @@ func TestDefaultAccountManager_PostureCheck(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("Generic posture check flow", func(t *testing.T) {
|
t.Run("Generic posture check flow", func(t *testing.T) {
|
||||||
// regular users can not create checks
|
// regular users can not create checks
|
||||||
err := am.SavePostureChecks(context.Background(), account.Id, regularUserID, &posture.Checks{})
|
err := am.SavePostureChecks(context.Background(), account.Id, regularUserID, &posture.Checks{}, false)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
// regular users cannot list check
|
// regular users cannot list check
|
||||||
@ -45,7 +45,7 @@ func TestDefaultAccountManager_PostureCheck(t *testing.T) {
|
|||||||
MinVersion: "0.26.0",
|
MinVersion: "0.26.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// admin users can list check
|
// admin users can list check
|
||||||
@ -66,7 +66,7 @@ func TestDefaultAccountManager_PostureCheck(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}, false)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
// admins can update posture checks
|
// admins can update posture checks
|
||||||
@ -78,7 +78,7 @@ func TestDefaultAccountManager_PostureCheck(t *testing.T) {
|
|||||||
MinVersion: "0.27.0",
|
MinVersion: "0.27.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// users should not be able to delete posture checks
|
// users should not be able to delete posture checks
|
||||||
|
@ -1057,14 +1057,18 @@ func (s *SqlStore) GetAccountDNSSettings(ctx context.Context, lockStrength Locki
|
|||||||
|
|
||||||
// AccountExists checks whether an account exists by the given ID.
|
// AccountExists checks whether an account exists by the given ID.
|
||||||
func (s *SqlStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error) {
|
func (s *SqlStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error) {
|
||||||
var count int64
|
var accountID string
|
||||||
|
|
||||||
result := s.db.WithContext(ctx).Clauses(clause.Locking{Strength: string(lockStrength)}).Model(&Account{}).
|
result := s.db.WithContext(ctx).Clauses(clause.Locking{Strength: string(lockStrength)}).Model(&Account{}).
|
||||||
Where(idQueryCondition, id).Count(&count)
|
Select("id").First(&accountID, idQueryCondition, id)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
return false, result.Error
|
return false, result.Error
|
||||||
}
|
}
|
||||||
return count > 0, nil
|
|
||||||
|
return accountID != "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountDomainAndCategory retrieves the Domain and DomainCategory fields for an account based on the given accountID.
|
// GetAccountDomainAndCategory retrieves the Domain and DomainCategory fields for an account based on the given accountID.
|
||||||
|
Reference in New Issue
Block a user