Update version from 1.2.0 to 2.0.0
[oom/platform/cert-service.git] / trustStoreMerger / src / test / java / org / onap / oom / truststoremerger / configuration / path / PathValidatorTest.java
1 /*============LICENSE_START=======================================================
2  * oom-truststore-merger
3  * ================================================================================
4  * Copyright (C) 2020 Nokia. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.onap.oom.truststoremerger.configuration.path;
21
22 import static org.assertj.core.api.Assertions.assertThat;
23
24 import org.junit.jupiter.params.ParameterizedTest;
25 import org.junit.jupiter.params.provider.ValueSource;
26
27 class PathValidatorTest {
28
29     private final PathValidator validator = new PathValidator();
30
31     @ParameterizedTest()
32     @ValueSource(strings = {"/opt/app/truststore.pem", "/opt/app/truststore.jks",
33         "/opt/app/truststore.p12", "/truststore.pem"})
34     void shouldAcceptValidTruststorePaths(String path) {
35         assertThat(validator.isTruststorePathValid(path)).isTrue();
36     }
37
38     @ParameterizedTest()
39     @ValueSource(strings = {"/opt/app/truststore.pass", "/opt/app/truststore.invalid", "/",
40         "truststore", "opt/app/truststore.p12", "/?.pem", "/.pem"})
41     void shouldRejectInvalidTruststorePaths(String path) {
42         assertThat(validator.isTruststorePathValid(path)).isFalse();
43     }
44
45     @ParameterizedTest()
46     @ValueSource(strings = {"", "/opt/app/truststore.pass", "/truststore.pass"})
47     void shouldAcceptValidTruststorePasswordPaths(String path) {
48         assertThat(validator.isTruststorePasswordPathValid(path)).isTrue();
49     }
50
51     @ParameterizedTest()
52     @ValueSource(strings = {"/opt/app/truststore.pem", "/opt/app/truststore.jks",
53         "/opt/app/truststore.p12", "/", "truststore", "opt/app/truststore.p12", "/?.pass", "/.pass"})
54     void shouldRejectInvalidTruststorePasswordPaths(String path) {
55         assertThat(validator.isTruststorePasswordPathValid(path)).isFalse();
56     }
57
58 }