Skip to content

Commit

Permalink
fix for schrodinger tests of labs 101 (MOD10, MOD110
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Apr 30, 2020
1 parent 36316f4 commit c772cfc
Show file tree
Hide file tree
Showing 13 changed files with 1,815 additions and 1,078 deletions.

Large diffs are not rendered by default.

Expand Up @@ -210,6 +210,10 @@ protected String fetchMidpointHome() {
}

protected File initTestDirectory(String dir) throws IOException {
return initTestDirectory(dir, true);
}

protected File initTestDirectory(String dir, boolean clearExist) throws IOException {

String home = fetchMidpointHome();
File parentDir = new File(home, "schrodinger");
Expand All @@ -221,8 +225,9 @@ protected File initTestDirectory(String dir) throws IOException {
return testTargetDir;
} else {
if (testTargetDir.exists()) {

FileUtils.cleanDirectory(testTargetDir);
if (clearExist) {
FileUtils.cleanDirectory(testTargetDir);
}
return testTargetDir;
} else {

Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.testng.annotations.AfterClass;

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

Expand Down Expand Up @@ -91,7 +92,7 @@ public class AbstractLabTest extends AbstractSchrodingerTest {
protected static File csv2TargetFile;
protected static File csv3TargetFile;
protected static File hrTargetFile;
protected static File notificationFile = new File("./target/notification.txt");
protected static File notificationFile;

@AfterClass
@Override
Expand All @@ -103,6 +104,13 @@ public void afterClass() {
Selenide.close();
}

protected File getTestTargetDir() throws IOException {
if (testTargetDir == null) {
initTestDirectory(DIRECTORY_CURRENT_TEST, false);
}
return testTargetDir;
}

public UserPage showUser(String userName){
UserPage user = showUserInTable(userName).clickByName(userName);
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
Expand Down
Expand Up @@ -229,6 +229,9 @@ public void mod10test04FinishingManagerMapping() {
rootTab.getMemberPanel()
.selectType("User")
.table()
.search()
.resetBasicSearch()
.and()
.clickByName("X000158");
Assert.assertTrue(new UserPage().selectTabProjections()
.table()
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.File;
Expand Down Expand Up @@ -61,7 +62,9 @@ public void afterClass() {

@Test(groups={"M11"}, dependsOnGroups={"M10"})
public void mod11test01ConfiguringNotifications() throws IOException {
notificationFile = new File(testTargetDir, NOTIFICATION_FILE_NAME);
showTask("HR Synchronization").clickResume();

notificationFile = new File(getTestTargetDir(), NOTIFICATION_FILE_NAME);
notificationFile.createNewFile();

importObject(SYSTEM_CONFIGURATION_FILE_11_1, true);
Expand Down
@@ -0,0 +1,99 @@
/*
* 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.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage;

import com.evolveum.midpoint.schrodinger.page.login.FormLoginPage;

import com.evolveum.midpoint.schrodinger.page.self.ProfilePage;
import com.evolveum.midpoint.schrodinger.util.Utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.xml.namespace.QName;
import java.io.File;
import java.io.IOException;

/**
* @author skublik
*/

public class M12Authorizations extends AbstractLabTest{

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

private static final File ROLE_BASIC_USER_FILE = new File(LAB_OBJECTS_DIRECTORY + "roles/role-basic-user.xml");
private static final File ROLE_BASIC_USER_FILE_12_1 = new File(LAB_OBJECTS_DIRECTORY + "roles/role-basic-user-12-1.xml");

// @AfterClass
// @Override
// public void afterClass() {
// super.afterClass();
//
// midPoint.formLogin().loginWithReloadLoginPage(username, password);
//
// LOG.info("After: Login name " + username + " pass " + password);
//
// AboutPage aboutPage = basicPage.aboutPage();
// aboutPage
// .clickSwitchToFactoryDefaults()
// .clickYes();
// }

@Test(groups={"M12"}, dependsOnGroups={"M11"})
public void mod12test01BasicUserAuthorization() {
importObject(ROLE_BASIC_USER_FILE, true);
showUser("X000005").selectTabBasic()
.form()
.setPasswordFieldsValues(new QName(SchemaConstantsGenerated.NS_COMMON, "value"), "qwerty12345XXXX")
.and()
.and()
.clickSave()
.feedback()
.isSuccess();

basicPage.loggedUser().logoutIfUserIsLogin();
FormLoginPage login = midPoint.formLogin();
login.login("X000005", "qwerty12345XXXX")
.feedback()
.isError();

login.login(getUsername(), getPassword());

Utils.addAsignments(showUser("X000005").selectTabAssignments(), "Basic user");

basicPage.loggedUser().logoutIfUserIsLogin();
login.login("X000005", "qwerty12345XXXX");

ProfilePage profile = basicPage.profile();
Assert.assertTrue(profile.selectTabProjections()
.table()
.containsLinksTextPartially("")); //TODO projections names

Assert.assertTrue(profile.selectTabAssignments()
.table()
.containsLinksTextPartially("Basic user", "")); //TODO roles names

basicPage.credentials(); //TODO implement credentials page

basicPage.loggedUser().logoutIfUserIsLogin();
login.login(getUsername(), getPassword());

importObject(ROLE_BASIC_USER_FILE_12_1, true);

basicPage.loggedUser().logoutIfUserIsLogin();
login.login("X000005", "qwerty12345ZZZZ");

}
}
Expand Up @@ -50,9 +50,7 @@ public void beforeClass() throws IOException {

@Test(groups={"M3"})
public void mod03test01ViewingResources() throws Exception {
initTestDirectory(DIRECTORY_CURRENT_TEST);

csv1TargetFile = new File(testTargetDir, CSV_1_FILE_SOURCE_NAME);
csv1TargetFile = new File(getTestTargetDir(), CSV_1_FILE_SOURCE_NAME);
FileUtils.copyFile(CSV_1_SOURCE_FILE, csv1TargetFile);

importObject(CSV_1_SIMPLE_RESOURCE_FILE,true);
Expand Down Expand Up @@ -127,14 +125,14 @@ public void mod03test01ViewingResources() throws Exception {

importObject(NUMERIC_PIN_FIRST_NONZERO_POLICY_FILE,true);

csv2TargetFile = new File(testTargetDir, CSV_2_FILE_SOURCE_NAME);
csv2TargetFile = new File(getTestTargetDir(), CSV_2_FILE_SOURCE_NAME);
FileUtils.copyFile(CSV_2_SOURCE_FILE, csv2TargetFile);

importObject(CSV_2_RESOURCE_FILE,true);

changeResourceAttribute(CSV_2_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, csv2TargetFile.getAbsolutePath(), true);

csv3TargetFile = new File(testTargetDir, CSV_3_FILE_SOURCE_NAME);
csv3TargetFile = new File(getTestTargetDir(), CSV_3_FILE_SOURCE_NAME);
FileUtils.copyFile(CSV_3_SOURCE_FILE, csv3TargetFile);

importObject(CSV_3_RESOURCE_FILE,true);
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class M7SynchronizationFlavours extends AbstractLabTest{

@Test(groups={"M7"}, dependsOnGroups={"M6"})
public void mod07test01RunningImportFromResource() throws IOException {
hrTargetFile = new File(testTargetDir, HR_FILE_SOURCE_NAME);
hrTargetFile = new File(getTestTargetDir(), HR_FILE_SOURCE_NAME);
FileUtils.copyFile(HR_SOURCE_FILE, hrTargetFile);

importObject(HR_NO_EXTENSION_RESOURCE_FILE,true);
Expand Down
Expand Up @@ -71,7 +71,7 @@ public void mod08test01ExtendingMidPointXMLSchema() {
form.findProperty("isManager");
form.findProperty("empStatus");

showTask("HR Synchronization").clickSuspend();
// showTask("HR Synchronization").clickSuspend();

importObject(HR_RESOURCE_FILE_8_1,true);
changeResourceAttribute(HR_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, hrTargetFile.getAbsolutePath(), true);
Expand Down

0 comments on commit c772cfc

Please sign in to comment.