SubjectAttributeToUserAttributeCertificateMapperTestCase.java:
Extracted methods getKeyStorePath(), getTrustStorePath()
Used varargs instead of array parameter.
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.SubjectAttributeToUserAttributeCertificateMapperCfgDefn; |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | |
| | | try |
| | | { |
| | | setAttributeMappings(new String[] { "cn:cn", "1.2.840.113549.1.9.1:mail" }); |
| | | setAttributeMappings("cn:cn", "1.2.840.113549.1.9.1:mail"); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | |
| | | "cn: Test User", |
| | | "mail: test@example.com"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client-emailAddress.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client-emailAddress.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | setAttributeMappings("cn:cn", "emailAddress:mail"); |
| | | } |
| | | } |
| | | |
| | |
| | | "cn: Test User", |
| | | "mail: test@example.com"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client-emailAddress.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client-emailAddress.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | } |
| | | } |
| | | |
| | | private String getKeyStorePath(String fileName) |
| | | { |
| | | return DirectoryServer.getInstanceRoot() + File.separator + "config" + File.separator + fileName; |
| | | } |
| | | |
| | | private String getTrustStorePath() |
| | | { |
| | | return DirectoryServer.getInstanceRoot() + File.separator + "config" + File.separator + "client.truststore"; |
| | | } |
| | | |
| | | /** |
| | | * Tests a successful mapping with multiple attributes. |
| | |
| | | |
| | | try |
| | | { |
| | | setAttributeMappings(new String[] { "cn:cn", "o:o" }); |
| | | setAttributeMappings("cn:cn", "o:o"); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | |
| | | "cn: Test User", |
| | | "o: test"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | setAttributeMappings("cn:cn", "emailAddress:mail"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | setAttributeMappings(new String[] { "emailAddress:mail" }); |
| | | setAttributeMappings("emailAddress:mail"); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | |
| | | "cn: Test User", |
| | | "o: test"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | setAttributeMappings("cn:cn", "emailAddress:mail"); |
| | | } |
| | | } |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Not Test User"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | |
| | | try |
| | | { |
| | | setBaseDNs(new String[] { "dc=example,dc=com" }); |
| | | setBaseDNs("dc=example,dc=com"); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntries( |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetMappingNoColon() |
| | | throws Exception |
| | | public void testSetMappingNoColon() throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { "nocolon" }); |
| | | setAttributeMappings("nocolon"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSetMappingNoCertAttribute() |
| | | throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { ":cn" }); |
| | | setAttributeMappings(":cn"); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetMappingNoUserAttribute() |
| | | throws Exception |
| | | public void testSetMappingNoUserAttribute() throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { "cn:" }); |
| | | setAttributeMappings("cn:"); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetMappingUndefinedUserAttribute() |
| | | throws Exception |
| | | public void testSetMappingUndefinedUserAttribute() throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { "cn:undefined" }); |
| | | setAttributeMappings("cn:undefined"); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetMappingDuplicateCertAttribute() |
| | | throws Exception |
| | | public void testSetMappingDuplicateCertAttribute() throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { "cn:cn", "cn:sn" }); |
| | | setAttributeMappings("cn:cn", "cn:sn"); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetMappingDuplicateUserAttribute() |
| | | throws Exception |
| | | public void testSetMappingDuplicateUserAttribute() throws Exception |
| | | { |
| | | setAttributeMappings(new String[] { "cn:cn", "e:cn" }); |
| | | setAttributeMappings("cn:cn", "e:cn"); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { AssertionError.class }) |
| | | public void testSetInvalidBaseDN() |
| | | throws Exception |
| | | public void testSetInvalidBaseDN() throws Exception |
| | | { |
| | | setBaseDNs(new String[] { "invalid" }); |
| | | setBaseDNs("invalid"); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | private void setAttributeMappings(String[] mappings) |
| | | throws Exception |
| | | private void setAttributeMappings(String... mappings) throws Exception |
| | | { |
| | | String mapperDN = "cn=Subject Attribute to User Attribute," + |
| | | "cn=Certificate Mappers,cn=config"; |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | private void setBaseDNs(String[] baseDNs) throws Exception |
| | | private void setBaseDNs(String... baseDNs) throws Exception |
| | | { |
| | | String mapperDN = "cn=Subject Attribute to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | |
| | |
| | | "cn: Test User", |
| | | "ds-privilege-name: config-read"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-b", "cn=config", |
| | | "-s", "sub", |