View Javadoc
1   /*
2    *  Copyright 2022 Red Hat
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jboss.hal.testsuite.test.configuration.remoting;
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.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.FormFragment;
25  import org.jboss.hal.testsuite.fragment.TableFragment;
26  import org.jboss.hal.testsuite.page.configuration.RemotingPage;
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.MethodOrderer;
31  import org.junit.jupiter.api.Test;
32  import org.junit.jupiter.api.TestMethodOrder;
33  import org.testcontainers.junit.jupiter.Container;
34  import org.testcontainers.junit.jupiter.Testcontainers;
35  import org.wildfly.extras.creaper.commands.socketbindings.AddSocketBinding;
36  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
37  import org.wildfly.extras.creaper.core.online.operations.Operations;
38  import org.wildfly.extras.creaper.core.online.operations.Values;
39  
40  import static java.util.Arrays.asList;
41  import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING;
42  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
43  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_REF;
44  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.HTTP_CONNECTOR_SECURITY;
45  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.HTTP_CONNECTOR_SECURITY_LISTENER;
46  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.HTTP_CONNECTOR_SECURITY_SOCKET;
47  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.INCLUDE_MECHANISMS;
48  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.httpConnectorAddress;
49  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.httpConnectorSecurityAddress;
50  import static org.jboss.hal.testsuite.fixtures.WebFixtures.DEFAULT_SERVER;
51  import static org.jboss.hal.testsuite.fixtures.WebFixtures.httpListenerAddress;
52  
53  @Manatoko
54  @Testcontainers
55  @TestMethodOrder(MethodOrderer.MethodName.class)
56  class HttpConnectorSecurityTest {
57  
58      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
59  
60      @BeforeAll
61      static void setupModel() throws Exception {
62          OnlineManagementClient client = wildFly.managementClient();
63          Operations operations = new Operations(client);
64          client.apply(new AddSocketBinding.Builder(HTTP_CONNECTOR_SECURITY_SOCKET).build());
65          operations.add(httpListenerAddress(DEFAULT_SERVER, HTTP_CONNECTOR_SECURITY_LISTENER),
66                  Values.of(SOCKET_BINDING, HTTP_CONNECTOR_SECURITY_SOCKET)).assertSuccess();
67          operations.add(httpConnectorAddress(HTTP_CONNECTOR_SECURITY),
68                  Values.of(CONNECTOR_REF, HTTP_CONNECTOR_SECURITY_LISTENER)).assertSuccess();
69      }
70  
71      @Inject Console console;
72      @Inject CrudOperations crud;
73      @Page RemotingPage page;
74      TableFragment table;
75      FormFragment form;
76  
77      @BeforeEach
78      void prepare() {
79          page.navigate();
80          console.verticalNavigation().selectSecondary("remoting-remote-connector-item",
81                  "remoting-http-connector-sub-item");
82          table = page.getHttpConnectorTable();
83          form = page.getHttpConnectorSecurityForm();
84          table.bind(form);
85      }
86  
87      @Test
88      void _0create() throws Exception {
89          table.select(HTTP_CONNECTOR_SECURITY);
90          page.getHttpConnectorTabs().select(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_TAB);
91          crud.createSingleton(httpConnectorSecurityAddress(HTTP_CONNECTOR_SECURITY), form);
92      }
93  
94      @Test
95      void _1update() throws Exception {
96          table.select(HTTP_CONNECTOR_SECURITY);
97          page.getHttpConnectorTabs().select(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_TAB);
98          crud.update(httpConnectorSecurityAddress(HTTP_CONNECTOR_SECURITY), form, INCLUDE_MECHANISMS,
99                  asList("foo", "bar"));
100     }
101 
102     @Test
103     void _2reset() throws Exception {
104         table.select(HTTP_CONNECTOR_SECURITY);
105         page.getHttpConnectorTabs().select(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_TAB);
106         crud.reset(httpConnectorSecurityAddress(HTTP_CONNECTOR_SECURITY), form);
107     }
108 
109     @Test
110     void _3delete() throws Exception {
111         table.select(HTTP_CONNECTOR_SECURITY);
112         page.getHttpConnectorTabs().select(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_TAB);
113         crud.deleteSingleton(httpConnectorSecurityAddress(HTTP_CONNECTOR_SECURITY), form);
114     }
115 }