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.webservice;
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.fixtures.WebServicesFixtures;
26  import org.jboss.hal.testsuite.page.configuration.WebServicesPage;
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.Disabled;
31  import org.junit.jupiter.api.Test;
32  import org.testcontainers.junit.jupiter.Container;
33  import org.testcontainers.junit.jupiter.Testcontainers;
34  import org.wildfly.extras.creaper.core.online.operations.Operations;
35  
36  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
37  
38  @Manatoko
39  @Testcontainers
40  class ConfigurationTest {
41  
42      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
43      static Operations operations;
44  
45      @BeforeAll
46      static void setupModel() {
47          operations = new Operations(wildFly.managementClient());
48      }
49  
50      @Inject Console console;
51      @Inject CrudOperations crudOperations;
52      @Page WebServicesPage page;
53  
54      @BeforeEach
55      void prepare() {
56          page.navigate();
57          console.verticalNavigation().selectPrimary(Ids.WEBSERVICES_ITEM);
58      }
59  
60      @Test
61      void toggleModifyWSDLAddress() throws Exception {
62          boolean modifyWSDLAddress = operations.readAttribute(WebServicesFixtures.WEB_SERVICES_ADDRESS, "modify-wsdl-address")
63                  .booleanValue();
64          crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
65                  "modify-wsdl-address", !modifyWSDLAddress);
66      }
67  
68      // TODO: recent wildfly uses an expression for this value and the flip operation should switch to normal mode
69      // before flipping
70      @Test
71      @Disabled
72      void toggleStatisticsEnabled() throws Exception {
73          boolean statisticsEnabled = operations.readAttribute(WebServicesFixtures.WEB_SERVICES_ADDRESS, "statistics-enabled")
74                  .booleanValue();
75          crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
76                  "statistics-enabled", !statisticsEnabled);
77      }
78  
79      @Test
80      void editWSDLHost() throws Exception {
81          crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
82                  "wsdl-host");
83      }
84  
85      @Test
86      void editWSDLPathRewriteRule() throws Exception {
87          String wsdlPathRewriteRule = String.format("s/%s/%s/g", Random.name(), Random.name());
88          crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
89                  "wsdl-path-rewrite-rule", wsdlPathRewriteRule);
90      }
91  
92      @Test
93      void editWSDLPort() throws Exception {
94          crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
95                  "wsdl-port", Random.number(0, 65536));
96      }
97  
98      @Test
99      void editWSDLSecurePort() throws Exception {
100         crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
101                 "wsdl-secure-port", Random.number(0, 65536));
102     }
103 
104     @Test
105     void editWSDLURIScheme() throws Exception {
106         crudOperations.update(WebServicesFixtures.WEB_SERVICES_ADDRESS, page.getWebServicesConfigurationForm(),
107                 formFragment -> formFragment.select("wsdl-uri-scheme", "http"),
108                 resourceVerifier -> resourceVerifier.verifyAttribute("wsdl-uri-scheme", "http"));
109     }
110 }