/
M3ResourcesAttributesAndMappingsTest.java
216 lines (175 loc) · 8.55 KB
/
M3ResourcesAttributesAndMappingsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* 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.Condition;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.common.PrismForm;
import com.evolveum.midpoint.schrodinger.page.resource.AccountPage;
import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage;
import com.evolveum.midpoint.schrodinger.page.resource.ResourceWizardPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;
import com.evolveum.midpoint.schrodinger.util.Schrodinger;
import com.evolveum.midpoint.testing.schrodinger.scenarios.ScenariosCommons;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.xml.namespace.QName;
import java.io.File;
import java.io.IOException;
import static com.codeborne.selenide.Selenide.$;
/**
* @author skublik
*/
public class M3ResourcesAttributesAndMappingsTest extends AbstractLabTest {
@BeforeClass(alwaysRun = true, dependsOnMethods = { "springTestContextPrepareTestInstance" })
@Override
public void beforeClass() throws IOException {
super.beforeClass();
}
@Test(groups={"M3"})
public void mod03test01ViewingResources() throws Exception {
csv1TargetFile = new File(getTestTargetDir(), CSV_1_FILE_SOURCE_NAME);
FileUtils.copyFile(CSV_1_SOURCE_FILE, csv1TargetFile);
importObject(CSV_1_SIMPLE_RESOURCE_FILE,true);
changeResourceAttribute(CSV_1_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, csv1TargetFile.getAbsolutePath(), true);
ListResourcesPage resourcesList = basicPage.listResources();
resourcesList
.table()
.clickByName(CSV_1_RESOURCE_NAME)
.clickEditResourceConfiguration();
SelenideElement uniqueAttributeField = $(Schrodinger.byDataResourceKey(UNIQUE_ATTRIBUTE_RESOURCE_KEY))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);
// Unique attribute name should be login
Assert.assertTrue(uniqueAttributeField
.$(By.tagName("input"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.getValue()
.equals(CSV_1_UNIQUE_ATTRIBUTE_NAME));
SelenideElement passwordAttributeField = $(Schrodinger.byDataResourceKey(PASSWORD_ATTRIBUTE_RESOURCE_KEY))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);
// Password attribute name should be password
Assert.assertTrue(passwordAttributeField
.$(By.tagName("input"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.getValue()
.equals(CSV_1_PASSWORD_ATTRIBUTE_NAME));
ResourceWizardPage resourceWizard = basicPage.listResources()
.table()
.clickByName(CSV_1_RESOURCE_NAME)
.clickShowUsingWizard();
//wizard should appear
Assert.assertTrue($(By.className("wizard"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.exists());
Assert.assertTrue($(Schrodinger.byDataId("readOnlyNote"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.exists());
//Configuration tab
resourceWizard.clickOnWizardTab("Configuration");
Assert.assertTrue($(Schrodinger.byDataId("configuration"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.exists());
//Schema tab
resourceWizard.clickOnWizardTab("Schema");
Assert.assertTrue($(By.linkText("Schema"))
.shouldBe(Condition.visible)
.exists());
$(By.linkText(CSV_1_ACCOUNT_OBJECT_CLASS_LINK))
.shouldBe(Condition.visible)
.click();
//Attributes table visibility check
Assert.assertTrue($(Schrodinger.byDataId("attributeTable"))
.shouldBe(Condition.visible)
.exists());
//check resource attributes are present
CSV_1_RESOURCE_ATTRIBUTES.forEach(attr ->
Assert.assertTrue($(Schrodinger.byElementValue("div", attr))
.waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S)
.exists()));
importObject(NUMERIC_PIN_FIRST_NONZERO_POLICY_FILE,true);
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(getTestTargetDir(), CSV_3_FILE_SOURCE_NAME);
FileUtils.copyFile(CSV_3_SOURCE_FILE, csv3TargetFile);
importObject(CSV_3_RESOURCE_FILE,true);
changeResourceAttribute(CSV_3_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, csv3TargetFile.getAbsolutePath(), true);
}
@Test(dependsOnMethods = {"mod03test01ViewingResources"}, groups={"M3"})
public void mod03test02BasicProvisioning() {
UserPage user = basicPage.newUser();
user.selectTabBasic()
.form()
.addAttributeValue(UserType.F_NAME, "kirk")
.addAttributeValue(UserType.F_GIVEN_NAME, "Jim")
.addAttributeValue(UserType.F_FAMILY_NAME, "Kirk")
.setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, "Enabled")
.setPasswordFieldsValues(new QName(SchemaConstantsGenerated.NS_COMMON, "value"), "abc123")
.and()
.and()
.clickSave()
.feedback()
.isSuccess();
showUser("kirk")
.selectTabProjections()
.clickAddProjection()
.table()
.search()
.byName()
.inputValue(CSV_1_RESOURCE_NAME)
.updateSearch()
.and()
.selectCheckboxByName(CSV_1_RESOURCE_NAME)
.and()
.clickAdd()
.and()
.clickSave()
.feedback()
.isSuccess();
Assert.assertTrue(existShadow(CSV_1_RESOURCE_NAME, "login", "kirk"));
showUser("kirk")
.selectTabBasic()
.form()
.addAttributeValue(UserType.F_GIVEN_NAME, "Jim T.")
.and()
.and()
.clickSave()
.feedback()
.isSuccess();
PrismForm<AccountPage> accountForm = showShadow(CSV_1_RESOURCE_NAME, "login", "kirk")
.form();
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
Assert.assertTrue(accountForm.compareInputAttributeValue("fname", "Jim T."));
showUser("kirk")
.selectTabProjections()
.table()
.search()
.byItemName("Name")
.inputValue("kirk")
.updateSearch()
.and()
.selectAll()
.and()
.clickHeaderActionDropDown()
.delete()
.clickYes()
.and()
.and()
.clickSave()
.feedback()
.isSuccess();
Assert.assertFalse(existShadow(CSV_1_RESOURCE_NAME, "login", "kirk"));
}
}