aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plans/aaf/certservice/setup.sh12
-rw-r--r--plans/aaf/certservice/teardown.sh3
-rw-r--r--tests/aaf/certservice/assets/invalid_client_docker.env12
-rw-r--r--tests/aaf/certservice/assets/valid_client_docker.env12
-rw-r--r--tests/aaf/certservice/cert-service-test.robot11
-rw-r--r--tests/aaf/certservice/libraries/CertClientManager.py27
-rw-r--r--tests/aaf/certservice/resources/cert-service-keywords.robot8
-rw-r--r--tests/aaf/certservice/resources/cert-service-properties.robot10
8 files changed, 94 insertions, 1 deletions
diff --git a/plans/aaf/certservice/setup.sh b/plans/aaf/certservice/setup.sh
index a89a1625..995b31d3 100644
--- a/plans/aaf/certservice/setup.sh
+++ b/plans/aaf/certservice/setup.sh
@@ -27,6 +27,18 @@ SCRIPTS_DIRECTORY="scripts"
JENKINS_SCRIPTS_PATH="$CURRENT_WORKDIR_PATH/$PROJECT_DIRECTORY/$SCRIPTS_DIRECTORY"
LOCAL_SCRIPTS_PATH="$CURRENT_WORKDIR_PATH/$SCRIPTS_DIRECTORY"
+# ------------------------------------
+#Prepare enviroment for client
+#install docker sdk
+echo "Uninstall docker-py and reinstall docker."
+pip uninstall -y docker-py
+pip uninstall -y docker
+pip install -U docker==2.7.0
+
+#export container name
+export ClientContainerName=CertServiceClient
+# ------------------------------------
+
if test -d "$JENKINS_SCRIPTS_PATH"; then
SCRIPTS_PATH=$JENKINS_SCRIPTS_PATH
else test -f "$LOCAL_SCRIPTS_PATH";
diff --git a/plans/aaf/certservice/teardown.sh b/plans/aaf/certservice/teardown.sh
index ab227596..0a9e0734 100644
--- a/plans/aaf/certservice/teardown.sh
+++ b/plans/aaf/certservice/teardown.sh
@@ -18,4 +18,5 @@
docker-compose down
kill-instance.sh aafcert
-kill-instance.sh aafcert-ejbca \ No newline at end of file
+kill-instance.sh aafcert-ejbca
+kill-instance.sh ${ClientContainerName} \ No newline at end of file
diff --git a/tests/aaf/certservice/assets/invalid_client_docker.env b/tests/aaf/certservice/assets/invalid_client_docker.env
new file mode 100644
index 00000000..7fbc666e
--- /dev/null
+++ b/tests/aaf/certservice/assets/invalid_client_docker.env
@@ -0,0 +1,12 @@
+#Client envs
+REQUEST_TIMEOUT=5000
+OUTPUT_PATH=/var/log
+CA_NAME=Invalid
+#Csr config envs
+COMMON_NAME=onap.org
+ORGANIZATION=Linux-Foundation
+ORGANIZATION_UNIT=ONAP
+LOCATION=San-Francisco
+STATE=California
+COUNTRY=US
+SANS=example.com:example1.com:example3.com \ No newline at end of file
diff --git a/tests/aaf/certservice/assets/valid_client_docker.env b/tests/aaf/certservice/assets/valid_client_docker.env
new file mode 100644
index 00000000..7a219761
--- /dev/null
+++ b/tests/aaf/certservice/assets/valid_client_docker.env
@@ -0,0 +1,12 @@
+#Client envs
+REQUEST_TIMEOUT=30000
+OUTPUT_PATH=/var/log
+CA_NAME=RA
+#Csr config envs
+COMMON_NAME=onap.org
+ORGANIZATION=Linux-Foundation
+ORGANIZATION_UNIT=ONAP
+LOCATION=San-Francisco
+STATE=California
+COUNTRY=US
+SANS=example.com:sample.com \ No newline at end of file
diff --git a/tests/aaf/certservice/cert-service-test.robot b/tests/aaf/certservice/cert-service-test.robot
index ad358263..9d45e455 100644
--- a/tests/aaf/certservice/cert-service-test.robot
+++ b/tests/aaf/certservice/cert-service-test.robot
@@ -42,3 +42,14 @@ Report Bad Request Error When PK Is Not Valid
[Tags] AAF-CERT-SERVICE
[Documentation] Send request to ${CERT_SERVICE_ENDPOINT}/${CLIENT_CA_NAME} endpoint and expect 400
Send Get Request with Header And Expect Error ${CERT_SERVICE_ENDPOINT}/${CLIENT_CA_NAME} ${VALID_CLIENT_CSR_FILE} ${INVALID_PK_FILE} 400
+
+Cert Service Client successful create keystore and trust store
+ [Tags] AAF-CERT-SERVICE
+ [Documentation] Run with correct env and expected exit code 0
+ Run Cert Service Client Container And Validate Exit Code ${VALID_ENV_FILE} 0
+
+Creation of keystore and trustore unsuccesful, incorrect client configuration
+ [Tags] AAF-CERT-SERVICE
+ [Documentation] Run with invalid CaName env and expected exit code 5
+ Run Cert Service Client Container And Validate Exit Code ${INVALID_ENV_FILE} 5
+
diff --git a/tests/aaf/certservice/libraries/CertClientManager.py b/tests/aaf/certservice/libraries/CertClientManager.py
new file mode 100644
index 00000000..30501c8b
--- /dev/null
+++ b/tests/aaf/certservice/libraries/CertClientManager.py
@@ -0,0 +1,27 @@
+import docker
+
+
+class CertClientManager:
+
+ def run_client_container(self, client_image, container_name, path_to_env, request_url, network):
+ client = docker.from_env()
+ environment = self.read_list_env_from_file(path_to_env)
+ environment.append("REQUEST_URL=" + request_url)
+ container = client.containers.run(image=client_image, name=container_name, detach=True, environment=environment,
+ network=network)
+ exitcode = container.wait()
+ return exitcode
+
+ def remove_client_container(self, container_name):
+ client = docker.from_env()
+ container = client.containers.get(container_name)
+ container.remove()
+
+ def read_list_env_from_file(self, path):
+ f = open(path, "r")
+ r_list = []
+ for line in f:
+ line = line.strip()
+ if line[0] != "#":
+ r_list.append(line)
+ return r_list
diff --git a/tests/aaf/certservice/resources/cert-service-keywords.robot b/tests/aaf/certservice/resources/cert-service-keywords.robot
index 5f25f0b0..a8315e7f 100644
--- a/tests/aaf/certservice/resources/cert-service-keywords.robot
+++ b/tests/aaf/certservice/resources/cert-service-keywords.robot
@@ -3,6 +3,7 @@
Library RequestsLibrary
Library HttpLibrary.HTTP
Library Collections
+Library ../libraries/CertClientManager.py
Resource ../../../common.robot
Resource ./cert-service-properties.robot
@@ -81,3 +82,10 @@ Send Post Request And Validate Response
[Arguments] ${path} ${resp_code}
${resp}= Post Request ${http_session} ${path}
Should Be Equal As Strings ${resp.status_code} ${resp_code}
+
+Run Cert Service Client Container And Validate Exit Code
+ [Documentation] Run Cert Service Client Container And Validate Exit Code
+ [Arguments] ${env_file} ${expected_code}
+ ${exitcode}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_ADDRESS} ${CERT_SERVICE_NETWORK}
+ Remove Client Container ${CLIENT_CONTAINER_NAME}
+ Should Be Equal As Strings ${exitcode} ${expected_code}
diff --git a/tests/aaf/certservice/resources/cert-service-properties.robot b/tests/aaf/certservice/resources/cert-service-properties.robot
index 5cf97819..ea5352e9 100644
--- a/tests/aaf/certservice/resources/cert-service-properties.robot
+++ b/tests/aaf/certservice/resources/cert-service-properties.robot
@@ -10,3 +10,13 @@ ${VALID_RA_CSR_FILE} %{WORKSPACE}/tests/aaf/certservice/asse
${VALID_RA_PK_FILE} %{WORKSPACE}/tests/aaf/certservice/assets/valid_ra.pk
${INVALID_CSR_FILE} %{WORKSPACE}/tests/aaf/certservice/assets/invalid.csr
${INVALID_PK_FILE} %{WORKSPACE}/tests/aaf/certservice/assets/invalid.key
+
+
+${CERT_ADDRESS} ${AAFCERT_URL}/v1/certificate/
+${VALID_ENV_FILE} %{WORKSPACE}/tests/aaf/certservice/assets/valid_client_docker.env
+${INVALID_ENV_FILE} %{WORKSPACE}/tests/aaf/certservice/assets/invalid_client_docker.env
+${DOCKER_CLIENT_IMAGE} nexus3.onap.org:10001/onap/org.onap.aaf.certservice.aaf-certservice-client:latest
+${CLIENT_CONTAINER_NAME} %{ClientContainerName}
+${CERT_SERVICE_NETWORK} certservice_certservice
+
+