1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.console;
20
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertNotNull;
23 import static org.junit.jupiter.api.Assertions.assertTrue;
24
25 import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
26 import org.apache.syncope.client.console.pages.Realms;
27 import org.apache.syncope.client.console.panels.TogglePanel;
28 import org.apache.syncope.client.ui.commons.Constants;
29 import org.apache.wicket.Component;
30 import org.apache.wicket.util.tester.FormTester;
31 import org.junit.jupiter.api.BeforeEach;
32 import org.junit.jupiter.api.Test;
33
34 public class RealmsITCase extends AbstractConsoleITCase {
35
36 @BeforeEach
37 public void login() {
38 doLogin(ADMIN_UNAME, ADMIN_PWD);
39 TESTER.clickLink("body:realmsLI:realms", false);
40 TESTER.assertRenderedPage(Realms.class);
41 }
42
43 @Test
44 public void read() {
45 TESTER.assertLabel(
46 "body:content:body:container:content:tabbedPanel:panel:container:policies:1:field-label",
47 "Account Policy");
48 }
49
50 @Test
51 public void create() {
52 TESTER.clickLink(
53 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:0:action:action");
54 TESTER.assertComponent("body:content:body:outerObjectsRepeater:0:outer", Modal.class);
55
56 FormTester formTester = TESTER.newFormTester(
57 "body:content:body:outerObjectsRepeater:0:outer:form:content:form");
58 formTester.setValue("view:details:container:generics:name:textField", "testRealm");
59
60 formTester.submit("buttons:finish");
61
62 assertSuccessMessage();
63 TESTER.cleanupFeedbackMessages();
64
65 TESTER.executeAjaxEvent(
66 "body:content:body:outerObjectsRepeater:0:outer:form:content:action:actionRepeater:"
67 + "0:action:action", Constants.ON_CLICK);
68
69
70 TESTER.clickLink("body:realmsLI:realms", false);
71
72 TESTER.executeAjaxEvent(
73 "body:content:realmChoicePanel:container:realmsFragment:realms:btn", Constants.ON_CLICK);
74 TESTER.executeAjaxEvent(
75 "body:content:realmChoicePanel:container:realmsFragment:realms:dropdown-menu:buttons:5:button",
76 Constants.ON_CLICK);
77
78 assertTrue(TESTER.getLastResponseAsString().contains(">/</a>"));
79 assertTrue(TESTER.getLastResponseAsString().contains(">testRealm</a>"));
80
81 TESTER.getRequest().addParameter("confirm", "true");
82 TESTER.clickLink(
83 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:3:action:action");
84
85 assertSuccessMessage();
86 TESTER.cleanupFeedbackMessages();
87
88 TESTER.assertLabel(
89 "body:content:body:container:content:tabbedPanel:panel:container:policies:1:field-label",
90 "Account Policy");
91
92 assertTrue(TESTER.getLastResponseAsString().contains(">/</a>"));
93 assertFalse(TESTER.getLastResponseAsString().contains(">testRealm</a>"));
94 }
95
96 @Test
97 public void update() {
98 TESTER.clickLink(
99 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:1:action:action");
100 TESTER.assertComponent("body:content:body:outerObjectsRepeater:0:outer", Modal.class);
101
102 FormTester formTester = TESTER.newFormTester(
103 "body:content:body:outerObjectsRepeater:0:outer:form:content:form");
104 formTester.submit("buttons:finish");
105
106 assertSuccessMessage();
107 TESTER.cleanupFeedbackMessages();
108
109 TESTER.executeAjaxEvent(
110 "body:content:body:outerObjectsRepeater:0:outer:form:content:action:actionRepeater:"
111 + "0:action:action", Constants.ON_CLICK);
112 }
113
114 @Test
115 public void addUserTemplate() {
116 TESTER.executeAjaxEvent(
117 "body:content:realmChoicePanel:container:realmsFragment:realms:btn",
118 Constants.ON_CLICK);
119 TESTER.executeAjaxEvent(
120 "body:content:realmChoicePanel:container:realmsFragment:realms:dropdown-menu:buttons:4:button",
121 Constants.ON_CLICK);
122
123 assertTrue(TESTER.getLastResponseAsString().contains(">/</a>"));
124 assertTrue(TESTER.getLastResponseAsString().contains(">odd</a>"));
125
126 TESTER.clickLink(
127 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:2:action:action");
128 TESTER.assertComponent("body:content:toggleTemplates", TogglePanel.class);
129
130 FormTester formTester = TESTER.newFormTester(
131 "body:content:toggleTemplates:container:content:togglePanelContainer:templatesForm");
132 formTester.setValue("type:dropDownChoiceField", "0");
133 formTester.submit("changeit");
134
135 TESTER.assertComponent("body:content:templateModal", Modal.class);
136
137 formTester = TESTER.newFormTester("body:content:templateModal:form:content:form");
138 formTester.setValue("view:username:textField", "'k' + firstname");
139 formTester.submit("buttons:finish");
140
141 assertSuccessMessage();
142 TESTER.cleanupFeedbackMessages();
143
144 assertTrue(TESTER.getLastResponseAsString().contains(">/</a>"));
145 assertTrue(TESTER.getLastResponseAsString().contains(">odd</a>"));
146
147 TESTER.clickLink(
148 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:2:action:action");
149 TESTER.assertComponent("body:content:toggleTemplates", TogglePanel.class);
150
151 formTester = TESTER.newFormTester(
152 "body:content:toggleTemplates:container:content:togglePanelContainer:templatesForm");
153 formTester.setValue("type:dropDownChoiceField", "0");
154 formTester.submit("changeit");
155
156 TESTER.assertComponent("body:content:templateModal", Modal.class);
157
158 TESTER.assertModelValue("body:content:templateModal:form:content:form:view:username:textField",
159 "'k' + firstname");
160
161 formTester = TESTER.newFormTester("body:content:templateModal:form:content:form");
162 formTester.setValue("view:username:textField", "");
163 formTester.submit("buttons:finish");
164
165 assertSuccessMessage();
166 TESTER.cleanupFeedbackMessages();
167 }
168
169 @Test
170 public void verifyPropagation() {
171 TESTER.executeAjaxEvent("body:content:realmChoicePanel:container"
172 + ":realmsFragment:realms:btn", Constants.ON_CLICK);
173 TESTER.executeAjaxEvent("body:content:realmChoicePanel:container"
174 + ":realmsFragment:realms:dropdown-menu:buttons:2:button",
175 Constants.ON_CLICK);
176
177 TESTER.clickLink(
178 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:1:action:action");
179 TESTER.assertComponent("body:content:body:outerObjectsRepeater:0:outer", Modal.class);
180 TESTER.assertModelValue(
181 "body:content:body:outerObjectsRepeater:0:outer:form:content:form:view:details:"
182 + "container:generics:name:textField", "even");
183
184 FormTester formTester = TESTER.newFormTester(
185 "body:content:body:outerObjectsRepeater:0:outer:form:content:form");
186 formTester.setValue("view:details:container:resources:paletteField:recorder", "resource-ldap-orgunit");
187
188 formTester.submit("buttons:finish");
189
190 assertSuccessMessage();
191 TESTER.cleanupFeedbackMessages();
192
193
194
195
196 Component component = findComponentByProp("resource",
197 "body:content:body:outerObjectsRepeater:0:outer:form:"
198 + "content:customResultBody:firstLevelContainer:first:container", "resource-ldap-orgunit");
199
200 TESTER.clickLink(component.getPageRelativePath() + ":actions:actionRepeater:0:action:action");
201
202 TESTER.assertLabel(
203 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
204 + "secondLevelContainer:second:remoteObject:propView:0:value:leftAttribute:field-label", "__NAME__");
205
206 TESTER.assertModelValue(
207 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
208 + "secondLevelContainer:second:remoteObject:propView:0:value:leftAttribute:textField", null);
209
210 TESTER.assertLabel(
211 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
212 + "secondLevelContainer:second:remoteObject:propView:0:value:rightAttribute:field-label", "__NAME__");
213
214 TESTER.assertModelValue(
215 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
216 + "secondLevelContainer:second:remoteObject:propView:0:value:rightAttribute:textField",
217 "ou=even,o=isp");
218
219 TESTER.clickLink("body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
220 + "secondLevelContainer:back");
221
222 assertNotNull(findComponentByProp("resource", "body:content:body:outerObjectsRepeater:0:outer:form:"
223 + "content:customResultBody:firstLevelContainer:first:container", "resource-ldap-orgunit"));
224
225
226 TESTER.executeAjaxEvent(
227 "body:content:body:outerObjectsRepeater:0:outer:form:content:action:actionRepeater:"
228 + "0:action:action", Constants.ON_CLICK);
229
230 TESTER.clickLink(
231 "body:content:body:container:content:tabbedPanel:panel:actions:actions:actionRepeater:1:action:action");
232 TESTER.assertComponent("body:content:body:outerObjectsRepeater:0:outer", Modal.class);
233 TESTER.assertModelValue(
234 "body:content:body:outerObjectsRepeater:0:outer:form:content:form:view:details:"
235 + "container:generics:name:textField", "even");
236
237 formTester = TESTER.newFormTester(
238 "body:content:body:outerObjectsRepeater:0:outer:form:content:form");
239 formTester.setValue("view:details:container:resources:paletteField:recorder", "");
240
241 formTester.submit("buttons:finish");
242
243 assertSuccessMessage();
244 TESTER.cleanupFeedbackMessages();
245
246
247
248
249 component = findComponentByProp("resource", "body:content:body:outerObjectsRepeater:0:outer:form:"
250 + "content:customResultBody:firstLevelContainer:first:container", "resource-ldap-orgunit");
251
252 TESTER.clickLink(component.getPageRelativePath() + ":actions:actionRepeater:0:action:action");
253
254 TESTER.assertLabel(
255 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
256 + "secondLevelContainer:second:remoteObject:propView:4:value:leftAttribute:field-label", "ou");
257
258 TESTER.assertModelValue(
259 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
260 + "secondLevelContainer:second:remoteObject:propView:4:value:leftAttribute:textField", "even");
261
262 TESTER.assertLabel(
263 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
264 + "secondLevelContainer:second:remoteObject:propView:4:value:rightAttribute:field-label", "ou");
265
266 TESTER.assertModelValue(
267 "body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
268 + "secondLevelContainer:second:remoteObject:propView:4:value:rightAttribute:textField", null);
269
270 TESTER.clickLink("body:content:body:outerObjectsRepeater:0:outer:form:content:customResultBody:"
271 + "secondLevelContainer:back");
272
273 assertNotNull(findComponentByProp("resource", "body:content:body:outerObjectsRepeater:0:outer:form:"
274 + "content:customResultBody:firstLevelContainer:first:container", "resource-ldap-orgunit"));
275
276
277 TESTER.executeAjaxEvent(
278 "body:content:body:outerObjectsRepeater:0:outer:form:content:action:actionRepeater:"
279 + "0:action:action", Constants.ON_CLICK);
280 }
281 }