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.page.configuration.ElytronOtherSettingsPage;
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.operations.Operations;
35 import org.wildfly.extras.creaper.core.online.operations.Values;
36
37 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
38 import static org.jboss.hal.dmr.ModelDescriptionConstants.PATH;
39 import static org.jboss.hal.dmr.ModelDescriptionConstants.RELATIVE_TO;
40 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41 import static org.jboss.hal.testsuite.fixtures.PathsFixtures.JBOSS_SERVER_DATA_DIR;
42 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.DEFAULT_ALIAS;
43 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECRET_KEY_CREDENTIAL_STORE_CREATE;
44 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECRET_KEY_CREDENTIAL_STORE_DELETE;
45 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECRET_KEY_CREDENTIAL_STORE_READ;
46 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECRET_KEY_CREDENTIAL_STORE_UPDATE;
47 import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.secretKeyCredentialStoreAddress;
48
49 @Manatoko
50 @Testcontainers
51 class SecretKeyCredentialStoreTest {
52
53 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
54
55 @BeforeAll
56 static void setupModel() throws Exception {
57 Operations operations = new Operations(wildFly.managementClient());
58 operations.add(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_READ),
59 Values.of(PATH, Random.name()).and(RELATIVE_TO, JBOSS_SERVER_DATA_DIR));
60 operations.add(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_UPDATE),
61 Values.of(PATH, Random.name()).and(RELATIVE_TO, JBOSS_SERVER_DATA_DIR));
62 operations.add(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_DELETE),
63 Values.of(PATH, Random.name()).and(RELATIVE_TO, JBOSS_SERVER_DATA_DIR));
64 }
65
66 @Inject Console console;
67 @Inject CrudOperations crud;
68 @Page ElytronOtherSettingsPage page;
69 TableFragment table;
70 FormFragment form;
71
72 @BeforeEach
73 void prepare() {
74 page.navigate();
75 console.verticalNavigation().selectSecondary(Ids.ELYTRON_STORE_ITEM, "elytron-secret-key-credential-store-item");
76 table = page.getSecretKeyCredentialStoreTable();
77 form = page.getSecretKeyCredentialStoreForm();
78 table.bind(form);
79 }
80
81 @Test
82 void create() throws Exception {
83 crud.create(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_CREATE), table, form -> {
84 form.text(NAME, SECRET_KEY_CREDENTIAL_STORE_CREATE);
85 form.text(PATH, Random.name());
86 form.text(RELATIVE_TO, JBOSS_SERVER_DATA_DIR);
87 });
88 }
89
90 @Test
91 void reset() throws Exception {
92 table.select(SECRET_KEY_CREDENTIAL_STORE_READ);
93 crud.reset(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_READ), form);
94 }
95
96 @Test
97 void update() throws Exception {
98 table.select(SECRET_KEY_CREDENTIAL_STORE_UPDATE);
99 crud.update(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_UPDATE), form, DEFAULT_ALIAS, Random.name());
100 }
101
102 @Test
103 void delete() throws Exception {
104 crud.delete(secretKeyCredentialStoreAddress(SECRET_KEY_CREDENTIAL_STORE_DELETE), table,
105 SECRET_KEY_CREDENTIAL_STORE_DELETE);
106 }
107 }