1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.iiop;
17
18 import org.jboss.arquillian.core.api.annotation.Inject;
19 import org.jboss.arquillian.graphene.page.Page;
20 import org.jboss.hal.resources.Ids;
21 import org.jboss.hal.testsuite.Console;
22 import org.jboss.hal.testsuite.CrudOperations;
23 import org.jboss.hal.testsuite.Random;
24 import org.jboss.hal.testsuite.container.WildFlyContainer;
25 import org.jboss.hal.testsuite.fragment.FormFragment;
26 import org.jboss.hal.testsuite.page.configuration.IIOPPage;
27 import org.jboss.hal.testsuite.test.Manatoko;
28 import org.junit.jupiter.api.BeforeAll;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.testcontainers.junit.jupiter.Container;
32 import org.testcontainers.junit.jupiter.Testcontainers;
33 import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
34 import org.wildfly.extras.creaper.core.online.operations.Operations;
35
36 import static org.jboss.hal.dmr.ModelDescriptionConstants.CLIENT_SSL_CONTEXT;
37 import static org.jboss.hal.dmr.ModelDescriptionConstants.GROUP;
38 import static org.jboss.hal.dmr.ModelDescriptionConstants.IDENTITY;
39 import static org.jboss.hal.dmr.ModelDescriptionConstants.IIOP_OPENJDK;
40 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAMING;
41 import static org.jboss.hal.dmr.ModelDescriptionConstants.NONE;
42 import static org.jboss.hal.dmr.ModelDescriptionConstants.PROPERTIES;
43 import static org.jboss.hal.dmr.ModelDescriptionConstants.SECURITY;
44 import static org.jboss.hal.dmr.ModelDescriptionConstants.SECURITY_DOMAIN;
45 import static org.jboss.hal.dmr.ModelDescriptionConstants.SERVER_SSL_CONTEXT;
46 import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING;
47 import static org.jboss.hal.dmr.ModelDescriptionConstants.TRANSACTIONS;
48 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.FULL;
49 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.AUTH_METHOD;
50 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.CALLER_PROPAGATION;
51 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.DEFAULT_ROOT_CONTEXT;
52 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.EXPORT_CORBALOC;
53 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.HIGH_WATER_MARK;
54 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.IIOP;
55 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.PERSISTENT_SERVER_ID;
56 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.ROOT_CONTEXT;
57 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.SPEC;
58 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.SUBSYSTEM_ADDRESS;
59 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.SUPPORTED;
60 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.SUPPORT_SSL;
61 import static org.jboss.hal.testsuite.fixtures.IIOPFixtures.USERNAME_PASSWORD;
62 import static org.jboss.hal.testsuite.page.configuration.IIOPPage.IIOP_PREFIX;
63 import static org.junit.jupiter.api.Assertions.assertEquals;
64 import static org.junit.jupiter.api.Assertions.assertTrue;
65
66 @Manatoko
67 @Testcontainers
68 class IIOPTest {
69
70 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL);
71 private static Operations operations;
72
73 @BeforeAll
74 static void setupModel() throws Exception {
75 OnlineManagementClient client = wildFly.managementClient();
76 operations = new Operations(client);
77 operations.undefineAttribute(SUBSYSTEM_ADDRESS, PERSISTENT_SERVER_ID);
78 operations.undefineAttribute(SUBSYSTEM_ADDRESS, EXPORT_CORBALOC);
79 operations.writeAttribute(SUBSYSTEM_ADDRESS, SECURITY, IDENTITY);
80 operations.writeAttribute(SUBSYSTEM_ADDRESS, TRANSACTIONS, SPEC);
81 operations.undefineAttribute(SUBSYSTEM_ADDRESS, AUTH_METHOD);
82 operations.undefineAttribute(SUBSYSTEM_ADDRESS, CALLER_PROPAGATION);
83 operations.undefineAttribute(SUBSYSTEM_ADDRESS, HIGH_WATER_MARK);
84 operations.undefineAttribute(SUBSYSTEM_ADDRESS, ROOT_CONTEXT);
85 operations.undefineAttribute(SUBSYSTEM_ADDRESS, PROPERTIES);
86 operations.undefineAttribute(SUBSYSTEM_ADDRESS, SUPPORT_SSL);
87 operations.undefineAttribute(SUBSYSTEM_ADDRESS, SECURITY_DOMAIN);
88 }
89
90 @Inject Console console;
91 @Inject CrudOperations crud;
92 @Page IIOPPage page;
93 FormFragment form;
94
95 @BeforeEach
96 void prepare() {
97 page.navigate();
98 }
99
100 @Test
101 void updateOrbPersistentId() throws Exception {
102 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "orb", Ids.TAB));
103 form = page.getOrbForm();
104 crud.update(SUBSYSTEM_ADDRESS, form, PERSISTENT_SERVER_ID, "23");
105 }
106
107 @Test
108 void showOrbSocketBindingSensitive() {
109 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "orb", Ids.TAB));
110 form = page.getOrbForm();
111 form.showSensitive(SOCKET_BINDING);
112
113 String val = form.value(SOCKET_BINDING);
114 assertEquals(val, IIOP);
115 }
116
117 @Test
118 void updateNaming() throws Exception {
119 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, NAMING, Ids.TAB));
120 form = page.getNamingForm();
121 crud.update(SUBSYSTEM_ADDRESS, form, EXPORT_CORBALOC, false);
122 }
123
124 @Test
125 void resetNaming() throws Exception {
126 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, NAMING, Ids.TAB));
127 form = page.getNamingForm();
128 crud.reset(SUBSYSTEM_ADDRESS, form, resourceVerifier -> {
129 resourceVerifier.verifyAttribute(EXPORT_CORBALOC, true);
130 resourceVerifier.verifyAttribute(ROOT_CONTEXT, DEFAULT_ROOT_CONTEXT);
131 });
132 }
133
134 @Test
135 void resetInitializers() throws Exception {
136 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "initializers", Ids.TAB));
137 form = page.getInitializersForm();
138 crud.reset(SUBSYSTEM_ADDRESS, form, resourceVerifier -> {
139 resourceVerifier.verifyAttribute(SECURITY, NONE);
140 resourceVerifier.verifyAttribute(TRANSACTIONS, NONE);
141 });
142 }
143
144 @Test
145 void updateAsContext() throws Exception {
146 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "as-context", Ids.TAB));
147 form = page.getAsContextForm();
148 crud.update(SUBSYSTEM_ADDRESS, form,
149 f -> f.select(AUTH_METHOD, NONE),
150 resourceVerifier -> resourceVerifier.verifyAttribute(AUTH_METHOD, NONE));
151 }
152
153 @Test
154 void resetAsContext() throws Exception {
155 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "as-context", Ids.TAB));
156 form = page.getAsContextForm();
157 crud.reset(SUBSYSTEM_ADDRESS, form,
158 resourceVerifier -> resourceVerifier.verifyAttribute(AUTH_METHOD, USERNAME_PASSWORD));
159 }
160
161 @Test
162 void updateSasContext() throws Exception {
163 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "sas-context", Ids.TAB));
164 form = page.getSasContextForm();
165 crud.update(SUBSYSTEM_ADDRESS, form,
166 f -> f.select(CALLER_PROPAGATION, SUPPORTED),
167 resourceVerifier -> resourceVerifier.verifyAttribute(CALLER_PROPAGATION, SUPPORTED));
168 }
169
170 @Test
171 void updateSecurity() throws Exception {
172 boolean clientRequiresSSL = operations.readAttribute(SUBSYSTEM_ADDRESS, "client-requires-ssl").booleanValue();
173 boolean serverRequiresSSL = operations.readAttribute(SUBSYSTEM_ADDRESS, "client-requires-ssl").booleanValue();
174 boolean supportSSL = operations.readAttribute(SUBSYSTEM_ADDRESS, "support-ssl").booleanValue();
175 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, SECURITY, Ids.TAB));
176 form = page.getSecurityForm();
177 crud.update(SUBSYSTEM_ADDRESS, form,
178 formFragment -> {
179 formFragment.flip("client-requires-ssl", !clientRequiresSSL);
180 formFragment.flip("server-requires-ssl", !serverRequiresSSL);
181 formFragment.flip("support-ssl", !supportSSL);
182 },
183 resourceVerifier -> {
184 resourceVerifier.verifyAttribute("client-requires-ssl", !clientRequiresSSL);
185 resourceVerifier.verifyAttribute("server-requires-ssl", !serverRequiresSSL);
186 resourceVerifier.verifyAttribute("support-ssl", !supportSSL);
187 });
188 }
189
190 @Test
191 void updateSecurityServerRequireClientSslContext() {
192 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, SECURITY, Ids.TAB));
193 form = page.getSecurityForm();
194 crud.updateWithError(form, f -> f.text(CLIENT_SSL_CONTEXT, "foo"), SERVER_SSL_CONTEXT);
195 }
196
197 @Test
198 void updateTcp() throws Exception {
199 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "tcp", Ids.TAB));
200 form = page.getTcpForm();
201 crud.update(SUBSYSTEM_ADDRESS, form, HIGH_WATER_MARK, 11);
202 }
203
204 @Test
205 void updateProperties() throws Exception {
206 page.getTabs().select(Ids.build(IIOP_OPENJDK, PROPERTIES, Ids.TAB));
207 form = page.getPropertiesForm();
208 crud.update(SUBSYSTEM_ADDRESS, form, PROPERTIES, Random.properties());
209 }
210
211 @Test
212 void resetProperties() throws Exception {
213 page.getTabs().select(Ids.build(IIOP_OPENJDK, PROPERTIES, Ids.TAB));
214 form = page.getPropertiesForm();
215 crud.reset(SUBSYSTEM_ADDRESS, form,
216 resourceVerifier -> resourceVerifier.verifyAttributeIsUndefined(PROPERTIES));
217 }
218
219 @Test
220 void cancelEditTcp() {
221 page.getTabs().select(Ids.build(IIOP_PREFIX, GROUP, "tcp", Ids.TAB));
222 form = page.getTcpForm();
223 form.edit();
224 form.cancel();
225 assertTrue(console.verifyNoError());
226 }
227
228 @Test
229 void cancelEditProperties() {
230 page.getTabs().select(Ids.build(IIOP_OPENJDK, PROPERTIES, Ids.TAB));
231 form = page.getPropertiesForm();
232 form.edit();
233 form.cancel();
234 assertTrue(console.verifyNoError());
235 }
236 }