SEBA-186 test libraries for DHCP + RG auth requests

Change-Id: Ib7ed28e1316ba243360d075be2ec61946a16f903
diff --git a/src/test/cord-api/Framework/DHCP.robot b/src/test/cord-api/Framework/DHCP.robot
new file mode 100644
index 0000000..3ee3775
--- /dev/null
+++ b/src/test/cord-api/Framework/DHCP.robot
@@ -0,0 +1,43 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation     Library to DHCP Requests from an RG (source host)
+Library           OperatingSystem
+Library           SSHLibrary
+
+*** Keywords ***
+Send Dhclient Request
+    [Arguments]    ${ip}    ${user}    ${pass}    ${iface}    ${prompt}=$    ${prompt_timeout}=60s
+    [Documentation]    SSH's into the RG (src) and executes a dhclient against a particular interface
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo dhclient ${iface}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+    [Return]    ${result}
+
+Add Default Route to Dst Gateway
+    [Arguments]    ${ip}    ${user}    ${pass}    ${src_gateway}    ${dst_subnet}    ${iface}    ${prompt}=$    ${prompt_timeout}=60s
+    [Documentation]    SSH's into the RG (src) and adds an entry to the routing table
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo ip route add ${dst_subnet} via ${src_gateway} dev ${iface}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+    [Return]    ${result}
\ No newline at end of file
diff --git a/src/test/cord-api/Framework/RG_Authentication.robot b/src/test/cord-api/Framework/RG_Authentication.robot
new file mode 100644
index 0000000..a9593a5
--- /dev/null
+++ b/src/test/cord-api/Framework/RG_Authentication.robot
@@ -0,0 +1,31 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation     Library to Send EAPOL 802.1x messages from a RG (source host)
+Library           OperatingSystem
+Library           SSHLibrary
+
+*** Keywords ***
+Send EAPOL Message
+    [Arguments]    ${ip}    ${user}    ${pass}    ${iface}    ${conf_file}    ${prompt}=$    ${prompt_timeout}=60s
+    [Documentation]    SSH's into the RG (src) and executes a particular auth request via wpa_supplicant client. Requested packet should exist on src.
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pamvss}
+    SSHLibrary.Write    sudo sudo wpa_supplicant -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+    [Return]    ${result}
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index db559e5..b4a0d97 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -12,22 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Copyright 2017-present Radisys Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-
 *** Settings ***
 Documentation    Library for various utilities
 Library           SSHLibrary
@@ -37,25 +21,31 @@
 Library           Process
 Library           Collections
 Library           RequestsLibrary
-#Library           ${CURDIR}/readProperties.py
-#Resource          ${CURDIR}/utils.py
-*** Variables ***
-${SSH_KEY}=   id_rsa
 
 *** Keywords ***
 Run Command On Remote System
-    [Arguments]    ${system}    ${cmd}    ${user}=${VM_USER}    ${pass}=${VM_PASS}    ${prompt}=$    ${prompt_timeout}=60s    ${use_key}=False
+    [Arguments]    ${ip}    ${cmd}    ${user}    ${pass}    ${prompt}=$    ${prompt_timeout}=60s
     [Documentation]    SSH's into a remote host, executes command, and logs+returns output
     BuiltIn.Log    Attempting to execute command "${cmd}" on remote system "${system}"
-    BuiltIn.Log    ${pass}
-    ${conn_id}=    SSHLibrary.Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
-    Run Keyword If    '${use_key}' == 'False'    SSHLibrary.Login    ${user}    ${pass}    ELSE    SSHLibrary.Login With Public Key    ${user}    %{HOME}/.ssh/${SSH_KEY}    any
-    #SSHLibrary.Login    ${user}    ${pass}
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
     ${output}=    SSHLibrary.Execute Command    ${cmd}
     SSHLibrary.Close Connection
     Log    ${output}
     [Return]    ${output}
 
+Run Sudo Command On Remote System
+    [Arguments]    ${ip}    ${cmd}    ${user}    ${pass}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    ${cmd}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+    Log    ${result}
+    [Return]    ${result}
+
 Execute Command on CIAB Server in Specific VM
     [Arguments]    ${system}    ${vm}    ${cmd}    ${user}=${VM_USER}    ${password}=${VM_PASS}    ${prompt}=$    ${use_key}=True    ${strip_line}=True
     [Documentation]    SSHs into ${HOST} where CIAB is running and executes a command in the Prod Vagrant VM where all the containers are running
@@ -134,4 +124,38 @@
     [Documentation]    Ping hosts to check connectivity
     ${result}=   Run    ping -I ${interface} -c 5 ${host}
     Should Contain    ${result}    64 bytes
-    Should Not Contain    ${result}    Destination Host Unreachable
\ No newline at end of file
+    Should Not Contain    ${result}    Destination Host Unreachable
+
+Clean Up Objects
+    [Arguments]    ${model_api}
+    ${auth} =    Create List    admin@opencord.org    letmein
+    ${HEADERS}    Create Dictionary    Content-Type=application/json
+    Create Session    ${server_ip}    http://${server_ip}:${server_port}    auth=${AUTH}    headers=${HEADERS}
+    @{ids}=    Create List
+    ${resp}=    CORD Get    ${model_api}
+    ${jsondata}=    To Json    ${resp.content}
+    Log    ${jsondata}
+    ${length}=    Get Length    ${jsondata['items']}
+    : FOR    ${INDEX}    IN RANGE    0    ${length}
+    \    ${value}=    Get From List    ${jsondata['items']}    ${INDEX}
+    \    ${id}=    Get From Dictionary    ${value}    id
+    \    Append To List    ${ids}    ${id}
+    : FOR    ${i}    IN    @{ids}
+    \    CORD Delete    ${model_api}    ${i}
+    Delete All Sessions
+
+CORD Get
+    [Documentation]    Make a GET call to XOS
+    [Arguments]    ${service}
+    ${resp}=    Get Request    ${server_ip}    ${service}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    [Return]    ${resp}
+
+CORD Delete
+    [Documentation]    Make a DELETE call to XOS
+    [Arguments]    ${service}    ${data_id}
+    ${resp}=    Delete Request    ${SERVER_IP}    uri=${service}/${data_id}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    [Return]    ${resp}