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.core.online.OnlineManagementClient;
36  import org.wildfly.extras.creaper.core.online.operations.Operations;
37  import org.wildfly.extras.creaper.core.online.operations.Values;
38  
39  import static java.util.Arrays.asList;
40  import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING;
41  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
42  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.CONNECTOR_SECURITY;
43  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.INCLUDE_MECHANISMS;
44  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.connectorAddress;
45  import static org.jboss.hal.testsuite.fixtures.RemotingFixtures.connectorSecurityAddress;
46  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.INBOUND_READ;
47  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.STANDARD_SOCKETS;
48  import static org.jboss.hal.testsuite.fixtures.SocketBindingFixtures.inboundAddress;
49  
50  @Manatoko
51  @Testcontainers
52  @TestMethodOrder(MethodOrderer.MethodName.class)
53  class ConnectorSecurityTest {
54  
55      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
56  
57      @BeforeAll
58      static void setupModel() throws Exception {
59          OnlineManagementClient client = wildFly.managementClient();
60          Operations operations = new Operations(client);
61          operations.add(inboundAddress(STANDARD_SOCKETS, INBOUND_READ));
62          operations.add(connectorAddress(CONNECTOR_SECURITY), Values.of(SOCKET_BINDING, INBOUND_READ));
63      }
64  
65      @Inject Console console;
66      @Inject CrudOperations crud;
67      @Page RemotingPage page;
68      TableFragment table;
69      FormFragment form;
70  
71      @BeforeEach
72      void prepare() {
73          page.navigate();
74          console.verticalNavigation().selectSecondary("remoting-remote-connector-item",
75                  "remoting-connector-sub-item");
76          table = page.getConnectorTable();
77          form = page.getConnectorSecurityForm();
78          table.bind(form);
79      }
80  
81      @Test
82      void _0create() throws Exception {
83          table.select(CONNECTOR_SECURITY);
84          page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_SECURITY_TAB);
85          crud.createSingleton(connectorSecurityAddress(CONNECTOR_SECURITY), form);
86      }
87  
88      @Test
89      void _1update() throws Exception {
90          table.select(CONNECTOR_SECURITY);
91          page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_SECURITY_TAB);
92          crud.update(connectorSecurityAddress(CONNECTOR_SECURITY), form, INCLUDE_MECHANISMS, asList("foo", "bar"));
93      }
94  
95      @Test
96      void _2reset() throws Exception {
97          table.select(CONNECTOR_SECURITY);
98          page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_SECURITY_TAB);
99          crud.reset(connectorSecurityAddress(CONNECTOR_SECURITY), form);
100     }
101 
102     @Test
103     void _3delete() throws Exception {
104         table.select(CONNECTOR_SECURITY);
105         page.getConnectorTabs().select(Ids.REMOTING_CONNECTOR_SECURITY_TAB);
106         crud.deleteSingleton(connectorSecurityAddress(CONNECTOR_SECURITY), form);
107     }
108 }