Fix mRemoteNG import failing on entries without a username

The previous username relaxation only touched ProfileDialog's own
save-time validation. ProfileRepository::isProfileValid() had the
identical "username required for SSH/RDP" check independently, called
directly by insertProfile()/updateProfile() -- exactly the path
mRemoteNG import uses, since it builds Profile objects and inserts
them directly rather than going through the dialog. Every imported
SSH/RDP entry without a recorded username was rejected outright.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 08:17:05 -06:00
co-authored by Claude Sonnet 5
parent 7aa8849f8e
commit ab4a34fc01
3 changed files with 18 additions and 10 deletions
+9 -3
View File
@@ -48,7 +48,7 @@ private slots:
void createProfileRejectsMissingName();
void createProfileRejectsMissingHost();
void createProfileRejectsInvalidPort();
void createProfileRejectsMissingUsernameForSsh();
void createProfileAllowsMissingUsernameForSsh();
void createProfileRejectsMissingPrivateKeyForKeyAuth();
void createProfileRejectsDuplicateName();
void updateProfilePersistsChanges();
@@ -156,11 +156,17 @@ void TestProfileRepository::createProfileRejectsInvalidPort()
QVERIFY(!m_repo->createProfile(profile).has_value());
}
void TestProfileRepository::createProfileRejectsMissingUsernameForSsh()
void TestProfileRepository::createProfileAllowsMissingUsernameForSsh()
{
// SSH/RDP no longer require a username at save time (issue #21) --
// among other things, this unblocks importing mRemoteNG entries that
// don't have one recorded, which used to fail outright. The user is
// asked for it at connect time instead (see SessionTab).
Profile profile = makeSshProfile();
profile.username.clear();
QVERIFY(!m_repo->createProfile(profile).has_value());
const auto created = m_repo->createProfile(profile);
QVERIFY(created.has_value());
QVERIFY(created->username.isEmpty());
}
void TestProfileRepository::createProfileRejectsMissingPrivateKeyForKeyAuth()