| | |
| | | import org.opends.server.admin.AdminTestCase; |
| | | import org.opends.server.admin.Constraint; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.LDAPProfile; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.MockLDAPProfile; |
| | | import org.opends.server.admin.TestCfg; |
| | | import org.opends.server.admin.TestChildCfgClient; |
| | | import org.opends.server.admin.TestChildCfgDefn; |
| | |
| | | // optional-multi-valued-dn-property. |
| | | "dn: cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-parent-dummy", |
| | | "cn: test parent 1", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property. |
| | | "dn: cn=test parent 2,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-parent-dummy", |
| | | "cn: test parent 2", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property. |
| | | "dn: cn=test parent 3,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-parent-dummy", |
| | | "cn: test parent 3", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property2. |
| | | "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-child-dummy", |
| | | "cn: test child 1", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property2. |
| | | "dn: cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-child-dummy", |
| | | "cn: test child 2", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property2. |
| | | "dn: cn=test child 3,cn=test children,cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-child-dummy", |
| | | "cn: test child 3", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property2. |
| | | "dn: cn=test child 1,cn=test children,cn=test parent 2,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-child-dummy", |
| | | "cn: test child 1", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | | "ds-cfg-virtual-attribute-type: description", |
| | | "" |
| | | "", |
| | | }; |
| | | |
| | | |
| | |
| | | // This test suite depends on having the schema available, so |
| | | // we'll start the server. |
| | | TestCaseUtils.startServer(); |
| | | LDAPProfile.getInstance().pushWrapper(new MockLDAPProfile()); |
| | | TestCfg.setUp(); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @AfterClass |
| | | public void tearDown() { |
| | | LDAPProfile.getInstance().popWrapper(); |
| | | TestCfg.cleanup(); |
| | | } |
| | | |
| | |
| | | "cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test child new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-child-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | "cn=test parent new,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test parent new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-parent-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | "dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), |
| | | "dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"); |
| | | Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE); |
| | | } |
| | | |
| | | |
| | |
| | | "cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test child new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-child-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | "cn=test child new,cn=test children,cn=test parent 2,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test child new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-child-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | @Test |
| | | public void testAddConstraintSuccess() throws Exception { |
| | | Constraint constraint = new MockConstraint(true, false, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection( |
| | | "cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test child new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-child-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | c.assertEntryIsCreated(); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test(expectedExceptions=OperationRejectedException.class) |
| | | public void testAddConstraintFail() throws Exception { |
| | | Constraint constraint = new MockConstraint(false, true, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection( |
| | | "cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config"); |
| | | c.importLDIF(TEST_LDIF); |
| | | c.addExpectedAttribute("cn", "test child new"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-virtual-attribute"); |
| | | c.addExpectedAttribute("objectclass", "top", "ds-cfg-test-child-dummy"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-enabled", "true"); |
| | | c.addExpectedAttribute("ds-cfg-virtual-attribute-class", |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | |
| | | Assert.fail("The add constraint failed to prevent creation of the managed object"); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testRemoveConstraintSuccess() throws Exception { |
| | | Constraint constraint = new MockConstraint(false, false, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection( |
| | |
| | | c.assertSubtreeIsDeleted(); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test(expectedExceptions=OperationRejectedException.class) |
| | | public void testRemoveConstraintFail() throws Exception { |
| | | Constraint constraint = new MockConstraint(true, true, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection( |
| | |
| | | Assert.fail("The remove constraint failed to prevent removal of the managed object"); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testModifyConstraintSuccess() throws Exception { |
| | | Constraint constraint = new MockConstraint(false, true, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection( |
| | |
| | | Assert.assertTrue(c.isEntryModified()); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test(expectedExceptions = OperationRejectedException.class) |
| | | public void testModifyConstraintFail() throws Exception { |
| | | Constraint constraint = new MockConstraint(true, false, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection( |
| | |
| | | .fail("The modify constraint failed to prevent modification of the managed object"); |
| | | } finally { |
| | | // Clean up. |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | } |
| | | } |
| | | |