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
katkav committed Jul 14, 2016
2 parents db8190c + bb6c724 commit 40b5259
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 155 deletions.
92 changes: 45 additions & 47 deletions testing/selenidetest/basic-tests-suite.xml
Expand Up @@ -18,59 +18,57 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="basic-tests-suite" parallel="false">

<!--<test name="Log in Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.LoginTest"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="Simple User Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SimpleUserTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="End User Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.EndUserTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="Super User Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SuperUserTests"/>-->
<!--</classes>-->
<!--</test>-->
<test name="Log in Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.LoginTest"/>
</classes>
</test>
<test name="Simple User Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SimpleUserTests"/>
</classes>
</test>
<test name="End User Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.EndUserTests"/>
</classes>
</test>
<test name="Super User Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SuperUserTests"/>
</classes>
</test>

<!-- TODO: bug in local OpenDJ config? -->
<!--<test name="Resource-User-Account Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.account.ResourceUserAccountTests"/>-->
<!--</classes>-->
<!--</test>-->
<test name="Resource-User-Account Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.account.ResourceUserAccountTests"/>
</classes>
</test>
<test name="Organization Structure Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.organization.OrganizationStructureTests"/>
</classes>
</test>
<!--<test name="Object Template Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.ObjectTemplateTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="Role Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.RoleTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--TODO: after fix test it again -->
<!--<test name="Organization Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.OrganizationTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="CSV Account Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.CsvAccountTests"/>-->
<!--</classes>-->
<!--</test>-->
<test name="Object Template Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.ObjectTemplateTests"/>
</classes>
</test>
<test name="Role Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.RoleTests"/>
</classes>
</test>
<test name="Organization Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.OrganizationTests"/>
</classes>
</test>
<test name="CSV Account Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.CsvAccountTests"/>
</classes>
</test>


</suite>
Expand Up @@ -26,7 +26,7 @@ public class AbstractSelenideTest{
// extends AbstractTestNGSpringContextTests {
public static final String SITE_URL = "/";
public static final String ADMIN_LOGIN = "administrator";
public static final String ADMIN_PASSWORD = "administrator";
public static final String ADMIN_PASSWORD = "5ecr3t";
//User's attributes' fields' names
public static final String USER_NAME_FIELD_NAME = "Name";

Expand Down Expand Up @@ -205,7 +205,7 @@ public void createUser(String userName, Map<String, String> userFields){
$(By.partialLinkText("Users")).shouldBe(visible).click();

//click New user menu item
$(By.partialLinkText("New user")).click();
$(By.partialLinkText("New user")).shouldBe(visible).click();

//set value to Name field
findAttributeValueFiledByDisplayName(USER_NAME_FIELD_NAME, "input")
Expand All @@ -215,6 +215,17 @@ public void createUser(String userName, Map<String, String> userFields){
//click Save button
$(By.linkText("Save")).shouldBe(visible).click();

}

public void createRole(Map<String, String> roleFields){
if (!$(By.partialLinkText("New role")).isDisplayed())
$(By.partialLinkText("Roles")).shouldBe(visible).click();

$(By.partialLinkText("New role")).shouldBe(visible).click();
setFieldValues(roleFields);
//click Save button
$(By.linkText("Save")).shouldBe(visible).click();

}

/**
Expand Down Expand Up @@ -247,8 +258,7 @@ public void assignObjectToUser(String linkText, String objectType, String object
if (objectType != null && !(objectType.trim().isEmpty())){
$(byAttribute("class", "form-inline search-form")).find(By.tagName("select")).shouldBe(visible).click();
$(byText(objectType)).shouldBe(visible).click();
$(byAttribute("class", "form-inline search-form")).find(By.tagName("select")).shouldNotHave(text(ASSIGN_DEFAULT_OBJECT_TYPE));
// $(byText(ASSIGN_DEFAULT_OBJECT_TYPE)).shouldNotBe(visible);
$(byAttribute("class", "form-inline search-form")).find(By.tagName("select")).find(byAttribute("selected", "selected")).shouldHave(text(objectType));
}
//search for object by objectName in the opened Select object(s) window
searchForElement(objectName, "searchText");
Expand Down Expand Up @@ -342,21 +352,19 @@ public void importObjectFromFile(String filePath){
* @param propertyConstraintList
*/
public void editObjectPolicy(String objectType, String objectTemplate, List<String> propertyConstraintList){
//click Configuration menu
// $(By.partialLinkText("Configuration")).shouldBe(visible).click(); // clicked in previous step
//click Basic menu item
$(By.partialLinkText("System")).click();
if (!$(By.partialLinkText("System")).isDisplayed()) {
$(By.partialLinkText("Configuration")).shouldBe(visible).click(); // clicked in previous step
}
$(By.partialLinkText("System")).shouldBe(visible).click();
//click on the Edit button in the Object Policies row
//Note: this Edit button click affects only modifying of the first row
//of Object Policies
$(byAttribute("placeholder", "Insert object policy")).parent().find(By.tagName("button"))
$(byText("Object policies")).parent().find(By.tagName("button"))
.shouldBe(visible).click();
//select Object Type value from drop-down list
$(By.name("tabPanel:panel:objectPolicyEditor:templateConfigModal:content:mainForm:type:selectWrapper:select"))
.shouldBe(visible).selectOption(objectType);
$(byText("Object type")).parent().parent().find(By.tagName("select")).shouldBe(visible).selectOption(objectType);
//select Object Template value from drop-down list
$(By.name("tabPanel:panel:objectPolicyEditor:templateConfigModal:content:mainForm:objectTemplate:selectWrapper:select"))
.shouldBe(visible).selectOption(objectTemplate);
$(byText("Object template")).parent().parent().find(By.tagName("select")).shouldBe(visible).selectOption(objectTemplate);
if (propertyConstraintList != null && propertyConstraintList.size() > 0){
for (int i = 0; i < propertyConstraintList.size(); i++){
$(By.name("tabPanel:panel:mainForm:objectPolicyEditor:templateConfigModal:content:mainForm:repeater:" + i + ":textWrapper:oidBound"))
Expand All @@ -372,7 +380,7 @@ public void editObjectPolicy(String objectType, String objectTemplate, List<Stri
//click Save button on the Configuration for midPoint page
$(By.linkText("Save")).shouldBe(enabled).click();
//check if Success message appears
$(byText("Success")).shouldBe(visible);
checkOperationStatusOk("Update system configuration (GUI)");
}


Expand Down
Expand Up @@ -24,6 +24,7 @@ public class ObjectTemplateTests extends AbstractSelenideTest {
public void test001supplyUserAttributesByObjectTemplateTest(){
close();
login();
checkLoginIsPerformed();
//import object template from file object-template-default.xml
importObjectFromFile(OBJECT_TEMPLATE_FILE_PATH);
//update SystemConfiguration, insert reference on the default template
Expand All @@ -37,10 +38,10 @@ public void test001supplyUserAttributesByObjectTemplateTest(){
//check if Full name and Nickname attributes are filled with values
openUsersEditPage(USER_NAME_VALUE);
//check if Full Name and Nickname fields were filled in according to user template rules
$(By.name(AbstractSelenideTest.FULL_NAME_FIELD_NAME))
.shouldHave(value(USER_GIVEN_NAME_VALUE + " " + USER_FAMILY_NAME_VALUE));
$(By.name(AbstractSelenideTest.NICKNAME_FIELD_NAME))
.shouldHave(value("nick_" + USER_GIVEN_NAME_VALUE));
Map<String, String> userAttributesToCheck = new HashMap<>();
userAttributesToCheck.put(FULL_NAME_FIELD_NAME, USER_GIVEN_NAME_VALUE + " " + USER_FAMILY_NAME_VALUE);
userAttributesToCheck.put(NICKNAME_FIELD_NAME, "nick_" + USER_GIVEN_NAME_VALUE);
checkObjectAttributesValues(userAttributesToCheck);
}

}
Expand Up @@ -35,11 +35,11 @@ public class CsvAccountTests extends AbstractSelenideTest {
public static final String CSV_RESOURCE_NAME = "Localhost CSVfile";
public static final String CSV_FILE_PATH = "target/test-classes/mp-resources/midpoint-flatfile.csv";
//csv account fields
public static final String ACCOUNT_FIRST_NAME_FIELD = "tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:1:property:values:0:value:valueContainer:input:input";
public static final String ACCOUNT_LAST_NAME_FIELD = "tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:2:property:values:0:value:valueContainer:input:input";
public static final String ACCOUNT_NAME_FIELD = "tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input";
public static final String ACCOUNT_PASSWORD2_FIELD = "accounts:accountList:0:account:body:containers:5:container:properties:0:property:values:0:value:valueContainer:input:password2";
public static final String ACCOUNT_PASSWORD1_FIELD = "accounts:accountList:0:account:body:containers:5:container:properties:0:property:values:0:value:valueContainer:input:password1";
public static final String ACCOUNT_FIRST_NAME_FIELD = "Name";
public static final String ACCOUNT_LAST_NAME_FIELD = "First name";
public static final String ACCOUNT_NAME_FIELD = "Last name";
public static final String ACCOUNT_PASSWORD2_FIELD = "password2";
public static final String ACCOUNT_PASSWORD1_FIELD = "password1";
//csv account values
public static final String ACCOUNT_FIRST_NAME_VALUE = "AccountFirstName";
public static final String ACCOUNT_LAST_NAME_VALUE = "AccountLastName";
Expand All @@ -52,38 +52,24 @@ public class CsvAccountTests extends AbstractSelenideTest {
public void test001createCsvAccount() {
close();
login();
//check if welcome message appears after user logged in
$(byText("welcome to midPoint")).shouldBe(visible);
checkLoginIsPerformed();
//import csv resource localhost-csvfile-resource-advanced-sync
updateCsvFilePath();
importObjectFromFile(CSV_RESOURCE_XML_PATH);
//create test user
createUser(USER_WITH_CSV_ACCOUNT_NAME, new HashMap<String, String>());
//open user's Edit page
openUsersEditPage(USER_WITH_CSV_ACCOUNT_NAME);
//click on the menu icon in the Projections section
// $(byAttribute("about", "accountMenu")).find(byAttribute("class", "dropdown-toggle")).shouldBe(visible).click();
$(By.xpath("/html/body/div[1]/div/section[2]/form/div[4]/div/div/div[7]/div[2]/div[1]/div/div[2]/ul/li/a"))
.shouldBe(visible).click();
openProjectionsTab();
//click on the menu icon in the Projection section
$(byAttribute("about", "dropdownMenu")).shouldBe(visible).click();
//click on the Add projection menu item
$(By.linkText("Add projection")).shouldBe(visible).click();

//switch to the opened modal window
switchToInnerFrame();
//search for resource in resources list in the opened Select resource(s) window
searchForElement(CSV_RESOURCE_NAME);
//check if Localhost CSVfile resource was found
$(byText(CSV_RESOURCE_NAME)).shouldBe(visible);

//select check box in the first row for "Localhost CSVfile" resource
$(byAttribute("about", "resourcePopupTable")).find(By.tagName("tbody")).find(By.tagName("input"))
.shouldBe(visible).click();

//click Add resource(s) button
$(By.linkText("Add resource(s)")).shouldBe(enabled).click();

//switch to main window
switchTo().defaultContent();
$(byAttribute("about", "table")).find(By.tagName("tbody")).find(By.tagName("input")).shouldBe(visible).setSelected(true);
$(By.linkText("Add")).shouldBe(enabled).click();
$(By.linkText(CSV_RESOURCE_NAME)).shouldBe(enabled).click();

//fill in account fields map
accountFieldsMap.put(ACCOUNT_FIRST_NAME_FIELD, ACCOUNT_FIRST_NAME_VALUE);
Expand All @@ -94,17 +80,15 @@ public void test001createCsvAccount() {
$(byAttribute("about", "password1")).shouldBe(visible).setValue(PASSWORD1_FIELD_VALUE);
//click Save button
$(By.linkText("Save")).shouldBe(visible).click();
//check if Success message appears
// if error occured, copy midpoint\testing\selenidetest\src\test\resources\mp-resources\midpoint-flatfile-orig.csv to midpoint-flatfile.csv
$(byText("Success")).shouldBe(visible);
checkOperationStatusOk("Save (GUI)");
//open user's Edit page by account name value
openUsersEditPage(ACCOUNT_NAME_VALUE);
openUsersEditPage(ACCOUNT_FIRST_NAME_VALUE);
openProjectionsTab();
//check that account is displayed in the Accounts section
$(By.linkText(CSV_RESOURCE_NAME)).shouldBe(visible);
$(By.linkText(CSV_RESOURCE_NAME)).shouldBe(visible).click();
//check that user's attributes were updated by account's attributes
$(By.name(USER_NAME_FIELD_NAME)).shouldHave(value(ACCOUNT_NAME_VALUE));
$(By.name(GIVEN_NAME_FIELD_NAME)).shouldHave(value(ACCOUNT_FIRST_NAME_VALUE));
$(By.name(FAMILY_NAME_FIELD_NAME)).shouldHave(value(ACCOUNT_LAST_NAME_VALUE));
checkObjectAttributesValues(accountFieldsMap);
//check if account was created in the csv file
//TODO
System.out.println(isAccountExistInCsvFile(CSV_FILE_PATH, ACCOUNT_NAME_VALUE, ACCOUNT_FIRST_NAME_VALUE, ACCOUNT_LAST_NAME_VALUE, ACCOUNT_PASSWORD_VALUE));
Expand Down

0 comments on commit 40b5259

Please sign in to comment.