-
Notifications
You must be signed in to change notification settings - Fork 188
/
AccountTests.java
250 lines (222 loc) · 9.14 KB
/
AccountTests.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package schrodinger.core;
import com.codeborne.selenide.Selenide;
import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage;
import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import schrodinger.TestBase;
import java.io.File;
import java.io.IOException;
/**
* Created by matus on 3/22/2018.
*/
public class AccountTests extends TestBase {
private static final File CSV_RESOURCE_MEDIUM = new File("../../samples/resources/csv/resource-csv-username.xml");
private static final File CSV_SOURCE_FILE = new File("../../samples/resources/csv/midpoint-username.csv");
private static final File CSV_TARGET_FILE = new File("C:\\Users\\matus\\Documents\\apache-tomcat-8.5.16\\target\\midpoint.csv"); //TODO change hard coded path to local web container
private static final String CSV_SOURCE_OLDVALUE = "target/midpoint.csv";
private static final String IMPORT_CSV_RESOURCE_DEPENDENCY= "importCsvResource";
private static final String CREATE_MP_USER_DEPENDENCY= "createMidpointUser";
private static final String CHANGE_RESOURCE_FILE_PATH_DEPENDENCY= "changeResourceFilePath";
private static final String ADD_ACCOUNT_DEPENDENCY= "addAccount";
private static final String DISABLE_ACCOUNT_DEPENDENCY= "disableAccount";
private static final String ENABLE_ACCOUNT_DEPENDENCY= "enableAccount";
private static final String CSV_RESOURCE_NAME= "Test CSV: username";
protected static final String TEST_USER_MIKE_NAME= "michelangelo";
private static final String TEST_USER_MIKE_LAST_NAME_OLD= "di Lodovico Buonarroti Simoni";
private static final String TEST_USER_MIKE_LAST_NAME_NEW= "di Lodovico Buonarroti Simoni Il Divino";
@BeforeSuite
private void init() throws IOException {
FileUtils.copyFile(CSV_SOURCE_FILE,CSV_TARGET_FILE);
}
@Test(priority = 1)
public void createMidpointUser(){
UserPage user = basicPage.newUser();
Assert.assertTrue(user.selectTabBasic()
.form()
.addAttributeValue("name", TEST_USER_MIKE_NAME)
.addAttributeValue(UserType.F_GIVEN_NAME, "Michelangelo")
.addAttributeValue(UserType.F_FAMILY_NAME, "di Lodovico Buonarroti Simoni")
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess()
);
}
@Test
public void importCsvResource(){
ImportObjectPage importPage = basicPage.importObject();
Assert.assertTrue(importPage
.getObjectsFromFile()
.chooseFile(CSV_RESOURCE_MEDIUM)
.clickImport()
.feedback()
.isSuccess()
);
}
@Test (dependsOnMethods = {IMPORT_CSV_RESOURCE_DEPENDENCY})
public void changeResourceFilePath(){
ListResourcesPage listResourcesPage = basicPage.listResources();
Assert.assertTrue(listResourcesPage
.table()
.clickByName("Test CSV: username")
.clickEditResourceConfiguration()
.form()
.changeAttributeValue("File path",CSV_SOURCE_OLDVALUE,CSV_TARGET_FILE.getAbsolutePath())
.and()
.and()
.clickSaveAndTestConnection()
.isTestSuccess()
);
}
@Test(dependsOnMethods = {CREATE_MP_USER_DEPENDENCY,CHANGE_RESOURCE_FILE_PATH_DEPENDENCY})
public void addAccount() {
ListUsersPage users = basicPage.listUsers();
Assert.assertTrue(users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.clickCog()
.addProjection()
.projectionsTable()
.selectCheckboxByName(CSV_RESOURCE_NAME)
.and()
.clickAdd()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess()
);
}
@Test (dependsOnMethods = {ADD_ACCOUNT_DEPENDENCY})
public void modifyAccountAttribute(){
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.table()
.clickByName(CSV_RESOURCE_NAME)
.changeAttributeValue("lastname",TEST_USER_MIKE_LAST_NAME_OLD,TEST_USER_MIKE_LAST_NAME_NEW)
.and()
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
;
}
@Test (dependsOnMethods = {ADD_ACCOUNT_DEPENDENCY})
public void modifyAccountPassword(){
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.table()
.clickByName(CSV_RESOURCE_NAME)
.showEmptyAttributes("Password")
.addProtectedAttributeValue("Value","5ecr3t")
.and()
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess();
}
@Test (dependsOnMethods = {ADD_ACCOUNT_DEPENDENCY})
public void disableAccount(){
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.table()
.clickByName(CSV_RESOURCE_NAME)
.selectOption("Administrative status","Disabled")
.and()
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess();
}
@Test (dependsOnMethods = {ADD_ACCOUNT_DEPENDENCY, DISABLE_ACCOUNT_DEPENDENCY})
public void enableAccount(){
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.table()
.clickByName(CSV_RESOURCE_NAME)
.selectOption("Administrative status","Enabled")
.and()
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess();
}
@Test(dependsOnMethods = {ENABLE_ACCOUNT_DEPENDENCY})
public void deleteAccount(){
ListUsersPage users = basicPage.listUsers();
users
.table()
.search()
.byName()
.inputValue(TEST_USER_MIKE_NAME)
.updateSearch()
.and()
.clickByName(TEST_USER_MIKE_NAME)
.selectTabProjections()
.table()
.selectCheckboxByName(CSV_RESOURCE_NAME)
.and()
.clickCog()
.delete()
.clickYes()
.and()
.and()
.checkKeepDisplayingResults()
.clickSave()
.feedback()
.isSuccess();
}
}