| | |
| | | import org.forgerock.opendj.config.LDAPProfile; |
| | | import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.PropertyDefinitionsOptions; |
| | | import org.forgerock.opendj.config.TestCfg; |
| | | import org.forgerock.opendj.config.TestChildCfgClient; |
| | | import org.forgerock.opendj.config.TestChildCfgDefn; |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | c.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null); |
| | | child.setMandatoryBooleanProperty(true); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | child.commit(); |
| | | |
| | | c.assertEntryIsCreated(); |
| | |
| | | }; |
| | | conn.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance()); |
| | | try { |
| | | TestParentCfgClient parent = createTestParent(ctx, "test parent new"); |
| | | parent.setMandatoryBooleanProperty(true); |
| | | parent.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | parent.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | parent.commit(); |
| | | } catch (Exception e) { |
| | | if (expectedExceptionClass.equals(ErrorResultException.class)) { |
| | |
| | | c.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = createTestParent(ctx, "test parent new"); |
| | | parent.setMandatoryBooleanProperty(true); |
| | | parent.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | parent.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | parent.commit(); |
| | | c.assertEntryIsCreated(); |
| | | } |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.getTestChild("test child 3"); |
| | | Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE); |
| | | Assert.assertEquals(child.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), |
| | | DirectoryServer.getAttributeType("description")); |
| | | getAttributeType("description")); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=default value c3v1,dc=com", |
| | | "dc=default value c3v2,dc=com"); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=default value c3v3,dc=com", |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.getTestChild("test child 1"); |
| | | Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE); |
| | | Assert.assertEquals(child.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), |
| | | DirectoryServer.getAttributeType("description")); |
| | | getAttributeType("description")); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=domain1,dc=com", "dc=domain2,dc=com", |
| | | "dc=domain3,dc=com"); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=domain1,dc=com", "dc=domain2,dc=com", |
| | |
| | | }; |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | try { |
| | | getTestParent(ctx, "test parent 2"); |
| | | } catch (Exception e) { |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 2"); |
| | | Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE); |
| | | Assert.assertEquals(parent.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(), |
| | | DirectoryServer.getAttributeType("description")); |
| | | getAttributeType("description")); |
| | | assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=default value p2v1,dc=com", |
| | | "dc=default value p2v2,dc=com"); |
| | | } |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE); |
| | | Assert.assertEquals(parent.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(), |
| | | DirectoryServer.getAttributeType("description")); |
| | | getAttributeType("description")); |
| | | assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=domain1,dc=com", "dc=domain2,dc=com", |
| | | "dc=domain3,dc=com"); |
| | | } |
| | |
| | | c.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null); |
| | | |
| | |
| | | |
| | | // Check that the default values are not committed. |
| | | child.setMandatoryBooleanProperty(true); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | child.commit(); |
| | | |
| | | c.assertEntryIsCreated(); |
| | |
| | | c.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 2"); |
| | | TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null); |
| | | |
| | |
| | | |
| | | // Check that the default values are not committed. |
| | | child.setMandatoryBooleanProperty(true); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | child.commit(); |
| | | |
| | | c.assertEntryIsCreated(); |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | String[] actual = parent.listTestChildren(); |
| | | String[] expected = new String[] { "test child 1", "test child 2", "test child 3" }; |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 3"); |
| | | String[] actual = parent.listTestChildren(); |
| | | String[] expected = new String[] {}; |
| | |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | String[] actual = listTestParents(ctx); |
| | | String[] expected = new String[] { "test parent 1", "test parent 2", "test parent 3" }; |
| | | Assert.assertEqualsNoOrder(actual, expected); |
| | |
| | | public void testListTopLevelManagedObjectsEmpty() throws Exception { |
| | | MockLDAPConnection c = new MockLDAPConnection(); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | String[] actual = listTestParents(ctx); |
| | | String[] expected = new String[] {}; |
| | | Assert.assertEqualsNoOrder(actual, expected); |
| | |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedModification("ds-cfg-base-dn"); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.getTestChild("test child 2"); |
| | | child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet()); |
| | |
| | | new ModifyEntryMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | parent.commit(); |
| | | Assert.assertFalse(c.isEntryModified()); |
| | |
| | | c.addExpectedModification("ds-cfg-enabled", "false"); |
| | | c.addExpectedModification("ds-cfg-base-dn", "dc=mod1,dc=com", "dc=mod2,dc=com"); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | parent.setMandatoryBooleanProperty(false); |
| | | parent.setOptionalMultiValuedDNProperty(Arrays.asList(DN.valueOf("dc=mod1,dc=com"), |
| | |
| | | "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | parent.removeTestChild("test child 1"); |
| | | c.assertSubtreeIsDeleted(); |
| | |
| | | new DeleteSubtreeMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | removeTestParent(ctx, "test parent 1"); |
| | | c.assertSubtreeIsDeleted(); |
| | | } |
| | |
| | | c.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null); |
| | | child.setMandatoryBooleanProperty(true); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | child.commit(); |
| | | |
| | | c.assertEntryIsCreated(); |
| | |
| | | conn.addExpectedAttribute("ds-cfg-attribute-type", "description"); |
| | | |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null); |
| | | child.setMandatoryBooleanProperty(true); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description")); |
| | | child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description")); |
| | | child.commit(); |
| | | Assert.fail("The add constraint failed to prevent creation of the managed object"); |
| | | } finally { |
| | |
| | | "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | parent.removeTestChild("test child 1"); |
| | | c.assertSubtreeIsDeleted(); |
| | |
| | | "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | parent.removeTestChild("test child 1"); |
| | | Assert.fail("The remove constraint failed to prevent removal of the managed object"); |
| | |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedModification("ds-cfg-base-dn"); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.getTestChild("test child 2"); |
| | | child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet()); |
| | |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedModification("ds-cfg-base-dn"); |
| | | ManagementContext ctx = |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(), |
| | | PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance()); |
| | | TestParentCfgClient parent = getTestParent(ctx, "test parent 1"); |
| | | TestChildCfgClient child = parent.getTestChild("test child 2"); |
| | | child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet()); |
| | |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | | root.removeChild(TestCfg.getTestOneToManyParentRelationDefinition(), name); |
| | | } |
| | | |
| | | private AttributeType getAttributeType(String type) { |
| | | return Schema.getDefaultSchema().getAttributeType(type); |
| | | } |
| | | } |