Add CSIT tests for AAF Cert Service

Issue-ID: AAF-995
Signed-off-by: Aleksandra Maciaga <aleksandra.maciaga@nokia.com>
Change-Id: Iaf96cfb08ba9f83b1ebb5f382a530fcec9333a84
diff --git a/tests/aaf/certservice/assets/invalid.csr b/tests/aaf/certservice/assets/invalid.csr
new file mode 100644
index 0000000..7284ab4
--- /dev/null
+++ b/tests/aaf/certservice/assets/invalid.csr
@@ -0,0 +1 @@
+aaaa
\ No newline at end of file
diff --git a/tests/aaf/certservice/assets/invalid.key b/tests/aaf/certservice/assets/invalid.key
new file mode 100644
index 0000000..6484fb6
--- /dev/null
+++ b/tests/aaf/certservice/assets/invalid.key
@@ -0,0 +1 @@
+bbbb
\ No newline at end of file
diff --git a/tests/aaf/certservice/assets/valid.csr b/tests/aaf/certservice/assets/valid.csr
new file mode 100644
index 0000000..aa9387b
--- /dev/null
+++ b/tests/aaf/certservice/assets/valid.csr
@@ -0,0 +1 @@
+LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJRExEQ0NBaFFDQVFBd2daQXhDekFKQmdOVkJBWVRBbEJNTVJZd0ZBWURWUVFJREExTWIzZGxjaTFUYVd4bGMybGhNUkF3RGdZRFZRUUhEQWRYY205amJHRjNNUTR3REFZRFZRUUtEQVZPYjJ0cFlURU5NQXNHQTFVRUN3d0VUMDVCVURFWE1CVUdBMVVFQXd3T2RHVnpkQzV1YjJ0cFlTNWpiMjB4SHpBZEJna3Foa2lHOXcwQkNRRVdFSFJsYzNSbGNrQnViMnRwWVM1amIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFERzMwWUZKMDk3bS83dDJQV1pFbExBNmJ5bFc5Z1k0cDNod3NidC9paENqKzFqRG9YRFdpQk0wMXVGd1BqWmNiaXhwR3BQdXdVU3ZWREUzOUtwUDFHS3NCYVcrMHdLZG02Sit4YmN6ZTBEc0N6QUhCTnNYVXJEK3VzZC9jVUxOV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VCSHQvYTFmN3VoQmJoY2xQVFlPOTBSNGpLcUtGK2lVa2VDRHV0TmcrM09ncTdKaS9PWk5vajRSaUM1WWV4TWs5d1kxc3NVV0pqbDVoUURpd1BRQU5Zc09TSWxOT3Z2SWpydG81RnhNWVN5UndHamYrYnRSTzIyYz0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ==
\ No newline at end of file
diff --git a/tests/aaf/certservice/cert-service-test.robot b/tests/aaf/certservice/cert-service-test.robot
new file mode 100644
index 0000000..cc72eb6
--- /dev/null
+++ b/tests/aaf/certservice/cert-service-test.robot
@@ -0,0 +1,29 @@
+*** Settings ***
+
+Documentation     Run healthcheck
+Library 	      RequestsLibrary
+Resource          ./resources/cert-service-keywords.robot
+
+Suite Setup       Create sessions
+
+*** Test Cases ***
+
+AAF Cert Service API Health Check
+    [Tags]      AAF-CERT-SERVICE
+    [Documentation]   Run healthcheck
+    Run Healthcheck
+
+AAF Cert Service API Send Valid CSR and Valid PK
+    [Tags]      AAF-CERT-SERVICE
+    [Documentation]  Send request to /v1/certificate/test endpoint and expect 200
+    Send Request And Validate Response  ${CERT_PATH}  ${VALID_CSR_FILE}  ${VALID_PK_FILE}  200
+
+AAF Cert Service API Send Invalid CSR and Valid PK
+    [Tags]      AAF-CERT-SERVICE
+    [Documentation]  Send request to /v1/certificate/test endpoint and expect 400
+    Send Request And Validate Response  ${CERT_PATH}  ${INVALID_CSR_FILE}  ${VALID_PK_FILE}  400
+
+AAF Cert Service API Send Valid CSR and Invalid PK
+    [Tags]      AAF-CERT-SERVICE
+    [Documentation]  Send request to /v1/certificate/test endpoint and expect 400
+    Send Request And Validate Response  ${CERT_PATH}  ${VALID_CSR_FILE}  ${INVALID_PK_FILE}  400
\ No newline at end of file
diff --git a/tests/aaf/certservice/resources/cert-service-keywords.robot b/tests/aaf/certservice/resources/cert-service-keywords.robot
new file mode 100644
index 0000000..caec55a
--- /dev/null
+++ b/tests/aaf/certservice/resources/cert-service-keywords.robot
@@ -0,0 +1,36 @@
+*** Settings ***
+
+Library 	      RequestsLibrary
+Library           HttpLibrary.HTTP
+Library           Collections
+Resource          ../../../common.robot
+Resource          ./cert-service-properties.robot
+
+*** Keywords ***
+
+Create sessions
+    [Documentation]  Create all required sessions
+    Create Session    aaf_cert_service_url    ${AAFCERT_URL}
+    Set Suite Variable    ${http_session}    aaf_cert_service_url
+
+Run Healthcheck
+    [Documentation]  Run Healthcheck
+    ${resp}= 	Get Request 	${http_session} 	/actuator/health
+    Should Be Equal As Strings 	${resp.status_code} 	200
+    Validate Recieved Response  ${resp}  status  UP
+
+Send Request And Validate Response
+    [Documentation]   Send request to passed url and validate received response
+    [Arguments]   ${path}  ${csr_file}  ${pk_file}  ${resp_code}
+    ${csr}=  Get Data From File  ${csr_file}
+    ${pk}=   Get Data From File  ${pk_file}
+    ${headers}=  Create Dictionary  CSR=${csr}  PK=${pk}
+    ${resp}= 	Get Request 	${http_session}  ${path}  headers=${headers}
+    Should Be Equal As Strings 	${resp.status_code} 	${resp_code}
+
+Validate Recieved Response
+    [Documentation]  Validare message that has been received
+    [Arguments]  ${resp}  ${key}  ${expected_value}
+    ${json}=    Parse Json      ${resp.content}
+    ${value}=  get from dictionary  ${json}  ${key}
+    Should Be Equal As Strings    ${value}    ${expected_value}
\ No newline at end of file
diff --git a/tests/aaf/certservice/resources/cert-service-properties.robot b/tests/aaf/certservice/resources/cert-service-properties.robot
new file mode 100644
index 0000000..e911133
--- /dev/null
+++ b/tests/aaf/certservice/resources/cert-service-properties.robot
@@ -0,0 +1,9 @@
+*** Variables ***
+
+${AAFCERT_URL}                           http://%{AAFCERT_IP}:8080
+${CAName}                                test
+${CERT_PATH}                             /v1/certificate/${CAName}
+${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
+${INVALID_PK_FILE}                       %{WORKSPACE}/tests/aaf/certservice/assets/invalid.key