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.testsuite.Console;
21  import org.jboss.hal.testsuite.CrudOperations;
22  import org.jboss.hal.testsuite.container.WildFlyContainer;
23  import org.jboss.hal.testsuite.fragment.FormFragment;
24  import org.jboss.hal.testsuite.fragment.TableFragment;
25  import org.jboss.hal.testsuite.page.configuration.ElytronOtherSettingsPage;
26  import org.jboss.hal.testsuite.test.Manatoko;
27  import org.junit.jupiter.api.BeforeAll;
28  import org.junit.jupiter.api.BeforeEach;
29  import org.junit.jupiter.api.Test;
30  import org.testcontainers.junit.jupiter.Container;
31  import org.testcontainers.junit.jupiter.Testcontainers;
32  import org.wildfly.extras.creaper.core.online.operations.Operations;
33  import org.wildfly.extras.creaper.core.online.operations.Values;
34  
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.URL;
37  import static org.jboss.hal.resources.Ids.ELYTRON_OTHER_ITEM;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
39  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CERTIFICATE_AUTHORITY_CREATE;
40  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CERTIFICATE_AUTHORITY_DELETE;
41  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CERTIFICATE_AUTHORITY_READ;
42  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CERTIFICATE_AUTHORITY_UPDATE;
43  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.CERTIFICATE_AUTHORITY_URL;
44  import static org.jboss.hal.testsuite.fixtures.SecurityFixtures.certificateAuthorityAddress;
45  import static org.junit.jupiter.api.Assertions.assertEquals;
46  
47  @Manatoko
48  @Testcontainers
49  class CertificateAuthorityTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          Operations operations = new Operations(wildFly.managementClient());
56          operations.add(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_READ),
57                  Values.of(NAME, CERTIFICATE_AUTHORITY_READ).and(URL, CERTIFICATE_AUTHORITY_URL));
58          operations.add(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE),
59                  Values.of(NAME, CERTIFICATE_AUTHORITY_UPDATE).and(URL, CERTIFICATE_AUTHORITY_URL));
60          operations.add(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_DELETE),
61                  Values.of(NAME, CERTIFICATE_AUTHORITY_DELETE).and(URL, CERTIFICATE_AUTHORITY_URL));
62      }
63  
64      @Inject Console console;
65      @Inject CrudOperations crud;
66      @Page ElytronOtherSettingsPage page;
67      TableFragment table;
68      FormFragment form;
69  
70      @BeforeEach
71      void prepare() {
72          page.navigate();
73          console.verticalNavigation().selectSecondary(ELYTRON_OTHER_ITEM, "elytron-certificate-authority-item");
74          table = page.getCertificateAuthorityTable();
75          form = page.getCertificateAuthorityForm();
76          table.bind(form);
77      }
78  
79      @Test
80      void create() throws Exception {
81          crud.create(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_CREATE), table, form -> {
82              form.text(NAME, CERTIFICATE_AUTHORITY_CREATE);
83              form.text(URL, CERTIFICATE_AUTHORITY_URL);
84          });
85      }
86  
87      @Test
88      void read() {
89          table.select(CERTIFICATE_AUTHORITY_READ);
90          assertEquals(CERTIFICATE_AUTHORITY_URL, form.value(URL));
91      }
92  
93      @Test
94      void update() throws Exception {
95          table.select(CERTIFICATE_AUTHORITY_UPDATE);
96          crud.update(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE), form, URL, "https://redhat.com");
97      }
98  
99      @Test
100     void delete() throws Exception {
101         crud.delete(certificateAuthorityAddress(CERTIFICATE_AUTHORITY_DELETE), table, CERTIFICATE_AUTHORITY_DELETE);
102     }
103 }