mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 23:11:29 +02:00
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
rpservice "github.com/netbirdio/netbird/management/internals/modules/reverseproxy/service"
|
|
)
|
|
|
|
func TestSqlStore_GetAccount_PrivateServiceRoundtrip(t *testing.T) {
|
|
if (os.Getenv("CI") == "true" && runtime.GOOS == "darwin") || runtime.GOOS == "windows" {
|
|
t.Skip("skip CI tests on darwin and windows")
|
|
}
|
|
|
|
runTestForAllEngines(t, "", func(t *testing.T, store Store) {
|
|
ctx := context.Background()
|
|
account := newAccountWithId(ctx, "account_private_svc", "testuser", "")
|
|
require.NoError(t, store.SaveAccount(ctx, account))
|
|
|
|
svc := &rpservice.Service{
|
|
ID: "svc-private",
|
|
AccountID: account.Id,
|
|
Name: "private-svc",
|
|
Domain: "private.example",
|
|
ProxyCluster: "cluster.example",
|
|
Enabled: true,
|
|
Mode: rpservice.ModeHTTP,
|
|
Private: true,
|
|
AccessGroups: []string{"grp-admins", "grp-ops"},
|
|
}
|
|
require.NoError(t, store.CreateService(ctx, svc))
|
|
|
|
loaded, err := store.GetAccount(ctx, account.Id)
|
|
require.NoError(t, err)
|
|
require.Len(t, loaded.Services, 1)
|
|
|
|
got := loaded.Services[0]
|
|
assert.True(t, got.Private)
|
|
assert.Equal(t, []string{"grp-admins", "grp-ops"}, got.AccessGroups)
|
|
})
|
|
}
|