Add test cases for new API to netconf/call-home suite 04/91004/16
authorOleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Wed, 8 Jul 2020 16:59:55 +0000 (19:59 +0300)
committerLuis Gomez <ecelgp@gmail.com>
Thu, 11 Feb 2021 18:23:08 +0000 (18:23 +0000)
This test verify new yang data models for NETCONF CallHome feature

JIRA: NETCONF-5
Change-Id: I1a96db6beb4d68fe0f767b7f1e86bd4e4f200177
Signed-off-by: Oleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Signed-off-by: Vladyslav Marchenko <vladyslav.marchenko@pantheon.tech>
csit/libraries/NetconfCallHome.robot
csit/suites/netconf/callhome/callhome.robot
csit/variables/netconf/callhome/json/apiv2/create_device_hostkey_only.json [new file with mode: 0644]
csit/variables/netconf/callhome/json/apiv2/create_ssh_device.json [new file with mode: 0644]

index eabe799fd637eef5137eb87a255292a4ddcf8b46..6afb7bfc2a3302be17040c59382262e54053806e 100644 (file)
@@ -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.
index 501ee7c7a07e1f367155c0d72f0c43efbfda3b0e..f1651a1456f8ceb99ac532d9395da8618f0ecfa0 100644 (file)
@@ -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 (file)
index 0000000..d66ed85
--- /dev/null
@@ -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 (file)
index 0000000..e4cad2e
--- /dev/null
@@ -0,0 +1,12 @@
+{
+    "device": {
+        "unique-id": "{device_name}",
+        "ssh-client-params": {
+          "credentials": {
+              "username": "{username}",
+              "passwords": [ "{password}" ]
+          },
+          "host-key": "{hostkey}"
+        }
+    }
+}