Skip to content

Commit

Permalink
adding schrodinger tests for labs of demo 101 and resolving some bugs…
Browse files Browse the repository at this point in the history
… from testing
  • Loading branch information
skublik committed Apr 14, 2020
1 parent 776c1b4 commit 085144f
Show file tree
Hide file tree
Showing 75 changed files with 8,595 additions and 669 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
@@ -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,0 +1,150 @@
/*
* 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.
*/
package com.evolveum.midpoint.testing.schrodinger.labs;

import com.codeborne.selenide.Selenide;

import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.assignmentholder.AssignmentHolderObjectListTable;
import com.evolveum.midpoint.schrodinger.component.resource.ResourceAccountsTab;
import com.evolveum.midpoint.schrodinger.component.resource.ResourceShadowTable;
import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage;
import com.evolveum.midpoint.schrodinger.page.resource.AccountPage;
import com.evolveum.midpoint.schrodinger.page.resource.ViewResourcePage;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;
import com.evolveum.midpoint.testing.schrodinger.AbstractSchrodingerTest;
import com.evolveum.midpoint.testing.schrodinger.scenarios.SynchronizationTests;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;

import java.io.File;
import java.util.Arrays;
import java.util.List;

/**
* @author skublik
*/

public class AbstractLabTest extends AbstractSchrodingerTest {

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

protected static final String LAB_DIRECTORY = "./src/test/resources/labs/";
protected static final String LAB_OBJECTS_DIRECTORY = LAB_DIRECTORY + "objects/";
protected static final String LAB_SOURCES_DIRECTORY = LAB_DIRECTORY + "sources/";

protected static final File EXTENSION_SCHEMA_FILE = new File(LAB_DIRECTORY +"schema/extension-example.xsd");
protected static final File CSV_1_SIMPLE_RESOURCE_FILE = new File(LAB_OBJECTS_DIRECTORY + "resources/localhost-csvfile-1-document-access-simple.xml");
protected static final File CSV_1_RESOURCE_FILE = new File(LAB_OBJECTS_DIRECTORY + "resources/localhost-csvfile-1-document-access.xml");
protected static final File CSV_1_SOURCE_FILE = new File(LAB_SOURCES_DIRECTORY + "csv-1.csv");
protected static final File NUMERIC_PIN_FIRST_NONZERO_POLICY_FILE = new File(LAB_OBJECTS_DIRECTORY + "valuePolicies/numeric-pin-first-nonzero-policy.xml");
protected static final File CSV_2_RESOURCE_FILE = new File(LAB_OBJECTS_DIRECTORY + "resources/localhost-csvfile-2-canteen.xml");
protected static final File CSV_2_SOURCE_FILE = new File(LAB_SOURCES_DIRECTORY + "csv-2.csv");
protected static final File CSV_3_RESOURCE_FILE = new File(LAB_OBJECTS_DIRECTORY + "resources/localhost-csvfile-3-ldap.xml");
protected static final File CSV_3_SOURCE_FILE = new File(LAB_SOURCES_DIRECTORY + "csv-3.csv");

protected static final String DIRECTORY_CURRENT_TEST = "labTests";
protected static final String EXTENSION_SCHEMA_NAME = "extension-example.xsd";
protected static final String CSV_1_FILE_SOURCE_NAME = "csv-1.csv";
protected static final String CSV_1_RESOURCE_NAME = "CSV-1 (Document Access)";
protected static final String CSV_2_FILE_SOURCE_NAME = "csv-2.csv";
protected static final String CSV_2_RESOURCE_NAME = "CSV-2 (Canteen Ordering System)";
protected static final String CSV_3_FILE_SOURCE_NAME = "csv-3.csv";
protected static final String CSV_3_RESOURCE_NAME = "CSV-3 (LDAP)";

protected static final String PASSWORD_ATTRIBUTE_RESOURCE_KEY = "User password attribute name";
protected static final String UNIQUE_ATTRIBUTE_RESOURCE_KEY = "Unique attribute name";

protected static final String CSV_1_UNIQUE_ATTRIBUTE_NAME = "login";
protected static final String CSV_1_PASSWORD_ATTRIBUTE_NAME = "password";
protected static final String CSV_1_ACCOUNT_OBJECT_CLASS_LINK = "AccountObjectClass (Default Account)";

protected static final List<String> CSV_1_RESOURCE_ATTRIBUTES = Arrays.asList("login", "lname", "groups", "enumber", "phone", "dep", "fname", "dis");

protected static File csv1TargetFile;
protected static File csv2TargetFile;
protected static File csv3TargetFile;

@AfterClass
@Override
public void afterClass() {
LOG.info("Finished tests from class {}", getClass().getName());

Selenide.clearBrowserCookies();
Selenide.clearBrowserLocalStorage();
Selenide.close();
}

public UserPage showUser(String userName){
UserPage user = showUserInTable(userName).clickByName(userName);
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
return user;
}

public AssignmentHolderObjectListTable<ListUsersPage, UserPage> showUserInTable(String userName) {
return basicPage.listUsers()
.table()
.search()
.byName()
.inputValue(userName)
.updateSearch()
.and();
}

public AccountPage showShadow(String resourceName, String searchedItem, String itemValue){
return showShadow(resourceName, searchedItem, itemValue, null, false);
}

public AccountPage showShadow(String resourceName, String searchedItem, String itemValue, String intent, boolean useRepository){
return getShadowTable(resourceName, searchedItem, itemValue, intent, useRepository)
.clickByName(itemValue);
}

public boolean existShadow(String resourceName, String searchedItem, String itemValue){
return existShadow(resourceName, searchedItem, itemValue, null, false);
}

public boolean existShadow(String resourceName, String searchedItem, String itemValue, String intent, boolean useRepository){
ResourceShadowTable table = getShadowTable(resourceName, searchedItem, itemValue, intent, useRepository);
return table.containsText(itemValue);
}
public ResourceShadowTable getShadowTable(String resourceName, String searchedItem, String itemValue) {
return getShadowTable(resourceName, searchedItem, itemValue, null, false);
}

public ResourceShadowTable getShadowTable(String resourceName, String searchedItem, String itemValue, String intent, boolean useRepository) {
ResourceAccountsTab<ViewResourcePage> tab = basicPage.listResources()
.table()
.search()
.byName()
.inputValue(resourceName)
.updateSearch()
.and()
.clickByName(resourceName)
.clickAccountsTab();
if (useRepository) {
tab.clickSearchInRepository();
} else {
tab.clickSearchInResource();
}
Selenide.sleep(1000);
if (intent != null && !intent.isBlank()) {
tab.setIntent(intent);
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
}
return tab.table()
.search()
.resetBasicSearch()
.byItem(searchedItem)
.inputValueWithEnter(itemValue)
.and()
.and();
}
}

0 comments on commit 085144f

Please sign in to comment.