From ce300688a6369a7fcbb1654c753357acfad047b5 Mon Sep 17 00:00:00 2001 From: Oleksii Mozghovyi Date: Wed, 8 Jul 2020 19:59:55 +0300 Subject: [PATCH] Add test cases for new API to netconf/call-home suite This test verify new yang data models for NETCONF CallHome feature JIRA: NETCONF-5 Change-Id: I1a96db6beb4d68fe0f767b7f1e86bd4e4f200177 Signed-off-by: Oleksii Mozghovyi Signed-off-by: Vladyslav Marchenko --- csit/libraries/NetconfCallHome.robot | 22 +++++++++ csit/suites/netconf/callhome/callhome.robot | 45 +++++++++++++++++++ .../apiv2/create_device_hostkey_only.json | 8 ++++ .../json/apiv2/create_ssh_device.json | 12 +++++ 4 files changed, 87 insertions(+) create mode 100644 csit/variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json create mode 100644 csit/variables/netconf/callhome/json/apiv2/create_ssh_device.json diff --git a/csit/libraries/NetconfCallHome.robot b/csit/libraries/NetconfCallHome.robot index eabe799fd6..6afb7bfc2a 100644 --- a/csit/libraries/NetconfCallHome.robot +++ b/csit/libraries/NetconfCallHome.robot @@ -57,6 +57,26 @@ Get create device request without credentials template (APIv1) ${template} OperatingSystem.Get File ${CREATE_SSH_DEVICE_REQ_V1_HOST_KEY_ONLY} Set Test Variable ${template} +Register SSH call-home device in ODL controller (APIv2) + [Arguments] ${device_name} ${hostkey} ${username}=${EMPTY} ${password}=${EMPTY} + [Documentation] Registration call-home device with SSH transport using latest models + Run Keyword If '${username}' == '${EMPTY}' or '${password}' == '${EMPTY}' Get create device request without credentials template (APIv2) + ... ELSE Get create device request template (APIv2) + ${body} Replace String ${template} {device_name} ${device_name} + ${body} Replace String ${body} {username} ${username} + ${body} Replace String ${body} {password} ${password} + ${body} Replace String ${body} {hostkey} ${hostkey} + ${resp} RequestsLibrary.Post Request session ${whitelist} data=${body} headers=${HEADERS} + Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code} + +Get create device request template (APIv2) + ${template} OperatingSystem.Get File ${CREATE_SSH_DEVICE_REQ_V2} + Set Test Variable ${template} + +Get create device request without credentials template (APIv2) + ${template} OperatingSystem.Get File ${CREATE_SSH_DEVICE_REQ_V2_HOST_KEY_ONLY} + Set Test Variable ${template} + Pull Netopeer2 Docker Image [Documentation] Pulls the netopeer image from the docker repository. ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker pull sysrepo/sysrepo-netopeer2:latest return_stdout=True return_stderr=True @@ -110,6 +130,8 @@ Suite Setup Set Suite Variable ${CREATE_SSH_DEVICE_REQ_V1} ${CURDIR}/../variables/netconf/callhome/json/apiv1/create_device.json Set Suite Variable ${CREATE_SSH_DEVICE_REQ_V1_HOST_KEY_ONLY} ${CURDIR}/../variables/netconf/callhome/json/apiv1/create_device_hostkey_only.json Set Suite Variable ${CREATE_GLOBAL_CREDENTIALS_REQ} ${CURDIR}/../variables/netconf/callhome/json/apiv1/create_global_credentials.json + Set Suite Variable ${CREATE_SSH_DEVICE_REQ_V2} ${CURDIR}/../variables/netconf/callhome/json/apiv2/create_ssh_device.json + Set Suite Variable ${CREATE_SSH_DEVICE_REQ_V2_HOST_KEY_ONLY} ${CURDIR}/../variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json Suite Teardown [Documentation] Tearing down the setup. diff --git a/csit/suites/netconf/callhome/callhome.robot b/csit/suites/netconf/callhome/callhome.robot index 501ee7c7a0..f1651a1456 100644 --- a/csit/suites/netconf/callhome/callhome.robot +++ b/csit/suites/netconf/callhome/callhome.robot @@ -8,6 +8,7 @@ Suite Teardown Suite Teardown Test Setup Test Setup Test Teardown Test Teardown Resource ../../../libraries/NetconfCallHome.robot +Resource ../../../libraries/CompareStream.robot *** Test Cases *** CallHome with Incorrect global Credentials @@ -74,3 +75,47 @@ Successful CallHome with correct per-device credentials ... return_rc=True Wait Until Keyword Succeeds 90s 2s NetconfCallHome.Check Device Status CONNECTED Wait Until Keyword Succeeds 30s 2s Utils.Check For Elements At URI ${mount_point_url} ${netconf_mount_expected_values} + +CallHome over SSH with correct device credentials (APIv2) + [Documentation] Correct credentials should result to successful mount. CONNECTED should be the device status. + CompareStream.Run_Keyword_If_Less_Than_Silicon BuiltIn.Pass_Execution Test case valid only for versions silicon and above. + Apply SSH-based Call-Home configuration + Register SSH call-home device in ODL controller (APIv2) netopeer2 ${NETOPEER_PUB_KEY} root root + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker-compose up -d return_stdout=True return_stderr=True + ... return_rc=True + Wait Until Keyword Succeeds 90s 2s NetconfCallHome.Check Device Status CONNECTED + Wait Until Keyword Succeeds 30s 2s Utils.Check For Elements At URI ${mount_point_url} ${netconf_mount_expected_values} + +CallHome over SSH with incorrect device credentials (APIv2) + [Documentation] Correct credentials should result to successful mount. CONNECTED should be the device status. + CompareStream.Run_Keyword_If_Less_Than_Silicon BuiltIn.Pass_Execution Test case valid only for versions silicon and above. + Apply SSH-based Call-Home configuration + Register SSH call-home device in ODL controller (APIv2) netopeer2 ${NETOPEER_PUB_KEY} root incorrect + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker-compose up -d return_stdout=True return_stderr=True + ... return_rc=True + Wait Until Keyword Succeeds 90s 2s NetconfCallHome.Check Device Status FAILED_AUTH_FAILURE + Wait Until Keyword Succeeds 30s 2s Run Keyword And Expect Error * Utils.Check For Elements At URI ${mount_point_url} + ... ${netconf_mount_expected_values} + +CallHome over SSH with correct global credentials (APIv2) + [Documentation] CallHome SSH device registered via APIv2 with global credentials from APIv1 should result to successful mount. + CompareStream.Run_Keyword_If_Less_Than_Silicon BuiltIn.Pass_Execution Test case valid only for versions silicon and above. + Apply SSH-based Call-Home configuration + Register global credentials for SSH call-home devices (APIv1) root root + Register SSH call-home device in ODL controller (APIv2) netopeer2 ${NETOPEER_PUB_KEY} + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker-compose up -d return_stdout=True return_stderr=True + ... return_rc=True + Wait Until Keyword Succeeds 90s 2s NetconfCallHome.Check Device Status CONNECTED + Wait Until Keyword Succeeds 30s 2s Utils.Check For Elements At URI ${mount_point_url} ${netconf_mount_expected_values} + +CallHome over SSH with incorrect global credentials (APIv2) + [Documentation] CallHome SSH device registered via APIv2 with wrong global credentials from APIv1 should fail. + CompareStream.Run_Keyword_If_Less_Than_Silicon BuiltIn.Pass_Execution Test case valid only for versions silicon and above. + Apply SSH-based Call-Home configuration + Register global credentials for SSH call-home devices (APIv1) root incorrect + Register SSH call-home device in ODL controller (APIv2) netopeer2 ${NETOPEER_PUB_KEY} + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command docker-compose up -d return_stdout=True return_stderr=True + ... return_rc=True + Wait Until Keyword Succeeds 90s 2s NetconfCallHome.Check Device Status FAILED_AUTH_FAILURE + Wait Until Keyword Succeeds 30s 2s Run Keyword And Expect Error * Utils.Check For Elements At URI ${mount_point_url} + ... ${netconf_mount_expected_values} diff --git a/csit/variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json b/csit/variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json new file mode 100644 index 0000000000..d66ed85c11 --- /dev/null +++ b/csit/variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json @@ -0,0 +1,8 @@ +{ + "device": { + "unique-id": "{device_name}", + "ssh-client-params": { + "host-key": "{hostkey}" + } + } +} diff --git a/csit/variables/netconf/callhome/json/apiv2/create_ssh_device.json b/csit/variables/netconf/callhome/json/apiv2/create_ssh_device.json new file mode 100644 index 0000000000..e4cad2e921 --- /dev/null +++ b/csit/variables/netconf/callhome/json/apiv2/create_ssh_device.json @@ -0,0 +1,12 @@ +{ + "device": { + "unique-id": "{device_name}", + "ssh-client-params": { + "credentials": { + "username": "{username}", + "passwords": [ "{password}" ] + }, + "host-key": "{hostkey}" + } + } +} -- 2.36.6