Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 15, 2020
2 parents 88b1142 + a285132 commit dac53f1
Show file tree
Hide file tree
Showing 80 changed files with 8,628 additions and 682 deletions.
Expand Up @@ -160,7 +160,7 @@ private void initLayout() {

}

private LoadableModel<Search> initSearchModel(){
protected LoadableModel<Search> initSearchModel(){
return new LoadableModel<Search>(false) {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -192,7 +192,7 @@ public Search load() {
};
}

private String getSearchByNameParameterValue() {
protected String getSearchByNameParameterValue() {
PageParameters parameters = getPageBase().getPageParameters();
if (parameters == null) {
return null;
Expand Down Expand Up @@ -628,7 +628,7 @@ protected String getStorageKey(){
return key;
}

private PageStorage getPageStorage(String storageKey){
protected PageStorage getPageStorage(String storageKey){
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(storageKey);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(storageKey);
Expand Down
Expand Up @@ -6,14 +6,12 @@
*/
package com.evolveum.midpoint.web.page.admin.resources;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.*;

import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.PendingOperationPanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand All @@ -22,10 +20,13 @@
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem;
import com.evolveum.midpoint.web.component.search.SearchItem;
import com.evolveum.midpoint.web.component.search.SearchValue;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.page.admin.server.PageTask;
import com.evolveum.midpoint.web.page.admin.server.PageTasks;
import com.evolveum.midpoint.web.security.util.SecurityUtils;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -294,6 +295,41 @@ protected ObjectQuery createContentQuery() {
return queryFactory.createQuery(queryFactory.createAnd(filters));
}

@Override
protected LoadableModel<Search> initSearchModel() {
return new LoadableModel<Search>(false) {

private static final long serialVersionUID = 1L;

@Override
public Search load() {
String storageKey = getStorageKey();
Search search = null;
if (org.apache.commons.lang3.StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
search = storage.getSearch();
}
}
Search newSearch = createSearch();
if (search == null
|| !search.getAvailableDefinitions().containsAll(newSearch.getAvailableDefinitions())) {
search = newSearch;
}

String searchByName = getSearchByNameParameterValue();
if (searchByName != null) {
for (SearchItem item : search.getItems()) {
if (ItemPath.create(ObjectType.F_NAME).equivalent(item.getPath())) {
item.setValues(Collections.singletonList(new SearchValue(searchByName)));
}
}
}
return search;
}
};
}

@Override
protected Search createSearch() {
return ResourceContentPanel.this.createSearch();
Expand Down
10 changes: 2 additions & 8 deletions infra/prism-impl/pom.xml
Expand Up @@ -48,14 +48,8 @@
<artifactId>jaxb-xjc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
Expand Up @@ -13,7 +13,7 @@
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.cxf.wsdl.WSDLConstants;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

Expand All @@ -29,6 +29,12 @@ class SchemaDescriptionParser {

private static final Trace LOGGER = TraceManager.getTrace(SchemaDescription.class);

public static final String NS_WSDL11 = "http://schemas.xmlsoap.org/wsdl/";

public static final QName QNAME_DEFINITIONS = new QName(NS_WSDL11, "definitions");

public static final QName QNAME_TYPES = new QName(NS_WSDL11, "types");

static SchemaDescriptionImpl parseResource(String resourcePath) throws SchemaException {
SchemaDescriptionImpl desc = new SchemaDescriptionImpl("system resource " + resourcePath, resourcePath);
desc.setStreamable(() -> {
Expand Down Expand Up @@ -57,8 +63,8 @@ static List<SchemaDescriptionImpl> parseWsdlResource(String resourcePath) throws
}
Element rootElement = node instanceof Element ? (Element) node : DOMUtil.getFirstChildElement(node);
QName rootElementQName = DOMUtil.getQName(rootElement);
if (WSDLConstants.QNAME_DEFINITIONS.equals(rootElementQName)) {
Element types = DOMUtil.getChildElement(rootElement, WSDLConstants.QNAME_TYPES);
if (QNAME_DEFINITIONS.equals(rootElementQName)) {
Element types = DOMUtil.getChildElement(rootElement, QNAME_TYPES);
if (types == null) {
LOGGER.warn("No <types> section in WSDL document in system resource " + resourcePath);
return schemaDescriptions;
Expand Down
Expand Up @@ -7,14 +7,7 @@

package com.evolveum.midpoint.model.common.stringpolicy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;

import com.evolveum.midpoint.prism.MutablePrismPropertyDefinition;
Expand Down Expand Up @@ -96,6 +89,7 @@ public class ValuePolicyProcessor {
private static final Trace LOGGER = TraceManager.getTrace(ValuePolicyProcessor.class);

private static final Random RAND = new Random(System.currentTimeMillis());
private static final String ALPHANUMERIC_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

private static final String DOT_CLASS = ValuePolicyProcessor.class.getName() + ".";
private static final String OPERATION_STRING_POLICY_VALIDATION = DOT_CLASS + "stringPolicyValidation";
Expand Down Expand Up @@ -596,6 +590,17 @@ private String generateAttempt(ValuePolicyType policy, int defaultLength, boolea

boolean uniquenessReached = false;

//fake limit with all alphanumeric character, because of number of unique char
if(lims.isEmpty()){
StringLimitType fakeLimit = new StringLimitType();
CharacterClassType charClass = new CharacterClassType();
charClass.setValue(ALPHANUMERIC_CHARS);
fakeLimit.setCharacterClass(charClass);
fakeLimit.setMustBeFirst(false);
fakeLimit.setMaxOccurs(maxLen);
fakeLimit.setMinOccurs(minLen);
lims.put(fakeLimit, StringPolicyUtils.stringTokenizer(ALPHANUMERIC_CHARS));
}
// Count cardinality of elements
Map<Integer, List<String>> chars;
for (int i = 0; i < minLen; i++) {
Expand Down
Expand Up @@ -159,6 +159,27 @@ public void testValueGenerateRandomPin() throws Exception {

}

@Test
public void testValueGenerateMailNonce() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();

ValuePolicyType pp = parsePasswordPolicy("value-policy-generate-without-limit-with-unique.xml");

// WHEN
when();
String mailNonce = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 24, false, null, getTestNameShort(), task, result);

// THEN
then();
displayValue("Generated password", mailNonce);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(mailNonce);
assertPassword(mailNonce, pp);

}

@Test
public void testValueGenerate() throws Exception {
Task task = getTestTask();
Expand Down
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<valuePolicy xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
oid="81818181-76e0-59e2-8888-3d4f02d3fffb"
version="10">
<name>
<orig xmlns="http://prism.evolveum.com/xml/ns/public/types-3">Numeric PIN Policy</orig>
<norm xmlns="http://prism.evolveum.com/xml/ns/public/types-3">numeric pin policy</norm>
</name>
<description>A policy useful for generating long password without limit, but with more unique characters.</description>
<c:stringPolicy xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3"
xmlns:apti="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:enc="http://www.w3.org/2001/04/xmlenc#">
<c:description>String validation policy</c:description>
<c:limitations>
<c:minLength>30</c:minLength>
<c:minUniqueChars>29</c:minUniqueChars>
<c:checkPattern/>
</c:limitations>
</c:stringPolicy>
</valuePolicy>
Expand Up @@ -15,6 +15,12 @@

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.testng.BrowserPerClass;

import com.evolveum.midpoint.schrodinger.component.AssignmentsTab;

import com.evolveum.midpoint.schrodinger.component.common.table.AbstractTableWithPrismView;
import com.evolveum.midpoint.schrodinger.page.AssignmentHolderDetailsPage;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -56,17 +62,17 @@ public abstract class AbstractSchrodingerTest extends AbstractIntegrationTest {

protected static final String CSV_RESOURCE_ATTR_UNIQUE = "Unique attribute name";

private static final String SCHRODINGER_PROPERTIES = "./src/test/resources/configuration/schrodinger.properties";
protected static final String SCHRODINGER_PROPERTIES = "./src/test/resources/configuration/schrodinger.properties";

private static final Logger LOG = LoggerFactory.getLogger(AbstractSchrodingerTest.class);

protected static File csvTargetDir;

private EnvironmentConfiguration configuration;
protected EnvironmentConfiguration configuration;

private String username;
protected String username;

private String password;
protected String password;

protected MidPoint midPoint;

Expand Down Expand Up @@ -105,7 +111,7 @@ public void beforeClass() throws IOException {
basicPage = login.loginIfUserIsNotLog(username, password);
}

private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) {
protected EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) {
EnvironmentConfiguration config = new EnvironmentConfiguration();
config.driver(WebDriver.valueOf(props.getProperty("webdriver")));

Expand Down Expand Up @@ -246,8 +252,8 @@ public void changeResourceAttribute(String resourceName, String attributeName, S
ResourceConfigurationTab resourceConfigurationTab = viewResourcePage
.clickEditResourceConfiguration();
Selenide.screenshot("afterEditConfigurationClick");
Selenide.sleep(60000);
Selenide.screenshot("afterMinuteSleep");
Selenide.sleep(MidPoint.TIMEOUT_MEDIUM_6_S);
Selenide.screenshot("afterSixSecondsSleep");

Assert.assertTrue(resourceConfigurationTab
.form()
Expand Down Expand Up @@ -278,5 +284,4 @@ public void changeResourceAttribute(String resourceName, String attributeName, S
}

}

}

0 comments on commit dac53f1

Please sign in to comment.