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.distributableweb;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.Console;
21  import org.jboss.hal.testsuite.CrudOperations;
22  import org.jboss.hal.testsuite.container.WildFlyContainer;
23  import org.jboss.hal.testsuite.fragment.FormFragment;
24  import org.jboss.hal.testsuite.fragment.TableFragment;
25  import org.jboss.hal.testsuite.page.configuration.DistributableWebPage;
26  import org.jboss.hal.testsuite.test.Manatoko;
27  import org.junit.jupiter.api.BeforeAll;
28  import org.junit.jupiter.api.BeforeEach;
29  import org.junit.jupiter.api.Test;
30  import org.testcontainers.junit.jupiter.Container;
31  import org.testcontainers.junit.jupiter.Testcontainers;
32  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
33  import org.wildfly.extras.creaper.core.online.operations.Operations;
34  import org.wildfly.extras.creaper.core.online.operations.Values;
35  
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.REMOTE_CACHE_CONTAINER;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.FULL;
39  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.HOTROD_SSO_CREATE;
40  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.HOTROD_SSO_DELETE;
41  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.HOTROD_SSO_UPDATE;
42  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.REMOTE_SOCKET_BINDING;
43  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.hotrodSSOAddress;
44  import static org.jboss.hal.testsuite.fixtures.InfinispanFixtures.REMOTE_CC_CREATE;
45  import static org.jboss.hal.testsuite.test.configuration.distributableweb.DistributableWebOperations.addRemoteCacheContainer;
46  import static org.jboss.hal.testsuite.test.configuration.distributableweb.DistributableWebOperations.addRemoteSocketBinding;
47  
48  @Manatoko
49  @Testcontainers
50  class HotrodSSOTest {
51  
52      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL);
53  
54      @BeforeAll
55      static void setupModel() throws Exception {
56          OnlineManagementClient client = wildFly.managementClient();
57          Operations operations = new Operations(client);
58          addRemoteSocketBinding(client, operations, REMOTE_SOCKET_BINDING);
59          addRemoteCacheContainer(client, operations, REMOTE_CC_CREATE, REMOTE_SOCKET_BINDING);
60          Values values = Values.of(REMOTE_CACHE_CONTAINER, REMOTE_CC_CREATE);
61          operations.add(hotrodSSOAddress(HOTROD_SSO_UPDATE), values);
62          operations.add(hotrodSSOAddress(HOTROD_SSO_DELETE), values);
63      }
64  
65      @Page DistributableWebPage page;
66      @Inject CrudOperations crud;
67      @Inject Console console;
68      TableFragment table;
69      FormFragment form;
70  
71      @BeforeEach
72      void setUp() {
73          page.navigate();
74          console.verticalNavigation().selectPrimary("dw-hotrod-sso-management-item");
75          table = page.getHotrodSSOManagementTable();
76          form = page.getHotrodSSOManagementForm();
77          table.bind(form);
78      }
79  
80      @Test
81      void create() throws Exception {
82          crud.create(hotrodSSOAddress(HOTROD_SSO_CREATE), table, f -> {
83              f.text(NAME, HOTROD_SSO_CREATE);
84              f.text(REMOTE_CACHE_CONTAINER, REMOTE_CC_CREATE);
85          });
86      }
87  
88      @Test
89      void reset() throws Exception {
90          table.select(HOTROD_SSO_UPDATE);
91          crud.reset(hotrodSSOAddress(HOTROD_SSO_UPDATE), form);
92      }
93  
94      @Test
95      void delete() throws Exception {
96          table.select(HOTROD_SSO_DELETE);
97          crud.delete(hotrodSSOAddress(HOTROD_SSO_DELETE), table, HOTROD_SSO_DELETE);
98      }
99  }