1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.mail;
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.CredentialReference;
28 import org.jboss.hal.testsuite.page.configuration.MailPage;
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.OnlineManagementClient;
36 import org.wildfly.extras.creaper.core.online.operations.Operations;
37 import org.wildfly.extras.creaper.core.online.operations.Values;
38
39 import static org.jboss.hal.dmr.ModelDescriptionConstants.CREDENTIAL_REFERENCE;
40 import static org.jboss.hal.dmr.ModelDescriptionConstants.JNDI_NAME;
41 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
42 import static org.jboss.hal.dmr.ModelDescriptionConstants.OUTBOUND_SOCKET_BINDING_REF;
43 import static org.jboss.hal.dmr.ModelDescriptionConstants.PASSWORD;
44 import static org.jboss.hal.dmr.ModelDescriptionConstants.SMTP;
45 import static org.jboss.hal.dmr.ModelDescriptionConstants.USERNAME;
46 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
47 import static org.jboss.hal.testsuite.fixtures.MailFixtures.MAIL_SMTP;
48 import static org.jboss.hal.testsuite.fixtures.MailFixtures.SECRET;
49 import static org.jboss.hal.testsuite.fixtures.MailFixtures.SESSION_UPDATE;
50 import static org.jboss.hal.testsuite.fixtures.MailFixtures.serverAddress;
51 import static org.jboss.hal.testsuite.fixtures.MailFixtures.sessionAddress;
52
53 @Manatoko
54 @Testcontainers
55 class MailServerUpdateTest {
56
57 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
58
59 @BeforeAll
60 static void setupModel() throws Exception {
61 OnlineManagementClient client = wildFly.managementClient();
62 Operations operations = new Operations(client);
63 operations.add(sessionAddress(SESSION_UPDATE), Values.of(JNDI_NAME, Random.jndiName(SESSION_UPDATE)));
64 operations.add(serverAddress(SESSION_UPDATE, SMTP), Values.of(OUTBOUND_SOCKET_BINDING_REF, MAIL_SMTP));
65 operations.writeAttribute(serverAddress(SESSION_UPDATE, SMTP),
66 CREDENTIAL_REFERENCE, CredentialReference.storeAlias());
67 }
68
69 @Inject Console console;
70 @Inject CrudOperations crud;
71 @Page MailPage page;
72 TableFragment table;
73 FormFragment form;
74
75 @BeforeEach
76 void setUp() {
77 page.navigate(NAME, SESSION_UPDATE);
78 console.verticalNavigation().selectPrimary(Ids.MAIL_SERVER_ITEM);
79 table = page.getMailServerTable();
80 form = page.getMailServerAttributesForm();
81 table.bind(form);
82 }
83
84 @Test
85 void reset() {
86 table.select(SMTP.toUpperCase());
87 }
88
89 @Test
90 void update() throws Exception {
91 table.select(SMTP.toUpperCase());
92 crud.update(serverAddress(SESSION_UPDATE, SMTP), form, USERNAME, SECRET);
93 }
94
95 @Test
96 void updateConflictWithCredRef() {
97 table.select(SMTP.toUpperCase());
98 crud.updateWithError(form, PASSWORD, SECRET);
99 }
100 }