Clean up code

Signed-off-by: Aleksandra Maciaga <aleksandra.maciaga@nokia.com>
Issue-ID: AAF-997
Change-Id: Iaeebbe2e3dbae3d1f6d9374a8d54d28bfd39ff3e
diff --git a/plans/aaf/certservice/docker-compose.yml b/plans/aaf/certservice/docker-compose.yml
index 84da735..83aff56 100644
--- a/plans/aaf/certservice/docker-compose.yml
+++ b/plans/aaf/certservice/docker-compose.yml
@@ -6,10 +6,10 @@
     hostname: cahostname
     container_name: aafcert-ejbca
     ports:
-        - "80:8080"
-        - "443:8443"
+      - "80:8080"
+      - "443:8443"
     volumes:
-        - $SCRIPTS_PATH:/opt/primekey/scripts
+      - $SCRIPTS_PATH:/opt/primekey/scripts
     command: bash -c "
       ./scripts/ejbca-configuration.sh &
       /opt/primekey/bin/start.sh
@@ -19,6 +19,8 @@
       interval: 10s
       timeout: 3s
       retries: 9
+    networks:
+      - certservice
 
   certservice:
     image: nexus3.onap.org:10001/onap/org.onap.aaf.certservice.aaf-certservice-api:latest
@@ -30,4 +32,11 @@
     depends_on:
       ejbca:
         condition: service_healthy
+    networks:
+      - certservice
+
+
+networks:
+  certservice:
+    driver: bridge
 
diff --git a/plans/aaf/certservice/setup.sh b/plans/aaf/certservice/setup.sh
index 4911e47..17a278d 100644
--- a/plans/aaf/certservice/setup.sh
+++ b/plans/aaf/certservice/setup.sh
@@ -16,24 +16,33 @@
 #
 
 # ------------------------------------
-# Resolve path to script's folder and cmp servers configuration
+# Resolve path to script's directory and cmp servers configuration
 
 SCRIPT=`realpath $0`
 CURRENT_WORKDIR_PATH=`dirname $SCRIPT`
+PROJECT_DIRECTORY="plans/aaf/certservice"
 
 SCRIPTS_DIRECTORY="scripts"
-if test -d "$CURRENT_WORKDIR_PATH/plans/aaf/certservice/$SCRIPTS_DIRECTORY"; then
-    SCRIPTS_PATH="$CURRENT_WORKDIR_PATH/plans/aaf/certservice/$SCRIPTS_DIRECTORY"
-else test -f "$CURRENT_WORKDIR_PATH/$SCRIPTS_DIRECTORY";
-    SCRIPTS_PATH=$CURRENT_WORKDIR_PATH/$SCRIPTS_DIRECTORY
+
+JENKINS_SCRIPTS_PATH="$CURRENT_WORKDIR_PATH/$PROJECT_DIRECTORY/$SCRIPTS_DIRECTORY"
+LOCAL_SCRIPTS_PATH="$CURRENT_WORKDIR_PATH/$SCRIPTS_DIRECTORY"
+
+if test -d "$JENKINS_SCRIPTS_PATH"; then
+    SCRIPTS_PATH=$JENKINS_SCRIPTS_PATH
+else test -f "$LOCAL_SCRIPTS_PATH";
+    SCRIPTS_PATH=$LOCAL_SCRIPTS_PATH
 fi
 echo "Use scripts from: $SCRIPTS_PATH"
 
 CONFIGURATION_FILE="cmpServers.json"
-if test -f "$CURRENT_WORKDIR_PATH/plans/aaf/certservice/$CONFIGURATION_FILE"; then
-    CONFIGURATION_PATH="$CURRENT_WORKDIR_PATH/plans/aaf/certservice/$CONFIGURATION_FILE"
-else test -f "$CURRENT_WORKDIR_PATH/$CONFIGURATION_FILE";
-    CONFIGURATION_PATH=$CURRENT_WORKDIR_PATH/$CONFIGURATION_FILE
+
+JENKINS_CONFIGURATION_PATH="$CURRENT_WORKDIR_PATH/$PROJECT_DIRECTORY/$CONFIGURATION_FILE"
+LOCAL_CONFIGURATION_PATH="$CURRENT_WORKDIR_PATH/$CONFIGURATION_FILE"
+
+if test -f "$JENKINS_CONFIGURATION_PATH"; then
+    CONFIGURATION_PATH="$JENKINS_CONFIGURATION_PATH"
+else test -f "$LOCAL_CONFIGURATION_PATH";
+    CONFIGURATION_PATH=$LOCAL_CONFIGURATION_PATH
 fi
 echo "Use configuration from: $CONFIGURATION_PATH"
 
diff --git a/tests/aaf/certservice/cert-service-test.robot b/tests/aaf/certservice/cert-service-test.robot
index daaa07c..0bcdcf2 100644
--- a/tests/aaf/certservice/cert-service-test.robot
+++ b/tests/aaf/certservice/cert-service-test.robot
@@ -1,6 +1,6 @@
 *** Settings ***
 
-Documentation     AAF test case scenarios
+Documentation     AAF Cert Service API test case scenarios
 Library 	      RequestsLibrary
 Resource          ./resources/cert-service-keywords.robot
 
@@ -8,37 +8,37 @@
 
 *** Test Cases ***
 
-AAF Cert Service API Health Check
+Health Check
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]   Run healthcheck
+    [Documentation]   Service is up and running
     Run Healthcheck
 
-AAF Cert Service API Reload Configuration
+Reload Configuration
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]   Reload configuration
+    [Documentation]   Configuration was changed
     Send Post Request And Validate Response  /actuator/refresh  200
 
-AAF Cert Service API Send Valid CSR and Valid PK
+Generate Certicicate For CA Name
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]  Send request to ${CERT_PATH} endpoint and expect 200
-    Send Get Request with Header And Validate Response  ${CERT_PATH}  ${VALID_CSR_FILE}  ${VALID_PK_FILE}  200
+    [Documentation]  Send request to ${CERT_SERVICE_ENDPOINT}/${CA_NAME} endpoint and expect 200
+    Send Get Request with Header And Validate Response  ${CERT_SERVICE_ENDPOINT}/${CA_NAME}  ${VALID_CSR_FILE}  ${VALID_PK_FILE}  200
 
-AAF Cert Service API Send Valid CSR and Valid PK to Wrong Path
+Report Not Found Error When Path Is Not Valid
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]  Send request to /v1/certificate/ endpoint and expect 404
-    Send Get Request with Header And Validate Response  /v1/certificate/  ${VALID_CSR_FILE}  ${VALID_PK_FILE}  404
+    [Documentation]  Send request to ${CERT_SERVICE_ENDPOINT}/ endpoint and expect 404
+    Send Get Request with Header And Validate Response  ${CERT_SERVICE_ENDPOINT}/  ${VALID_CSR_FILE}  ${VALID_PK_FILE}  404
 
-AAF Cert Service API Send Request without Header
+Report Bad Request Error When Header Is Missing
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]  Send request without header to ${CERT_PATH} endpoint and expect 400
-    Send Get Request And Validate Response  ${CERT_PATH}  400
+    [Documentation]  Send request without header to ${CERT_SERVICE_ENDPOINT}/${CA_NAME} endpoint and expect 400
+    Send Get Request And Validate Response  ${CERT_SERVICE_ENDPOINT}/${CA_NAME}  400
 
-AAF Cert Service API Send Invalid CSR and Valid PK
+Report Bad Request Error When CSR Is Not Valid
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]  Send request to ${CERT_PATH} endpoint and expect 400
-    Send Get Request with Header And Validate Response  ${CERT_PATH}  ${INVALID_CSR_FILE}  ${VALID_PK_FILE}  400
+    [Documentation]  Send request to ${CERT_SERVICE_ENDPOINT}/${CA_NAME} endpoint and expect 400
+    Send Get Request with Header And Validate Response  ${CERT_SERVICE_ENDPOINT}/${CA_NAME}  ${INVALID_CSR_FILE}  ${VALID_PK_FILE}  400
 
-AAF Cert Service API Send Valid CSR and Invalid PK
+Report Bad Request Error When PK Is Not Valid
     [Tags]      AAF-CERT-SERVICE
-    [Documentation]  Send request to ${CERT_PATH} endpoint and expect 400
-    Send Get Request with Header And Validate Response  ${CERT_PATH}  ${VALID_CSR_FILE}  ${INVALID_PK_FILE}  400
+    [Documentation]  Send request to ${CERT_SERVICE_ENDPOINT}/${CA_NAME} endpoint and expect 400
+    Send Get Request with Header And Validate Response  ${CERT_SERVICE_ENDPOINT}/${CA_NAME}  ${VALID_CSR_FILE}  ${INVALID_PK_FILE}  400
diff --git a/tests/aaf/certservice/resources/cert-service-properties.robot b/tests/aaf/certservice/resources/cert-service-properties.robot
index 1049695..2a382ed 100644
--- a/tests/aaf/certservice/resources/cert-service-properties.robot
+++ b/tests/aaf/certservice/resources/cert-service-properties.robot
@@ -1,8 +1,8 @@
 *** Variables ***
 
 ${AAFCERT_URL}                           http://%{AAFCERT_IP}:8080
-${CAName}                                TEST
-${CERT_PATH}                             /v1/certificate/${CAName}
+${CA_NAME}                                TEST
+${CERT_SERVICE_ENDPOINT}                 /v1/certificate
 ${VALID_CSR_FILE}                        %{WORKSPACE}/tests/aaf/certservice/assets/valid.csr
 ${VALID_PK_FILE}                         %{WORKSPACE}/tests/aaf/certservice/assets/valid.key
 ${INVALID_CSR_FILE}                      %{WORKSPACE}/tests/aaf/certservice/assets/invalid.csr