View Javadoc
1   /*
2    *  Copyright 2022 Red Hat
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
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.Random;
23  import org.jboss.hal.testsuite.command.AddCredentialStore;
24  import org.jboss.hal.testsuite.container.WildFlyContainer;
25  import org.jboss.hal.testsuite.fragment.FormFragment;
26  import org.jboss.hal.testsuite.fragment.WizardFragment;
27  import org.jboss.hal.testsuite.model.ResourceVerifier;
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.OnlineManagementClient;
36  
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.CREDENTIAL_STORE;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
39  import static org.jboss.hal.resources.Ids.ELYTRON_OTHER_ITEM;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CREDENTIAL_STORE_CREATE;
42  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.DEFAULT_RESOLVER;
43  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.SECRET_KEY;
44  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.expressionEncryptionAddress;
45  
46  @Manatoko
47  @Testcontainers
48  class ExpressionEncryptionAddTest {
49  
50      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
51      static OnlineManagementClient client;
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          client = wildFly.managementClient();
56          client.apply(new AddCredentialStore(CREDENTIAL_STORE_CREATE));
57      }
58  
59      @Inject Console console;
60      @Page ElytronOtherSettingsPage page;
61  
62      @BeforeEach
63      void prepare() {
64          page.navigate();
65          console.verticalNavigation().selectSecondary(ELYTRON_OTHER_ITEM, Ids.ELYTRON_EXPRESSION);
66      }
67  
68      @Test
69      void add() throws Exception {
70          page.getExpressionEmptyState().mainAction();
71          WizardFragment wizard = console.wizard();
72          FormFragment form = wizard.getForm(Ids.ELYTRON_EXPRESSION + "-add-form");
73          form.text(DEFAULT_RESOLVER, Random.name());
74          wizard.next();
75          form = wizard.getForm(Ids.ELYTRON_EXPRESSION + "-resolvers-add-form");
76          form.text(CREDENTIAL_STORE, CREDENTIAL_STORE_CREATE);
77          form.text(NAME, Random.name());
78          form.text(SECRET_KEY, Random.name());
79          wizard.finish();
80          new ResourceVerifier(expressionEncryptionAddress(), client).verifyExists();
81      }
82  }