Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Dec 13, 2018
2 parents c51ec36 + 86003d8 commit cec364f
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 95 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -11,7 +11,7 @@ cache:
before_install:
- choco install maven
- RefreshEnv.cmd
- export MAVEN_OPTS='-Xmx6g -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
- export MAVEN_OPTS='-Xmx6g'
- export JAVA_HOME=`find "/c/Program Files/Java" -name jdk1.8.*`

addons:
Expand All @@ -24,6 +24,6 @@ env:
matrix:
include:
- name: JDK8 - Run all excluding model-intest
script: mvn install -B -DskipTests; mvn verify -DskipModelIntTest=true -DskipModelUnitTest=true
script: mvn install -T 1C -q -DskipTests; mvn verify -DskipModelIntTest=true -DskipModelUnitTest=true -Dfailsafe.rerunFailingTestsCount=2
- name: JDK8 - Run only model-intest
script: mvn install -B -DskipTests; mvn verify -pl :model-intest
script: mvn install -T 1C -q -DskipTests; mvn verify -pl :model-intest -Dfailsafe.rerunFailingTestsCount=2
124 changes: 62 additions & 62 deletions gui/admin-gui/src/main/resources/localization/Midpoint_cs.properties

Large diffs are not rendered by default.

Expand Up @@ -3857,7 +3857,7 @@ AssignmentConflictPanel.undoAction=Cofnij
PageAssignmentConflicts.title=Konflikty przypisań
PageAssignmentConflicts.back=Wstecz
PageAssignmentConflicts.submit=Prześlij
PageAssignmentsList.conflictsWarning=Unable to calculate assignment conflicts due to authorization problem. Reason:
PageAssignmentsList.conflictsWarning=Nie można obliczyć konfliktów przypisać z powodu problemu z autoryzacją. Powód:
AbstractShoppingCartTabPanel.addAllButton=Dodaj wszystko
AbstractShoppingCartTabPanel.requestingForLabel=Wnioskuj dla
AbstractShoppingCartTabPanel.availableRelationsLabel=Dostępne relacje
Expand Down
Expand Up @@ -275,7 +275,7 @@ FileConfigurationType.name=Název
SouborConfigurationType.file=Soubor
FullTextSearchConfigurationType.enabled=Povolený
FullTextSearchConfigurationType.indexed=Indexovaný
FullTextSearchIndexedItemsConfigurationType.details=Full text search indexed items
FullTextSearchIndexedItemsConfigurationType.details=Fulltextové prohledávání indexovaných položek
FullTextSearchIndexedItemsConfigurationType.objectType=Typ objektu
FullTextSearchIndexedPoložkasConfigurationType.item=Položka
FocusType.activation=Aktivace
Expand Down
Expand Up @@ -23,6 +23,7 @@

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.QNameUtil;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class CompiledObjectCollectionView implements DebugDumpable, Serializable
private DistinctSearchOptionType distinct;
private Boolean disableSorting;
private SearchBoxConfigurationType searchBoxConfiguration;
private ObjectFilter filter;

// Only used to construct "default" view definition. May be not needed later on.
public CompiledObjectCollectionView() {
Expand Down Expand Up @@ -141,6 +143,14 @@ public void setSearchBoxConfiguration(SearchBoxConfigurationType searchBoxConfig
this.searchBoxConfiguration = searchBoxConfiguration;
}

public ObjectFilter getFilter() {
return filter;
}

public void setFilter(ObjectFilter filter) {
this.filter = filter;
}

public boolean match(QName expectedObjectType, String expectedViewName) {
if (!QNameUtil.match(objectType, expectedObjectType)) {
return false;
Expand Down Expand Up @@ -176,7 +186,7 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelToStringLn(sb, "distinct", distinct, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "disableSorting", disableSorting, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "searchBoxConfiguration", searchBoxConfiguration, indent + 1);
// TODO
DebugUtil.debugDumpWithLabel(sb, "filter", filter, indent + 1);
return sb.toString();
}

Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.PlusMinusZero;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.util.ItemDeltaItem;
import com.evolveum.midpoint.prism.util.ObjectDeltaObject;
import com.evolveum.midpoint.repo.api.RepositoryService;
Expand All @@ -76,6 +77,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractObjectTypeConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationRoleManagementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CollectionSpecificationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardWidgetType;
Expand All @@ -92,6 +95,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFormsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchBoxConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
Expand Down Expand Up @@ -455,8 +459,22 @@ private void compileCollection(CompiledObjectCollectionView existingView, GuiObj
if (existingView.getCollection() != null) {
LOGGER.debug("Redefining collection in view {}", existingView.getViewName());
}
// TODO: resolve collection, apply filter
existingView.setCollection(collection);

// Compute and apply filter
ObjectReferenceType collectionRef = collection.getCollectionRef();
QName collectionRefType = collectionRef.getType();
ObjectFilter filter = null;

// TODO: support more cases
if (QNameUtil.match(ArchetypeType.COMPLEX_TYPE, collectionRefType)) {
filter = prismContext.queryFor(AssignmentHolderType.class)
.item(AssignmentHolderType.F_ARCHETYPE_REF).ref(collectionRef.getOid())
.buildFilter();
}

// TODO: resolve (read) collection if needed
existingView.setFilter(filter);
}

private void compileColumns(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
Expand Down Expand Up @@ -505,8 +523,6 @@ private void compileSearchBox(CompiledObjectCollectionView existingView, GuiObje
existingView.setSearchBoxConfiguration(newSearchBoxConfig);
}



private void joinForms(ObjectFormsType objectForms, ObjectFormType newForm) {
objectForms.getObjectForm().removeIf(currentForm -> isTheSameObjectForm(currentForm, newForm));
objectForms.getObjectForm().add(newForm.clone());
Expand Down
Expand Up @@ -24,17 +24,23 @@
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.SearchResultList;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.security.api.MidPointPrincipal;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RichHyperlinkType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
Expand All @@ -50,6 +56,7 @@ public class TestArchetypes extends AbstractInitializedModelIntegrationTest {
public static final File TEST_DIR = new File("src/test/resources/archetypes");

public static final File SYSTEM_CONFIGURATION_ARCHETYPES_FILE = new File(TEST_DIR, "system-configuration-archetypes.xml");
public static final String VIEW_ALL_EMPLOYEES_NAME = "All employees";

public static final File ARCHETYPE_EMPLOYEE_FILE = new File(TEST_DIR, "archetype-employee.xml");
protected static final String ARCHETYPE_EMPLOYEE_OID = "7135e68c-ee53-11e8-8025-170b77da3fd6";
Expand All @@ -61,13 +68,17 @@ public class TestArchetypes extends AbstractInitializedModelIntegrationTest {

public static final File ROLE_EMPLOYEE_BASE_FILE = new File(TEST_DIR, "role-employee-base.xml");
protected static final String ROLE_EMPLOYEE_BASE_OID = "e869d6c4-f6ef-11e8-b51f-df3e51bba129";

public static final File ROLE_USER_ADMINISTRATOR_FILE = new File(TEST_DIR, "role-user-administrator.xml");
protected static final String ROLE_USER_ADMINISTRATOR_OID = "6ae02e34-f8b0-11e8-9c40-87e142b606fe";

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

repoAddObjectFromFile(ROLE_EMPLOYEE_BASE_FILE, initResult);
repoAddObjectFromFile(ARCHETYPE_TEST_FILE, initResult);
repoAddObjectFromFile(ROLE_USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ARCHETYPE_EMPLOYEE_FILE, initResult);

addObject(SHADOW_GROUP_DUMMY_TESTERS_FILE, initTask, initResult);
}
Expand All @@ -78,23 +89,42 @@ protected File getSystemConfigurationFile() {
}

@Test
public void test050AddArchetypeEmployee() throws Exception {
final String TEST_NAME = "test050SetupJack";
public void test050AddArchetypeTest() throws Exception {
final String TEST_NAME = "test050AddArchetypeTest";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
addObject(ARCHETYPE_EMPLOYEE_FILE, task, result);
addObject(ARCHETYPE_TEST_FILE, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

PrismObject<ArchetypeType> archetypeEmployee = modelService.getObject(ArchetypeType.class, ARCHETYPE_EMPLOYEE_OID, null, task, result);
display("Archetype employee", archetypeEmployee);
PrismObject<ArchetypeType> archetypeTest = modelService.getObject(ArchetypeType.class, ARCHETYPE_TEST_OID, null, task, result);
display("Archetype test", archetypeTest);
}

@Test
public void test060AssignGuybrushUserAdministrator() throws Exception {
final String TEST_NAME = "test060AssignGuybrushUserAdministrator";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
assignRole(USER_GUYBRUSH_OID, ROLE_USER_ADMINISTRATOR_OID, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

// TODO: assert guybrush
}


Expand Down Expand Up @@ -134,11 +164,93 @@ public void test100AssignJackArchetypeEmployee() throws Exception {
.assertPluralLabel(ARCHETYPE_EMPLOYEE_DISPLAY_PLURAL_LABEL);
}

@Test
public void test102SearchEmployeeArchetypeRef() throws Exception {
final String TEST_NAME = "test102SearchEmployeeArchetypeRef";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

ObjectQuery query = queryFor(UserType.class)
.item(UserType.F_ARCHETYPE_REF).ref(ARCHETYPE_EMPLOYEE_OID)
.build();

// WHEN
displayWhen(TEST_NAME);

SearchResultList<PrismObject<UserType>> searchResults = modelService.searchObjects(UserType.class, query, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("Search results", searchResults);
assertEquals("Wrong number of search results", 1, searchResults.size());
PrismObject<UserType> foundUser = searchResults.get(0);
assertUser(foundUser, "found user")
.assertName(USER_JACK_USERNAME)
.assertOid(USER_JACK_OID)
.assignments()
.assertAssignments(1)
.assertArchetype(ARCHETYPE_EMPLOYEE_OID)
.end()
.assertArchetypeRef(ARCHETYPE_EMPLOYEE_OID)
.roleMembershipRefs()
.assertRoleMemberhipRefs(1)
.assertArchetype(ARCHETYPE_EMPLOYEE_OID)
.end()
.getObject();
}

@Test
public void test104GetGuybryshCompiledUserProfile() throws Exception {
final String TEST_NAME = "test104GetGuybryshCompiledUserProfile";
displayTestTitle(TEST_NAME);

// GIVEN
login(USER_GUYBRUSH_USERNAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
CompiledUserProfile compiledUserProfile = modelInteractionService.getCompiledUserProfile(task, result);

// THEN
assertSuccess(result);

loginAdministrator();

ObjectFilter viewFilter = assertCompiledUserProfile(compiledUserProfile)
.assertAdditionalMenuLinks(0)
.assertUserDashboardLinks(0)
.assertObjectForms(0)
.assertUserDashboardWidgets(0)
.objectCollectionViews()
.single()
.assertName(VIEW_ALL_EMPLOYEES_NAME)
.assertFilter()
.getFilter();

ObjectQuery viewQuery = prismContext.queryFactory().createQuery(viewFilter, null);
SearchResultList<PrismObject<UserType>> searchResults = modelService.searchObjects(UserType.class, viewQuery, null, task, result);

display("Search results", searchResults);
assertEquals("Wrong number of search results", 1, searchResults.size());
PrismObject<UserType> foundUser = searchResults.get(0);
assertUser(foundUser, "found user")
.assertName(USER_JACK_USERNAME)
.assertOid(USER_JACK_OID);

}

@Test
public void test109UnassignJackArchetypeEmployee() throws Exception {
final String TEST_NAME = "test109UnassignJackArchetypeEmployee";
displayTestTitle(TEST_NAME);

loginAdministrator();

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Expand Down Expand Up @@ -274,19 +386,17 @@ public void test129UnassignJackArchetypeTest() throws Exception {
assertSuccess(result);

assertUserAfter(USER_JACK_OID)
.assignments()
.assertAssignments(0)
.end()
.assertNoArchetypeRef()
.roleMembershipRefs()
.assertRoleMemberhipRefs(0)
.end()
.links()
.assertNone();
.assignments()
.assertAssignments(0)
.end()
.assertNoArchetypeRef()
.roleMembershipRefs()
.assertRoleMemberhipRefs(0)
.end()
.links()
.assertNone();
}

// TODO: search by archetypeRef

// TODO: object template in archetype
// TODO: correct application of object template for new object (not yet stored)

Expand Down
Expand Up @@ -411,8 +411,8 @@ private void assertAddAccount(ModelContext<UserType> modelContext, boolean expec
}

@Test
public void test130GetAdminGuiConfig() throws Exception {
final String TEST_NAME = "test130GetAdminGuiConfig";
public void test130GetCompiledUserProfile() throws Exception {
final String TEST_NAME = "test130GetCompiledUserProfile";
displayTestTitle(TEST_NAME);

// GIVEN
Expand Down

0 comments on commit cec364f

Please sign in to comment.