Merge "Add scripts generating temporary certificates for VES CSIT tests"
diff --git a/tests/dcaegen2/testcases/assets/certs/rootCAdec.key b/tests/dcaegen2/testcases/assets/certs/rootCAdec.key
deleted file mode 100644
index e33b7e3..0000000
--- a/tests/dcaegen2/testcases/assets/certs/rootCAdec.key
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKAIBAAKCAgEAvsiM7YoEmyA+HU995RHPlBevYCqYHQ9KO//Z590HsmaxxMXT
-XRfURZxEXrMC3uuGRC/AcAWj873gD2M5O4zeidS0t730w5Bp8zV1cqJHE6xi+MSB
-gBXtd2QY9cU5cQaI0bibACdp9ooZ5NqXEGvkAjsuxwO4jkVa63+Ic1LYR3HL1RWO
-Wde7DS7Uwq7KPT/cSJDKuBPvBku7n02SFFUouqK7kjpYQ9CtMP2nisD4wR05OaPM
-poXPx0jnMVW1Hvn5HLCvIsxy06D0+JQgDwq7L3h2+niEM3fss3YAknTny7AqEmT+
-7Oeg5JmjzcZPFGuVZ7p0yqhjkpkyBE/ocEUyluZQsiRljSDC/fa1pKeBPk12kjMk
-POktX35tqrAcB7jWG03Ois43jdBq+ePgKWoHlSKTjON2zxGHeQSzN0rYFeRnSzB+
-Z3V99MzKCL5YBe6JXJnTkXQO1oBUQJorzeH5+un+ionupb19hU4IxZQK22mxxS44
-qs1uF13Eu0lfqKZ3eu7LWQG3ZC8fpzmY4yWQ5qSOa74dXmTs9IS/YJG4tMmEx15q
-ZHyaIpJ9hXgmR66h12wuRZA3kdMwxFBwuqO2Gb0PYdcqIFkRmuvzmVPDYod4XOmW
-1Vhlhrxu7V+iOX7ecuRiYMJKjqnBuN1AsPxs9ru5g4tFaDcPj4RSEBveCVUCAwEA
-AQKCAgBwXh7jKY9c7rim+tLjwIHKb8jTk0LUmtTWUfM+JWkLIoFBrGK5Sfe0qD18
-qWLfeUkzkAx/7lKKlSMK7R4gfO/1rlpifndTWBOPM8VhJ0NFyxrf+p1rm36p+0LY
-Prl+Y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Y085K/D6lD8sg2d1CmJAX6w9WXR84jd
-ZqSi4+GXekvsItKj8XwJikkpBp5eb30iibmiNoP9LXsy2z710mRzlnEXg/2MKL14
-AG5IxxZAu7r36qO8DtAMu0b7TNF3GgdbbN0doDvxNbNkXqNBxiGD028h+POHjuQt
-e54uKRTGBejKwhVx+skw1DPcDfznIY7uwBSiDR2JhrSAcAqwOGXTh4tne9c=
------END RSA PRIVATE KEY-----
diff --git a/tests/dcaegen2/testcases/dcae_ves.robot b/tests/dcaegen2/testcases/dcae_ves.robot
index f9a97b0..48912e1 100644
--- a/tests/dcaegen2/testcases/dcae_ves.robot
+++ b/tests/dcaegen2/testcases/dcae_ves.robot
@@ -7,9 +7,10 @@
Library Collections
Library DcaeLibrary
Resource ./resources/dcae_keywords.robot
+
Test Teardown Cleanup VES Events
-Suite Setup Run keywords VES Collector Suite Setup DMaaP Create sessions Create header
-Suite Teardown VES Collector Suite Shutdown DMaaP
+Suite Setup Run keywords VES Collector Suite Setup DMaaP Generate Certs Create sessions Create header
+Suite Teardown Run keywords VES Collector Suite Shutdown DMaaP Remove Certs
*** Test Cases ***
@@ -82,7 +83,6 @@
${uuid}= Generate UUID
${headers}= Create Dictionary Accept=*/* X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
${err_msg}= Run Keyword And Expect Error SSLError:* Get Request ${https_outdated_cert_session} /healthcheck headers=${headers}
- Should Contain ${err_msg} bad handshake
Should Contain ${err_msg} certificate unknown
Log Recieved error message ${err_msg}
@@ -135,14 +135,14 @@
Publish Single VES VNF Measurement Event With Wrong Cert
[Tags] DCAE-VESC-R1
- [Documentation] Post single event with valid data and invalid certificate to /eventListener/v7 endpoint over HTTPS and expect SSLError with bad handshake
- @{err_content} Create List bad handshake certificate unknown
+ [Documentation] Post single event with valid data and invalid certificate to /eventListener/v7 endpoint over HTTPS and expect SSLError with certificate unknown
+ @{err_content} Create List certificate unknown
Send Request And Expect Error Publish Event To VES Collector ${https_invalid_cert_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7} SSLError:* @{err_content}
Publish Single VES VNF Measurement Event With Outdated Cert
[Tags] DCAE-VESC-R1
- [Documentation] Post single event with valid data and outdated certificate to /eventListener/v7 endpoint over HTTPS and expect SSLError with bad handshake
- @{err_content} Create List bad handshake certificate unknown
+ [Documentation] Post single event with valid data and outdated certificate to /eventListener/v7 endpoint over HTTPS and expect SSLError with certificate unknown
+ @{err_content} Create List certificate unknown
Send Request And Expect Error Publish Event To VES Collector ${https_outdated_cert_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7} SSLError:* @{err_content}
Publish Single VES VNF Measurement Event Without Auth And Cert
@@ -167,14 +167,14 @@
Publish V7 Batch With Wrong Cert
[Tags] DCAE-VESC-R1
- [Documentation] Post single event with valid data and invalid certificate to /eventListener/v7/eventBatch endpoint over HTTPS and expect SSLError with bad handshake
- @{err_content} Create List bad handshake certificate unknown
+ [Documentation] Post single event with valid data and invalid certificate to /eventListener/v7/eventBatch endpoint over HTTPS and expect SSLError with certificate unknown
+ @{err_content} Create List certificate unknown
Send Request And Expect Error Publish Event To VES Collector ${https_invalid_cert_session} ${VES_BATCH_EVENT_ENDPOINT_V7} ${VES_VALID_BATCH_JSON_V7} SSLError:* @{err_content}
Publish V7 Batch Event With Outdated Cert
[Tags] DCAE-VESC-R1
- [Documentation] Post single event with valid data and outdated certificate to /eventListener/v7/eventBatch endpoint over HTTPS and expect SSLError with bad handshake
- @{err_content} Create List bad handshake certificate unknown
+ [Documentation] Post single event with valid data and outdated certificate to /eventListener/v7/eventBatch endpoint over HTTPS and expect SSLError with certificate unknown
+ @{err_content} Create List certificate unknown
Send Request And Expect Error Publish Event To VES Collector ${https_outdated_cert_session} ${VES_BATCH_EVENT_ENDPOINT_V7} ${VES_VALID_BATCH_JSON_V7} SSLError:* @{err_content}
Publish V7 Batch Event Without Auth And Cert
diff --git a/tests/dcaegen2/testcases/resources/CertsLibrary.py b/tests/dcaegen2/testcases/resources/CertsLibrary.py
new file mode 100644
index 0000000..b818942
--- /dev/null
+++ b/tests/dcaegen2/testcases/resources/CertsLibrary.py
@@ -0,0 +1,42 @@
+
+import os
+import subprocess
+import time
+
+from robot.api import logger
+
+
+class CertsLibrary(object):
+
+ def __init__(self):
+ pass
+
+
+
+ @staticmethod
+ def generate_certs():
+ ws = os.environ['WORKSPACE']
+ script2run = ws + "/tests/dcaegen2/testcases/resources/gen-certs.sh"
+ logger.info("Running script: " + script2run)
+ logger.console("Running script: " + script2run)
+ subprocess.call([script2run, ws])
+ time.sleep(5)
+ return
+
+ @staticmethod
+ def remove_certs():
+ ws = os.environ['WORKSPACE']
+ script2run = ws + "/tests/dcaegen2/testcases/resources/rm-certs.sh"
+ logger.info("Running script: " + script2run)
+ logger.console("Running script: " + script2run)
+ subprocess.call([script2run, ws])
+ time.sleep(5)
+ return
+
+
+
+
+
+
+
+
diff --git a/tests/dcaegen2/testcases/resources/dcae_keywords.robot b/tests/dcaegen2/testcases/resources/dcae_keywords.robot
index 16a8a8a..0011ab8 100644
--- a/tests/dcaegen2/testcases/resources/dcae_keywords.robot
+++ b/tests/dcaegen2/testcases/resources/dcae_keywords.robot
@@ -4,6 +4,7 @@
Library DcaeLibrary
Library OperatingSystem
Library Collections
+Library CertsLibrary
Variables ../resources/DcaeVariables.py
Resource ../../../common.robot
Resource ../resources/dcae_properties.robot
@@ -13,7 +14,7 @@
[Documentation] Create all required sessions
${auth}= Create List ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
${wrong_auth}= Create List ${VESC_HTTPS_WRONG_USER} ${VESC_HTTPS_WRONG_PD}
- ${certs}= Create List ${VESC_ROOTCA_CERT} ${VESC_ROOTCA_KEY}
+ ${certs}= Create List ${VESC_CERT} ${VESC_KEY}
${wrong_certs}= Create List ${VESC_WRONG_CERT} ${VESC_WRONG_KEY}
${outdated_certs}= Create List ${VESC_OUTDATED_CERT} ${VESC_OUTDATED_KEY}
Create Session dcae_vesc_url ${VESC_URL}
diff --git a/tests/dcaegen2/testcases/resources/dcae_properties.robot b/tests/dcaegen2/testcases/resources/dcae_properties.robot
index de5519e..119ef23 100644
--- a/tests/dcaegen2/testcases/resources/dcae_properties.robot
+++ b/tests/dcaegen2/testcases/resources/dcae_properties.robot
@@ -4,6 +4,7 @@
... make sure you prepend them with GLOBAL so that other files can easily see it is from this file.
*** Variables ***
+
${GLOBAL_APPLICATION_ID} robot-dcaegen2
${GLOBAL_DCAE_CONSUL_URL} http://135.205.228.129:8500
${GLOBAL_DCAE_CONSUL_URL1} http://135.205.228.170:8500
@@ -14,8 +15,8 @@
${VESC_HTTPS_PD} sample1
${VESC_HTTPS_WRONG_PD} sample
${VESC_HTTPS_WRONG_USER} sample
-${VESC_ROOTCA_CERT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/rootCA.crt
-${VESC_ROOTCA_KEY} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/rootCAdec.key
+${VESC_CERT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/temporary.crt
+${VESC_KEY} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/temporary.key
${VESC_WRONG_CERT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/wrong.crt
${VESC_WRONG_KEY} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/wrong.key
${VESC_OUTDATED_CERT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/certs/outdated.crt
@@ -44,4 +45,5 @@
${CB_HEALTHCHECK_PATH} /healthcheck
${CB_SERVICE_COMPONENT_PATH} /service_component/
${VES_Service_Name1} dcae-controller-ves-collector
-${VES_Service_Name2} ves-collector-not-exist
\ No newline at end of file
+${VES_Service_Name2} ves-collector-not-exist
+
diff --git a/tests/dcaegen2/testcases/resources/gen-certs.sh b/tests/dcaegen2/testcases/resources/gen-certs.sh
new file mode 100755
index 0000000..f3f358f
--- /dev/null
+++ b/tests/dcaegen2/testcases/resources/gen-certs.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+WS=$1
+dir=$WS/tests/dcaegen2/testcases/assets/certs
+
+openssl genrsa -out "$dir/temporary.key" 2048
+
+openssl req -new -key "$dir/temporary.key" -subj "/C=PL/ST=DL/O=Nokia/CN=dcaegen2" -out "$dir/temporary.csr"
+
+openssl x509 -req -in "$dir/temporary.csr" -CA "$dir/rootCA.crt" -CAkey "$dir/rootCA.key" -passin pass:collector -CAcreateserial -out "$dir/temporary.crt" -days 1 -sha256
diff --git a/tests/dcaegen2/testcases/resources/rm-certs.sh b/tests/dcaegen2/testcases/resources/rm-certs.sh
new file mode 100755
index 0000000..827849c
--- /dev/null
+++ b/tests/dcaegen2/testcases/resources/rm-certs.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+WS=$1
+dir=$WS/tests/dcaegen2/testcases/assets/certs
+
+rm "$dir/temporary.crt" "$dir/temporary.csr" "$dir/temporary.key" "$dir/rootCA.srl"
\ No newline at end of file