1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }