Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
691 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 109 additions & 104 deletions
213
.../midpoint/testing/story/TestFlatLdap.java → ...ting/story/AbstractLdapHierarchyTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLdapFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2016 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.testing.story; | ||
|
||
|
||
import static org.testng.AssertJUnit.assertNotNull; | ||
|
||
import java.io.File; | ||
|
||
import org.opends.server.types.DirectoryException; | ||
import org.opends.server.types.Entry; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.annotation.DirtiesContext.ClassMode; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.test.util.MidPointTestConstants; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.exception.CommunicationException; | ||
import com.evolveum.midpoint.util.exception.ConfigurationException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.util.exception.SecurityViolationException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
|
||
/** | ||
* Flat LDAP structure. All accounts in ou=people. The organizational structure is | ||
* reflected to (non-nested) LDAP groups. Users are members of the groups to reflect | ||
* the orgstruct. | ||
* | ||
* @author Radovan Semancik | ||
* | ||
*/ | ||
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) | ||
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) | ||
public class TestLdapFlat extends AbstractLdapHierarchyTest { | ||
|
||
public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "flat-ldap"); | ||
|
||
@Override | ||
public void initSystem(Task initTask, OperationResult initResult) throws Exception { | ||
super.initSystem(initTask, initResult); | ||
} | ||
|
||
@Override | ||
protected File getTestDir() { | ||
return TEST_DIR; | ||
} | ||
|
||
@Override | ||
protected PrismObject<UserType> getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { | ||
PrismObject<UserType> user = super.getAndAssertUser(username, directOrgGroupname, indirectGroupNames); | ||
Entry accountEntry = openDJController.searchSingle("uid="+username); | ||
|
||
Entry groupEntry = openDJController.searchSingle("cn="+directOrgGroupname); | ||
assertNotNull("No group LDAP entry for "+directOrgGroupname, groupEntry); | ||
openDJController.assertUniqueMember(groupEntry, accountEntry.getDN().toString()); | ||
|
||
if (indirectGroupNames != null) { | ||
for (String expectedGroupName: indirectGroupNames) { | ||
groupEntry = openDJController.searchSingle("cn="+expectedGroupName); | ||
assertNotNull("No group LDAP entry for "+expectedGroupName, groupEntry); | ||
openDJController.assertUniqueMember(groupEntry, accountEntry.getDN().toString()); | ||
} | ||
} | ||
|
||
return user; | ||
} | ||
|
||
} |
92 changes: 92 additions & 0 deletions
92
testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLdapNested.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2016 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.testing.story; | ||
|
||
|
||
import static org.testng.AssertJUnit.assertNotNull; | ||
|
||
import java.io.File; | ||
|
||
import org.opends.server.types.DirectoryException; | ||
import org.opends.server.types.Entry; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.annotation.DirtiesContext.ClassMode; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.test.util.MidPointTestConstants; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.exception.CommunicationException; | ||
import com.evolveum.midpoint.util.exception.ConfigurationException; | ||
import com.evolveum.midpoint.util.exception.ObjectNotFoundException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.util.exception.SecurityViolationException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
|
||
/** | ||
* Semi-flat LDAP structure. All accounts in ou=people. The organizational structure is | ||
* reflected to nested LDAP groups. Users are members of the groups to reflect | ||
* their direct membership in orgstruct. Group are member of other groups to reflect | ||
* the org tree. Not there is no structure of OUs. | ||
* | ||
* @author Radovan Semancik | ||
* | ||
*/ | ||
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) | ||
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) | ||
public class TestLdapNested extends AbstractLdapHierarchyTest { | ||
|
||
public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "nested-ldap"); | ||
|
||
@Override | ||
public void initSystem(Task initTask, OperationResult initResult) throws Exception { | ||
super.initSystem(initTask, initResult); | ||
} | ||
|
||
@Override | ||
protected File getTestDir() { | ||
return TEST_DIR; | ||
} | ||
|
||
@Override | ||
protected PrismObject<UserType> getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { | ||
PrismObject<UserType> user = super.getAndAssertUser(username, directOrgGroupname, indirectGroupNames); | ||
Entry accountEntry = openDJController.searchSingle("uid="+username); | ||
|
||
Entry groupEntry = openDJController.searchSingle("cn="+directOrgGroupname); | ||
assertNotNull("No group LDAP entry for "+directOrgGroupname, groupEntry); | ||
openDJController.assertUniqueMember(groupEntry, accountEntry.getDN().toString()); | ||
|
||
return user; | ||
} | ||
|
||
@Override | ||
protected PrismObject<OrgType> getAndAssertFunctionalOrg(String orgName, String directParentOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { | ||
PrismObject<OrgType> org = super.getAndAssertFunctionalOrg(orgName, directParentOrgOid); | ||
if (directParentOrgOid != null && !ORG_TOP_OID.equals(directParentOrgOid)) { | ||
Entry groupEntry = openDJController.searchSingle("cn="+orgName); | ||
PrismObject<OrgType> parentOrg = getObject(OrgType.class, directParentOrgOid); | ||
Entry parentGroupEntry = openDJController.searchSingle("cn="+parentOrg.getName()); | ||
assertNotNull("No group LDAP entry for "+parentOrg.getName(), parentGroupEntry); | ||
openDJController.assertUniqueMember(parentGroupEntry, groupEntry.getDN().toString()); | ||
} | ||
return org; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2015 Evolveum | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<org oid="00000000-8888-6666-0000-100000000001" | ||
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3' | ||
xmlns:org='http://midpoint.evolveum.com/xml/ns/public/common/org-3'> | ||
<name>TOP</name> | ||
<displayName>Top</displayName> | ||
<identifier>0000</identifier> | ||
<orgType>functional</orgType> | ||
</org> |
Oops, something went wrong.