diff --git a/client/android/profile_manager.go b/client/android/profile_manager.go index e7c58c723..00c9cbde8 100644 --- a/client/android/profile_manager.go +++ b/client/android/profile_manager.go @@ -213,10 +213,10 @@ func (pm *ProfileManager) getProfileConfigPath(id string) (string, error) { return filepath.Join(profilesDir, id+".json"), nil } -// GetConfigPath returns the config file path for a given profile +// GetConfigPath returns the config file path for a given profile id // Java should call this instead of constructing paths with Preferences.configFile() -func (pm *ProfileManager) GetConfigPath(profileName string) (string, error) { - return pm.getProfileConfigPath(profileName) +func (pm *ProfileManager) GetConfigPath(id string) (string, error) { + return pm.getProfileConfigPath(id) } // GetStateFilePath returns the state file path for a given profile diff --git a/client/cmd/login.go b/client/cmd/login.go index 4d5d8da54..fa0eb546a 100644 --- a/client/cmd/login.go +++ b/client/cmd/login.go @@ -171,7 +171,7 @@ func getActiveProfile(ctx context.Context, pm *profilemanager.ProfileManager, pr } func switchProfileOnDaemon(ctx context.Context, pm *profilemanager.ProfileManager, handle string, username string) error { - resolvedID, err := switchProfile(context.Background(), handle, username) + resolvedID, err := switchProfile(ctx, handle, username) if err != nil { return fmt.Errorf("switch profile on daemon: %v", err) } diff --git a/client/internal/debug/debug_test.go b/client/internal/debug/debug_test.go index 39b972244..196a1da2b 100644 --- a/client/internal/debug/debug_test.go +++ b/client/internal/debug/debug_test.go @@ -843,6 +843,7 @@ func TestAddConfig_AllFieldsCovered(t *testing.T) { "PreSharedKey": "sensitive: WireGuard pre-shared key", "SSHKey": "sensitive: SSH private key", "ClientCertKeyPair": "non-config: parsed cert pair, not serialized", + "Name": "non-config: profile name is not needed for debug purposes", } mURL, _ := url.Parse("https://api.example.com:443") diff --git a/client/internal/profilemanager/service.go b/client/internal/profilemanager/service.go index d7da191cf..268f87b2b 100644 --- a/client/internal/profilemanager/service.go +++ b/client/internal/profilemanager/service.go @@ -442,7 +442,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) { ID: defaultProfileName, Name: defaultProfileName, Path: DefaultConfigPath, - IsActive: activeIsDefault || activeID == defaultProfileName, + IsActive: activeIsDefault, }} configDir, err := s.getConfigDir(username) @@ -487,7 +487,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) { ID: stem, Name: name, Path: path, - IsActive: stem == activeID && !activeIsDefault, + IsActive: stem == activeID, }) } diff --git a/client/internal/profilemanager/service_test.go b/client/internal/profilemanager/service_test.go index 60fea7c3e..98fac31e0 100644 --- a/client/internal/profilemanager/service_test.go +++ b/client/internal/profilemanager/service_test.go @@ -131,16 +131,6 @@ func TestServiceProfile_LegacyFilenameCoexists(t *testing.T) { }) } -func TestAddProfile_RejectsDuplicateNameByDefault(t *testing.T) { - withTestSM(t, func(sm *ServiceManager, username string) { - _, err := sm.AddProfile("work", username) - require.NoError(t, err) - - _, err = sm.AddProfile("work", username) - assert.ErrorIs(t, err, ErrProfileAlreadyExists) - }) -} - func TestAddProfile_AllowsDuplicateWithFlag(t *testing.T) { withTestSM(t, func(sm *ServiceManager, username string) { first, err := sm.AddProfile("work", username) diff --git a/client/ui/client_ui.go b/client/ui/client_ui.go index d7cb31a0c..1a451070b 100644 --- a/client/ui/client_ui.go +++ b/client/ui/client_ui.go @@ -493,7 +493,7 @@ func (s *serviceClient) getConnectionForm() *widget.Form { if err != nil { log.Errorf("get active profile: %v", err) } else { - activeProfName = activeProf.ID + activeProfName = activeProf.Name } return &widget.Form{ Items: []*widget.FormItem{