/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS
*/
/**
* This class defines a set of test cases for testing the binary transfer option
* functionality across different protocol versions of LDAP.
*/
/** Exported LDIF file. */
/** LDIFExportConfig used for exporting entries. */
/** LDIFImportConfig used for importing entries. */
/** Test Backend. */
/** Constant value of userCertificate attribute. */
"MIIB5TCCAU6gAwIBAgIERloIajANBgkqhkiG9" +
"w0BAQUFADA3MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRXhhbXBs" +
"ZSBDb3JwMREwDwYDVQQDEwhKb2huIERvZTAeFw0wNzA1MjcyMjM4" +
"MzRaFw0wNzA4MjUyMjM4MzRaMDcxCzAJBgNVBAYTAlVTMRUwEwYD" +
"VQQKEwxFeGFtcGxlIENvcnAxETAPBgNVBAMTCEpvaG4gRG9lMIGfMA" +
"0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWNZB4qs1UvjYgvGvB" +
"9udmiUi4X4DeaSm3o0p8PSwpOFxSqgWdSwKgUugZ1EJVyYoakljDFs" +
"J0GVown+dIB24V4ozNs6wa0YotIKTV2AcySQkmzzP3e+OnE9Aa1wlB/" +
"PVnh1CFLgk1UOoruLE10bac5HA8QiAmfNMorU26AwFTcwIDAQABMA" +
"0GCSqGSIb3DQEBBQUAA4GBAGrzMKNbBRWn+LIfYTfqKYUc258XVbhFri" +
"1OV0oF82vyvciYWZzyxLc52EPDsymLmcDh+CdWxy3bVkjdMg1WEtMGr" +
"RvNfqemCf7o3+Cp00OmF5ey";
/**
* Ensures that the Directory Server is running before executing the
* testcases.
*
* @throws Exception If an unexpected problem occurs.
*/
public void startServer()
throws Exception
{
}
/**
* Test to verify an ADD of the binary attributes using a V3
* protocol.
* @throws Exception If an unexpected problem occurs.
*/
@Test
{
//Add a binary attribute both with or without the binary option.
"dn: uid=user.1,o=test",
"objectClass: inetOrgPerson",
"uid: user.1",
"sn: 1",
"cn: user 1",
"userCertificate:: "+CERT
);
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-a",
"-f", filePath
};
//ADD with ;binary option.
"dn: uid=user.2,o=test",
"objectClass: inetOrgPerson",
"uid: user.2",
"sn: 2",
"cn: user 2",
"userCertificate;binary:: "+CERT
);
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-a",
"-f", filePath
};
}
/**
* Test to verify an ADD of a non-binary attribute with the ;binary
* transfer option using a V3 protocol.
* @throws Exception If an unexpected problem occurs.
*/
@Test
{
"dn: uid=user.3,o=test",
"objectClass: inetOrgPerson",
"uid: user.3",
"sn: 3",
"cn: user 3",
"cn;binary: common name"
);
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-a",
"-f", filePath,
};
}
/**
* Test to verify a SEARCH using the ;binary transfer option using a V3
* protocol.
* @throws Exception If an unexpected problem occurs.
*/
"LDAPBinaryOptionTestCase.binaryAttributeAddV3"})
{
assertNotNull(e);
assertNotNull(a);
}
/**
* Test to verify a SEARCH using the ;binary transfer option using a V3
* protocol for a non-binary attribute.
* @throws Exception If an unexpected problem occurs.
*/
"LDAPBinaryOptionTestCase.binaryAttributeAddV3"})
{
.addAttribute("cn;binary");
assertNotNull(e);
}
/**
* Test to verify an ADD and SEARCH using the ;binary transfer option using a
* V2 protocol.
* @throws Exception If an unexpected problem occurs.
*/
@Test
{
//Construct a V2 connection.
try
{
w.writeMessage(message);
message = r.readMessage();
addAttrs);
w.writeMessage(message);
message = r.readMessage();
//Create a SEARCH request to search for this added entry.
//Request only the interesting attributes.
0, false,
attrs);
w.writeMessage(message);
while (searchResultDone == null)
{
message = r.readMessage();
switch (message.getProtocolOpType())
{
break;
break;
}
}
boolean certWithNoOption = false;
boolean snWithMultiVal = false;
{
//Shouldn't be userCertificate;binary.
{
certWithNoOption=true;
}
{
for (ByteString v : a.getValues())
{
}
}
}
}
finally
{
StaticUtils.close(r, w);
StaticUtils.close(s);
}
}
/**
* Test to verify that the DB stores the binary option by
* exporting the LDIF and searching for the binary keyword.
* @throws Exception If an unexpected problem occurs.
*/
"LDAPBinaryOptionTestCase.binaryAttributeAddV3"})
{
//Ensure that the entry exists.
{
"--noPropertiesFile",
"-h", "127.0.0.1",
"-b", "o=test",
"(uid=user.1)"
};
}
/**
* Test to verify that the server adds the binary option by
* importing an LDIF both with or without the binary option.
* @throws Exception If an unexpected problem occurs.
*/
"LDAPBinaryOptionTestCase.exportAndValidateBinaryAttribute"})
{
//This testcase uses the exported ldif in exportAndValidBinaryAttribute
//testcase. It imports the ldif after cleaning up the database and verifies
//that the binary option is present in the binary attributes. After that, it
//modifies the binary option from the ldif and re-imports it.A re-export of
//the last import should have the binary option even though it wasn't
//there in the imported ldif.
importLDIF();
//Remove the binary option and re-import it.
{
{
}
else
{
}
}
importLDIF();
//Re-export it.
}
/**
* Test to verify a MODIFY using the ;binary transfer option using V3
* protocol.
* @throws Exception If an unexpected problem occurs.
*/
@Test
{
"dn: uid=user.4,o=test",
"objectClass: inetOrgPerson",
"uid: user.4",
"sn: 4",
"cn: user 4"
);
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-a",
"-f", filePath,
};
"dn: uid=user.4,o=test",
"changetype: modify",
"add: usercertificate;binary",
"userCertificate;binary:: " + CERT);
{
"-h", "127.0.0.1",
"-D","cn=directory manager",
"-w","password",
"-f", filePath,
};
}
/**
* Utility method to verify if the LDIF file contains binary option.
* @return {@code true} if binary option is found in the LDIF
* , or {@code false} if not.
* @throws Exception If an unexpected problem occurs.
*/
{
boolean found=false;
{
{
found = true;
}
}
return found;
}
/**
* Utility method to export the database into an LDIF file.
* @throws Exception If an unexpected problem occurs.
*/
{
//Initialize necessary instance variables.
{
}
}
/**
* Utility method to import the LDIF into the database.
* @throws Exception If an unexpected problem occurs.
*/
{
TestCaseUtils.initializeTestBackend(false);
}
}