Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Nov 6, 2018
2 parents 99f29bd + 1d78a47 commit 7b3ccb8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 19 deletions.
Expand Up @@ -673,7 +673,7 @@ public Response findShadowOwner(@PathParam("oid") String shadowOid, @Context Mes
try {
PrismObject<UserType> user = model.findShadowOwner(shadowOid, task, parentResult);
// response = Response.ok().entity(user).build();
response = RestServiceUtil.createResponse(Response.Status.NO_CONTENT, user, parentResult);
response = RestServiceUtil.createResponse(Response.Status.OK, user, parentResult);
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
Expand Down
@@ -1,12 +1,18 @@
package com.evolveum.midpoint.testing.schrodinger.labs;

import com.codeborne.selenide.Condition;
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;
import com.evolveum.midpoint.schrodinger.util.Schrodinger;
import com.evolveum.midpoint.testing.schrodinger.TestBase;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.testng.Assert;
import org.testng.annotations.Test;

import javax.xml.namespace.QName;

import static com.codeborne.selenide.Selenide.$;

/**
Expand All @@ -20,12 +26,14 @@ public class BasicProvisioningTest extends TestBase {
private static final String USER_FAMILY_NAME_ATTRIBUTE = "Family name";
private static final String USER_PASSWORD_ATTRIBUTE = "Value";
private static final String USER_ADMINISTRATIVE_STATUS_ATTRIBUTE = "Administrative status";
private static final String PASSWORD_IS_SET_LABEL = "password is set";
private static final QName PASSWORD_FIELD_LABEL = new QName(SchemaConstantsGenerated.NS_COMMON, "value");

private static final String USER_NAME = "kirk";
private static final String USER_GIVEN_NAME = "Jim";
private static final String USER_FAMILY_NAME = "Kirk";
private static final String USER_PASSWORD = "abc123";
private static final String USER_ADMINISTRATIVE_STATUS = "enabled";
private static final String USER_ADMINISTRATIVE_STATUS = "Enabled";

//todo dependsOnGroup
@Test(groups={"lab_4_1"})
Expand All @@ -38,8 +46,8 @@ public void test001createUserKirk(){
.addAttributeValue(UserType.F_NAME, USER_NAME)
.addAttributeValue(UserType.F_FAMILY_NAME, USER_FAMILY_NAME)
.addAttributeValue(UserType.F_GIVEN_NAME, USER_GIVEN_NAME)
//TODO set password and enable status
// .addAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS)
.setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS)
.setPasswordFieldsValues(PASSWORD_FIELD_LABEL, USER_PASSWORD)
.and()
.and()
.clickSave();
Expand All @@ -59,26 +67,56 @@ public void test001createUserKirk(){
Assert.assertTrue(userPage
.selectTabBasic()
.form()
.compareAttibuteValue(USER_NAME_ATTRIBUTE, USER_NAME));
.compareInputAttributeValue(USER_NAME_ATTRIBUTE, USER_NAME));

//check given name attribute value
Assert.assertTrue(userPage
.selectTabBasic()
.form()
.compareAttibuteValue(USER_GIVEN_NAME_ATTRIBUTE, USER_GIVEN_NAME));
.compareInputAttributeValue(USER_GIVEN_NAME_ATTRIBUTE, USER_GIVEN_NAME));

//check family name attribute value
Assert.assertTrue(userPage
.selectTabBasic()
.form()
.compareAttibuteValue(USER_FAMILY_NAME_ATTRIBUTE, USER_FAMILY_NAME));
.compareInputAttributeValue(USER_FAMILY_NAME_ATTRIBUTE, USER_FAMILY_NAME));

//TODO check status, and password is set
//check administrative status attribute value
// Assert.assertTrue(userPage
// .selectTabBasic()
// .form()
// .compareAttibuteValue(Schrodinger.qnameToString(ActivationType.F_ADMINISTRATIVE_STATUS), USER_ADMINISTRATIVE_STATUS));
//check password is set label
Assert.assertTrue($(Schrodinger.byElementValue("span", PASSWORD_IS_SET_LABEL))
.shouldBe(Condition.visible)
.exists());

//check Administrative status value
Assert.assertTrue(userPage
.selectTabBasic()
.form()
.compareSelectAttributeValue(USER_ADMINISTRATIVE_STATUS_ATTRIBUTE, USER_ADMINISTRATIVE_STATUS));

}

@Test(groups={"lab_4_1"})
public void test002addProjectionToUserKirk() {
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(USER_NAME)
.updateSearch()
.and()
.clickByName(USER_NAME)
.selectTabProjections()
.clickCog()
.addProjection()
.projectionsTable()
.selectCheckboxByName(ImportResourceTest.RESOURCE_NAME)
.and()
.clickAdd()
.and()
.clickSave()
.feedback()
.isSuccess();

}

}
Expand Up @@ -46,7 +46,7 @@
public class ImportResourceTest extends TestBase {

private static final File CSV_RESOURCE = new File("./src/test/resources/labs/resources/localhost-csvfile-1-document-access.xml");
private static final String RESOURCE_NAME = "CSV-1 (Document Access)";
public static final String RESOURCE_NAME = "CSV-1 (Document Access)";
private static final String UNIQUE_ATTRIBUTE_NAME = "login";
private static final String PASSWORD_ATTRIBUTE_NAME = "password";
private static final String PASSWORD_ATTRIBUTE_RESOURCE_KEY = "User password attribute name";
Expand Down
Expand Up @@ -189,7 +189,7 @@ public void alreadyLinkedResourceAccountModified() throws IOException {
.clickByName(TEST_USER_DON_NAME)
.selectTabBasic()
.form()
.compareAttibuteValue("Given name","Donato")
.compareInputAttributeValue("Given name","Donato")
);
}

Expand Down
Expand Up @@ -101,14 +101,35 @@ public PrismForm<T> showEmptyAttributes(String containerName) {
return this;
}

public Boolean compareAttibuteValue(String name, String expectedValue) {
public Boolean compareInputAttributeValue(String name, String expectedValue) {
SelenideElement property = findProperty(name);
SelenideElement value = property.$(By.xpath(".//input[contains(@class,\"form-control\")]"));
String valueElemen = value.getValue();
String valueElement = value.getValue();

if (!valueElemen.isEmpty()) {
if (!valueElement.isEmpty()) {

return valueElemen.equals(expectedValue);
return valueElement.equals(expectedValue);

} else if (!expectedValue.isEmpty()) {

return false;

} else {

return true;

}

}

public Boolean compareSelectAttributeValue(String name, String expectedValue) {
SelenideElement property = findProperty(name);
SelenideElement value = property.$(By.xpath(".//select[contains(@class,\"form-control\")]"));
String selectedOptionText = value.getSelectedText();

if (!selectedOptionText.isEmpty()) {

return selectedOptionText.equals(expectedValue);

} else if (!expectedValue.isEmpty()) {

Expand All @@ -133,6 +154,32 @@ public PrismForm<T> addAttributeValue(QName name, String value) {
return this;
}

public PrismForm<T> setPasswordFieldsValues(QName name, String value) {
SelenideElement property = findProperty(name);

ElementsCollection values = property.$$(By.className("prism-property-value"));
if (values.size() > 0) {
ElementsCollection passwordInputs = values.first().$$(By.tagName("input"));
if (passwordInputs != null){
passwordInputs.forEach(inputElement -> inputElement.setValue(value));
}
}
return this;
}

public PrismForm<T> setDropDownAttributeValue(QName name, String value) {
SelenideElement property = findProperty(name);

ElementsCollection values = property.$$(By.className("prism-property-value"));
if (values.size() > 0) {
SelenideElement dropDown = values.first().$(By.tagName("select"));
if (dropDown != null){
dropDown.selectOptionContainingText(value);
}
}
return this;
}

public PrismForm<T> setAttributeValue(QName name, String value) {
// todo implement
return this;
Expand Down

0 comments on commit 7b3ccb8

Please sign in to comment.