mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
[management] fix extend call and move config to types (#3575)
This PR fixes configuration inconsistencies and updates the store engine type usage throughout the management code. Key changes include: - Replacing outdated server.Config references with types.Config and updating related flag variables (e.g. types.MgmtConfigPath). - Converting engine constants (SqliteStoreEngine, PostgresStoreEngine, MysqlStoreEngine) to use types.Engine for consistent type–safety. - Adjusting various test and migration code paths to correctly reference the new configuration and engine types.
This commit is contained in:
@@ -93,21 +93,21 @@ func getServerKey(client mgmtProto.ManagementServiceClient) (*wgtypes.Key, error
|
||||
|
||||
func Test_SyncProtocol(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
mgmtServer, _, mgmtAddr, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &Config{
|
||||
Stuns: []*Host{{
|
||||
mgmtServer, _, mgmtAddr, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &types.Config{
|
||||
Stuns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "stun:stun.netbird.io:3468",
|
||||
}},
|
||||
TURNConfig: &TURNConfig{
|
||||
TURNConfig: &types.TURNConfig{
|
||||
TimeBasedCredentials: false,
|
||||
CredentialsTTL: util.Duration{},
|
||||
Secret: "whatever",
|
||||
Turns: []*Host{{
|
||||
Turns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "turn:stun.netbird.io:3468",
|
||||
}},
|
||||
},
|
||||
Signal: &Host{
|
||||
Signal: &types.Host{
|
||||
Proto: "http",
|
||||
URI: "signal.netbird.io:10000",
|
||||
},
|
||||
@@ -330,7 +330,7 @@ func TestServer_GetDeviceAuthorizationFlow(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
inputFlow *DeviceAuthorizationFlow
|
||||
inputFlow *types.DeviceAuthorizationFlow
|
||||
expectedFlow *mgmtProto.DeviceAuthorizationFlow
|
||||
expectedErrFunc require.ErrorAssertionFunc
|
||||
expectedErrMSG string
|
||||
@@ -345,9 +345,9 @@ func TestServer_GetDeviceAuthorizationFlow(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Testing Invalid Device Flow Provider Config",
|
||||
inputFlow: &DeviceAuthorizationFlow{
|
||||
inputFlow: &types.DeviceAuthorizationFlow{
|
||||
Provider: "NoNe",
|
||||
ProviderConfig: ProviderConfig{
|
||||
ProviderConfig: types.ProviderConfig{
|
||||
ClientID: "test",
|
||||
},
|
||||
},
|
||||
@@ -356,9 +356,9 @@ func TestServer_GetDeviceAuthorizationFlow(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Testing Full Device Flow Config",
|
||||
inputFlow: &DeviceAuthorizationFlow{
|
||||
inputFlow: &types.DeviceAuthorizationFlow{
|
||||
Provider: "hosted",
|
||||
ProviderConfig: ProviderConfig{
|
||||
ProviderConfig: types.ProviderConfig{
|
||||
ClientID: "test",
|
||||
},
|
||||
},
|
||||
@@ -379,7 +379,7 @@ func TestServer_GetDeviceAuthorizationFlow(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
mgmtServer := &GRPCServer{
|
||||
wgKey: testingServerKey,
|
||||
config: &Config{
|
||||
config: &types.Config{
|
||||
DeviceAuthorizationFlow: testCase.inputFlow,
|
||||
},
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func TestServer_GetDeviceAuthorizationFlow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func startManagementForTest(t *testing.T, testFile string, config *Config) (*grpc.Server, *DefaultAccountManager, string, func(), error) {
|
||||
func startManagementForTest(t *testing.T, testFile string, config *types.Config) (*grpc.Server, *DefaultAccountManager, string, func(), error) {
|
||||
t.Helper()
|
||||
lis, err := net.Listen("tcp", "localhost:0")
|
||||
if err != nil {
|
||||
@@ -506,21 +506,21 @@ func testSyncStatusRace(t *testing.T) {
|
||||
t.Skip()
|
||||
dir := t.TempDir()
|
||||
|
||||
mgmtServer, am, mgmtAddr, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &Config{
|
||||
Stuns: []*Host{{
|
||||
mgmtServer, am, mgmtAddr, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &types.Config{
|
||||
Stuns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "stun:stun.netbird.io:3468",
|
||||
}},
|
||||
TURNConfig: &TURNConfig{
|
||||
TURNConfig: &types.TURNConfig{
|
||||
TimeBasedCredentials: false,
|
||||
CredentialsTTL: util.Duration{},
|
||||
Secret: "whatever",
|
||||
Turns: []*Host{{
|
||||
Turns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "turn:stun.netbird.io:3468",
|
||||
}},
|
||||
},
|
||||
Signal: &Host{
|
||||
Signal: &types.Host{
|
||||
Proto: "http",
|
||||
URI: "signal.netbird.io:10000",
|
||||
},
|
||||
@@ -678,21 +678,21 @@ func Test_LoginPerformance(t *testing.T) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
|
||||
mgmtServer, am, _, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &Config{
|
||||
Stuns: []*Host{{
|
||||
mgmtServer, am, _, cleanup, err := startManagementForTest(t, "testdata/store_with_expired_peers.sql", &types.Config{
|
||||
Stuns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "stun:stun.netbird.io:3468",
|
||||
}},
|
||||
TURNConfig: &TURNConfig{
|
||||
TURNConfig: &types.TURNConfig{
|
||||
TimeBasedCredentials: false,
|
||||
CredentialsTTL: util.Duration{},
|
||||
Secret: "whatever",
|
||||
Turns: []*Host{{
|
||||
Turns: []*types.Host{{
|
||||
Proto: "udp",
|
||||
URI: "turn:stun.netbird.io:3468",
|
||||
}},
|
||||
},
|
||||
Signal: &Host{
|
||||
Signal: &types.Host{
|
||||
Proto: "http",
|
||||
URI: "signal.netbird.io:10000",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user