${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
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.
Test Setup Test Setup
Test Teardown Test Teardown
Resource ../../../libraries/NetconfCallHome.robot
+Resource ../../../libraries/CompareStream.robot
*** Test Cases ***
CallHome with Incorrect global 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}