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