Skip to content

Commit 4e820c9

Browse files
committed
Add test cases to AuthorizedKeysCertificateTest
See [1]. Apache MINA SSHD never had that problem, but we also had no test for this. So add one just to be sure. [1] https://bugzilla.mindrot.org/show_bug.cgi?id=3950
1 parent a85a3b1 commit 4e820c9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

sshd-core/src/test/java/org/apache/sshd/server/auth/AuthorizedKeysCertificateTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ private static Stream<Arguments> options() {
114114
Arguments.of("cert-authority", "", false, false), // CA, no principal: fail
115115
Arguments.of("cert-authority", "other", false, false), // CA, wrong principal: fail
116116
Arguments.of("cert-authority,principals=\"other\"", "user", false, false), // CA, principal overridden
117-
Arguments.of("cert-authority,principals=\"other\"", "other", false, true) // CA, principal overridden
117+
Arguments.of("cert-authority,principals=\"other\"", "other", false, true), // CA, principal overridden
118+
Arguments.of("cert-authority,principals=\"other,user\"", "user", false, true), //
119+
// One principal "root,user" in the certificate
120+
Arguments.of("cert-authority,principals=\"other,user\"", "root,user", false, false), //
121+
// Two principals "root" and "user" in the certificate
122+
Arguments.of("cert-authority,principals=\"other,user\"", "root;user", false, true), //
123+
Arguments.of("cert-authority,principals=\"user,other\"", "root;user", false, true) //
118124
);
119125
}
120126

@@ -151,7 +157,7 @@ private void initCert(String caMarker, String... principals) throws Exception {
151157
@MethodSource("options")
152158
void testCertificate(String marker, String principals, boolean allowEmpty, boolean expectSuccess) throws Exception {
153159
CoreModuleProperties.ALLOW_EMPTY_CERTIFICATE_PRINCIPALS.set(sshd, allowEmpty);
154-
String[] certPrincipals = GenericUtils.isEmpty(principals) ? new String[0] : principals.split(",");
160+
String[] certPrincipals = GenericUtils.isEmpty(principals) ? new String[0] : principals.split(";");
155161
initCert(marker, certPrincipals);
156162
try (ClientSession s = client.connect("user", TEST_LOCALHOST, port).verify(CONNECT_TIMEOUT)
157163
.getSession()) {

0 commit comments

Comments
 (0)