mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
Fix setup keys
This commit is contained in:
@@ -163,7 +163,10 @@ func (s *SqliteStore) SaveAccount(account *Account) error {
|
||||
// operate over a fresh copy as we will modify its fields
|
||||
accCopy := account.Copy()
|
||||
accCopy.SetupKeysG = make([]SetupKey, 0, len(accCopy.SetupKeys))
|
||||
for _, key := range accCopy.SetupKeys {
|
||||
for id, key := range accCopy.SetupKeys {
|
||||
key.Id = id
|
||||
//we need an explicit reference to the account as it is missing for some reason
|
||||
key.AccountID = accCopy.Id
|
||||
accCopy.SetupKeysG = append(accCopy.SetupKeysG, *key)
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ func TestSqlite_SaveAccount_Large(t *testing.T) {
|
||||
SearchDomainsEnabled: false,
|
||||
}
|
||||
account.NameServerGroups[nameserver.ID] = nameserver
|
||||
|
||||
setupKey := GenerateDefaultSetupKey()
|
||||
account.SetupKeys[setupKey.Id] = setupKey
|
||||
}
|
||||
|
||||
err = store.SaveAccount(account)
|
||||
@@ -153,6 +156,18 @@ func TestSqlite_SaveAccount_Large(t *testing.T) {
|
||||
numPerAccount, len(a.NameServerGroups))
|
||||
return
|
||||
}
|
||||
|
||||
if a != nil && len(a.NameServerGroups) != numPerAccount {
|
||||
t.Errorf("expecting Account to have %d NameServerGroups stored after SaveAccount(), got %d",
|
||||
numPerAccount, len(a.NameServerGroups))
|
||||
return
|
||||
}
|
||||
|
||||
if a != nil && len(a.SetupKeys) != numPerAccount+1 {
|
||||
t.Errorf("expecting Account to have %d SetupKeys stored after SaveAccount(), got %d",
|
||||
numPerAccount+1, len(a.SetupKeys))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestSqlite_SaveAccount(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user