1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.security;
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.fragment.FormFragment;
26 import org.jboss.hal.testsuite.fragment.TableFragment;
27 import org.jboss.hal.testsuite.model.AvailablePortFinder;
28 import org.jboss.hal.testsuite.page.configuration.ElytronOtherSettingsPage;
29 import org.jboss.hal.testsuite.test.Manatoko;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.BeforeEach;
32 import org.junit.jupiter.api.Test;
33 import org.testcontainers.junit.jupiter.Container;
34 import org.testcontainers.junit.jupiter.Testcontainers;
35 import org.wildfly.extras.creaper.core.online.operations.Operations;
36 import org.wildfly.extras.creaper.core.online.operations.Values;
37
38 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
39 import static org.jboss.hal.dmr.ModelDescriptionConstants.PORT;
40 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.HOST_NAME;
42 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.LOCALHOST;
43 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SERVER_ADDRESS;
44 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SYSLOG_AUDIT_LOG_CREATE;
45 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SYSLOG_AUDIT_LOG_DELETE;
46 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SYSLOG_AUDIT_LOG_RESET;
47 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SYSLOG_AUDIT_LOG_UPDATE;
48 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.syslogAuditLogAddress;
49
50 @Manatoko
51 @Testcontainers
52 class SyslogAuditTest {
53
54 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
55
56 @BeforeAll
57 static void setupModel() throws Exception {
58 Values values = Values.of(HOST_NAME, Random.name())
59 .and(PORT, AvailablePortFinder.getNextAvailableNonPrivilegedPort())
60 .and("reconnect-attempts", 1)
61 .and(SERVER_ADDRESS, LOCALHOST);
62 Operations operations = new Operations(wildFly.managementClient());
63 operations.add(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_RESET), values);
64 operations.add(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_UPDATE), values);
65 operations.add(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_DELETE), values);
66 }
67
68 @Inject Console console;
69 @Inject CrudOperations crud;
70 @Page ElytronOtherSettingsPage page;
71 TableFragment table;
72 FormFragment form;
73
74 @BeforeEach
75 void prepare() {
76 page.navigate();
77 console.verticalNavigation().selectSecondary(Ids.ELYTRON_LOGS_ITEM, "elytron-syslog-audit-log-item");
78 table = page.getSyslogAuditLogTable();
79 form = page.getSyslogAuditLogForm();
80 table.bind(form);
81 }
82
83 @Test
84 void create() throws Exception {
85 crud.create(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_CREATE), table, form -> {
86 form.text(NAME, SYSLOG_AUDIT_LOG_CREATE);
87 form.text(HOST_NAME, Random.name());
88 form.number(PORT, AvailablePortFinder.getNextAvailableNonPrivilegedPort());
89 form.text(SERVER_ADDRESS, LOCALHOST);
90 });
91 }
92
93 @Test
94 void reset() throws Exception {
95 table.select(SYSLOG_AUDIT_LOG_RESET);
96 crud.reset(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_RESET), form,
97 resourceVerifier -> resourceVerifier.verifyAttribute("reconnect-attempts", 0));
98 }
99
100 @Test
101 void update() throws Exception {
102 table.select(SYSLOG_AUDIT_LOG_UPDATE);
103 crud.update(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_UPDATE), form, HOST_NAME, Random.name());
104 }
105
106 @Test
107 void delete() throws Exception {
108 crud.delete(syslogAuditLogAddress(SYSLOG_AUDIT_LOG_DELETE), table, SYSLOG_AUDIT_LOG_DELETE);
109 }
110 }