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.hal.meta.token.NameTokens;
20 import org.jboss.hal.resources.Ids;
21 import org.jboss.hal.testsuite.Console;
22 import org.jboss.hal.testsuite.command.AddSecurityDomain;
23 import org.jboss.hal.testsuite.container.WildFlyContainer;
24 import org.jboss.hal.testsuite.fragment.AddResourceDialogFragment;
25 import org.jboss.hal.testsuite.fragment.FormFragment;
26 import org.jboss.hal.testsuite.fragment.finder.ColumnFragment;
27 import org.jboss.hal.testsuite.model.ResourceVerifier;
28 import org.jboss.hal.testsuite.test.Manatoko;
29 import org.junit.jupiter.api.BeforeAll;
30 import org.junit.jupiter.api.BeforeEach;
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.OnlineManagementClient;
35 import org.wildfly.extras.creaper.core.online.operations.Operations;
36 import org.wildfly.extras.creaper.core.online.operations.Values;
37
38 import com.gwtplatform.mvp.shared.proxy.PlaceRequest;
39
40 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
41 import static org.jboss.hal.dmr.ModelDescriptionConstants.SECURITY_DOMAIN;
42 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
43 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECURITY_DOMAIN_CREATE;
44 import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_CREATE;
45 import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_DELETE;
46 import static org.jboss.hal.testsuite.fixtures.WebFixtures.APPLICATION_SECURITY_DOMAIN_READ;
47 import static org.jboss.hal.testsuite.fixtures.WebFixtures.applicationSecurityDomainAddress;
48 import static org.jboss.hal.testsuite.fragment.finder.FinderFragment.configurationSubsystemPath;
49 import static org.junit.jupiter.api.Assertions.assertTrue;
50
51 @Manatoko
52 @Testcontainers
53 class ApplicationSecurityDomainFinderTest {
54
55 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
56 static OnlineManagementClient client;
57
58 @BeforeAll
59 static void setupModel() throws Exception {
60 client = wildFly.managementClient();
61 client.apply(new AddSecurityDomain(SECURITY_DOMAIN_CREATE));
62
63 Operations operations = new Operations(client);
64 operations.add(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_READ),
65 Values.of(SECURITY_DOMAIN, SECURITY_DOMAIN_CREATE));
66 operations.add(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_DELETE),
67 Values.of(SECURITY_DOMAIN, SECURITY_DOMAIN_CREATE));
68 }
69
70 @Inject Console console;
71 ColumnFragment column;
72
73 @BeforeEach
74 void prepare() {
75 column = console.finder(NameTokens.CONFIGURATION, configurationSubsystemPath(NameTokens.UNDERTOW)
76 .append(Ids.UNDERTOW_SETTINGS, "application-security-domain"))
77 .column(Ids.UNDERTOW_APP_SECURITY_DOMAIN);
78 }
79
80 @Test
81 void create() throws Exception {
82 AddResourceDialogFragment dialog = column.add();
83 FormFragment form = dialog.getForm();
84 form.text(NAME, APPLICATION_SECURITY_DOMAIN_CREATE);
85 form.text(SECURITY_DOMAIN, SECURITY_DOMAIN_CREATE);
86 dialog.add();
87
88 console.verifySuccess();
89 assertTrue(column.containsItem(Ids.undertowApplicationSecurityDomain(APPLICATION_SECURITY_DOMAIN_CREATE)));
90 new ResourceVerifier(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_CREATE), client).verifyExists();
91 }
92
93 @Test
94 void read() throws Exception {
95 assertTrue(column.containsItem(Ids.undertowApplicationSecurityDomain(APPLICATION_SECURITY_DOMAIN_READ)));
96 new ResourceVerifier(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_READ), client).verifyExists();
97 }
98
99 @Test
100 void view() {
101 column.selectItem(Ids.undertowApplicationSecurityDomain(APPLICATION_SECURITY_DOMAIN_READ))
102 .view();
103 console.verify(new PlaceRequest.Builder().nameToken(NameTokens.UNDERTOW_APPLICATION_SECURITY_DOMAIN)
104 .with("name", APPLICATION_SECURITY_DOMAIN_READ).build());
105 }
106
107 @Test
108 void delete() throws Exception {
109 column.selectItem(Ids.undertowApplicationSecurityDomain(APPLICATION_SECURITY_DOMAIN_DELETE))
110 .dropdown().click("Remove");
111 console.confirmationDialog().confirm();
112 console.verifySuccess();
113 new ResourceVerifier(applicationSecurityDomainAddress(APPLICATION_SECURITY_DOMAIN_DELETE), client).verifyDoesNotExist();
114 }
115 }