mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 16:49:08 +02:00
[client] Name the two config readers for what they do
ReadConfig and GetConfig differed in one thing — what happens when the file is absent — and neither name said which was which: - ReadConfig -> ReadOrGenerateConfig (reads it, or generates one in memory) - GetConfig -> GetExistingConfig (reads it, or fails) Three comments went with them: - GetConfig's said "return with Config and if it was created. Errors out if it does not exist", which described a bool it does not return and a creation it never performs. - ReadConfig's explained that it does not write, which is what a reader is supposed to do anyway. - Server.getConfig's said it "errors out if it does not exist", which it does not — it resolves a default config, and now provisions the identity too.
This commit is contained in:
@@ -64,7 +64,7 @@ func TestSetConfig_ChangingASettingIsRefused(t *testing.T) {
|
||||
require.Error(t, err, "moving the management URL is a settings change")
|
||||
require.Equal(t, codes.Unavailable, gstatus.Code(err), "want the update-settings refusal, got %v", err)
|
||||
|
||||
cfg, err := profilemanager.GetConfig(cfgPath)
|
||||
cfg, err := profilemanager.GetExistingConfig(cfgPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, storedManagementURL, cfg.ManagementURL.String(), "the refused request changed the config anyway")
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func TestSetConfig_ChangeAllowedWhenTheSwitchIsOff(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg, err := profilemanager.GetConfig(cfgPath)
|
||||
cfg, err := profilemanager.GetExistingConfig(cfgPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "https://mgmt.elsewhere.example:443", cfg.ManagementURL.String())
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func seedProfileConfig(t *testing.T, managementURL, preSharedKey string) string
|
||||
// keeps a re-login, or a container restart carrying NB_MANAGEMENT_URL, working
|
||||
// with the kill switch on.
|
||||
func TestLoginGateDecision(t *testing.T) {
|
||||
stored, err := profilemanager.GetConfig(seedProfileConfig(t, storedManagementURL, "stored-key"))
|
||||
stored, err := profilemanager.GetExistingConfig(seedProfileConfig(t, storedManagementURL, "stored-key"))
|
||||
require.NoError(t, err)
|
||||
|
||||
redacted := preSharedKeyRedactedSentinel
|
||||
@@ -336,7 +336,7 @@ func TestLogin_ChangeThatAppearsMidRequestIsRefused(t *testing.T) {
|
||||
require.Equal(t, codes.Unavailable, gstatus.Code(err), "want the update-settings refusal, got %v", err)
|
||||
require.False(t, cancelled, "the refused login cancelled the login already in progress")
|
||||
|
||||
stored, err := profilemanager.GetConfig(targetPath)
|
||||
stored, err := profilemanager.GetExistingConfig(targetPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "https://mgmt.elsewhere.example:443", stored.ManagementURL.String(),
|
||||
"the refused login wrote the management URL it was asked for")
|
||||
|
||||
Reference in New Issue
Block a user