2 * ============LICENSE_START=======================================================
3 * aaf-certservice-client
4 * ================================================================================
5 * Copyright (C) 2020 Nokia. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aaf.certservice.client;
23 import java.io.IOException;
24 import java.nio.charset.StandardCharsets;
25 import java.nio.file.Files;
26 import java.nio.file.Paths;
28 public final class CerServiceRequestTestData {
30 private static final String RESOURCE_PATH = "src/test/resources/";
33 public static final String CA_NAME = "TestCA";
34 public static final String CSR = getCsrValue();
35 public static final String PK = getPkValue();
37 // Correct response data
38 public static final String CORRECT_RESPONSE = getCorrectResponse();
39 public static final String EXPECTED_FIRST_ELEMENT_OF_CERTIFICATE_CHAIN =
40 getExpectedFirstElementOfCertificateChain();
41 public static final String EXPECTED_FIRST_ELEMENT_OF_TRUSTED_CERTIFICATES =
42 getExpectedFirstElementOfTrustedCertificates();
44 // Error response data
45 public static final String MISSING_PK_RESPONSE = getMissingPkResponse();
47 private CerServiceRequestTestData() {
50 private static String getMissingPkResponse() {
51 String fileName = "missingPkResponse";
52 return readFromFile(RESOURCE_PATH + fileName);
55 private static String getExpectedFirstElementOfTrustedCertificates() {
57 String fileName = "expectedFirstElementOfTrustedCertificates";
58 return readFromFile(RESOURCE_PATH + fileName);
61 private static String getExpectedFirstElementOfCertificateChain() {
62 String fileName = "expectedFirstElementOfCertificateChain";
63 return readFromFile(RESOURCE_PATH + fileName);
66 private static String getCorrectResponse() {
67 String fileName = "correctResponse";
68 return readFromFile(RESOURCE_PATH + fileName);
71 private static String getPkValue() {
72 String fileName = "testPk";
73 return readFromFile(RESOURCE_PATH + fileName);
76 private static String getCsrValue() {
77 String fileName = "testCsr";
78 return readFromFile(RESOURCE_PATH + fileName);
81 private static String readFromFile(String path) {
83 return Files.readString(Paths.get(path), StandardCharsets.UTF_8);
84 } catch (IOException e) {
86 return "File not found";