| | |
| | | * |
| | | * |
| | | * Copyright 2006-2011 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that the binary option is automatically added to modifications if it |
| | | * is missing and required. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "baseDNs") |
| | | public void testAddCertificateWithoutBinaryOption(String baseDN) |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.clearJEBackend(true,"userRoot",baseDN); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user," + baseDN, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "displayName: Test User", |
| | | "userPassword: password", |
| | | "mail: foo", |
| | | "employeeNumber: 1"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("2468")); |
| | | LDAPAttribute attr = new LDAPAttribute("usercertificate", values); |
| | | ArrayList<RawModification> mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.ADD, attr)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf("uid=test.user," + baseDN), |
| | | mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.decode("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("usercertificate", |
| | | true)); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | Attribute a = attrList.get(0); |
| | | assertTrue(a.hasOption("binary")); |
| | | assertEquals(a.size(), 1); |
| | | assertEquals(a.iterator().next().getValue().toString(), "2468"); |
| | | } |
| | | |
| | | } |
| | | |