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.web;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.CrudOperations;
21  import org.jboss.hal.testsuite.Random;
22  import org.jboss.hal.testsuite.command.AddHttpAuthenticationFactory;
23  import org.jboss.hal.testsuite.command.AddSecurityDomain;
24  import org.jboss.hal.testsuite.container.WildFlyContainer;
25  import org.jboss.hal.testsuite.page.configuration.ApplicationSecurityDomainPage;
26  import org.jboss.hal.testsuite.test.Manatoko;
27  import org.junit.jupiter.api.BeforeAll;
28  import org.junit.jupiter.api.Test;
29  import org.testcontainers.junit.jupiter.Container;
30  import org.testcontainers.junit.jupiter.Testcontainers;
31  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
32  import org.wildfly.extras.creaper.core.online.operations.Operations;
33  import org.wildfly.extras.creaper.core.online.operations.Values;
34  
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.HTTP_AUTHENTICATION_FACTORY;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.SECURITY_DOMAIN;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
39  import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_HAF;
40  import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_SD;
41  import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_UPDATE;
42  import static org.jboss.hal.testsuite.fixtures.WebFixtures.applicationSecurityDomainAddress;
43  
44  @Manatoko
45  @Testcontainers
46  class ApplicationSecurityDomainConflictTest {
47  
48      private static final String SECURITY_DOMAIN_NAME = Random.name();
49      private static final String HTTP_AUTHENTICATION_FACTORY_NAME = Random.name();
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
52      static Operations operations;
53  
54      @BeforeAll
55      static void setupModel() throws Exception {
56          OnlineManagementClient client = wildFly.managementClient();
57          client.apply(new AddSecurityDomain(SECURITY_DOMAIN_NAME));
58          client.apply(new AddHttpAuthenticationFactory(HTTP_AUTHENTICATION_FACTORY_NAME));
59  
60          operations = new Operations(client);
61          operations.add(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_UPDATE),
62                  Values.of(HTTP_AUTHENTICATION_FACTORY, HTTP_AUTHENTICATION_FACTORY_NAME));
63          operations.add(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_HAF),
64                  Values.of(HTTP_AUTHENTICATION_FACTORY, HTTP_AUTHENTICATION_FACTORY_NAME));
65          operations.add(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_SD),
66                  Values.of(SECURITY_DOMAIN, SECURITY_DOMAIN_NAME));
67      }
68  
69      @Page ApplicationSecurityDomainPage page;
70      @Inject CrudOperations crud;
71  
72      @Test
73      void preventBothHttpAuthenticationFactoryAndSecurityDomain() {
74          page.navigate(NAME, APPLICATION_SECURITY_DOMAIN_HAF);
75          crud.updateWithError(page.getAttributesForm(), SECURITY_DOMAIN, SECURITY_DOMAIN_NAME);
76      }
77  
78      @Test
79      void preventBothSecurityDomainAndHttpAuthenticationFactory() {
80          page.navigate(NAME, APPLICATION_SECURITY_DOMAIN_SD);
81          crud.updateWithError(page.getAttributesForm(), HTTP_AUTHENTICATION_FACTORY, HTTP_AUTHENTICATION_FACTORY_NAME);
82      }
83  }