[VOL-2264] Radius Restart Scenario-Update the tests to include re-authentication case

Change-Id: Ie26b992f97e7ae8090d389e6e92e4a0c14ac16e0
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 58c039a..62c8569 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -89,4 +89,30 @@
     ...    voltha-ro-core    voltha-rw-core-11    voltha-rw-core-12    voltha-ofagent
     Set Suite Variable    ${container_list}
     ${datetime}=    Get Current Date
-    Set Suite Variable    ${datetime}
\ No newline at end of file
+    Set Suite Variable    ${datetime}
+
+WPA Reassociate
+    [Arguments]    ${iface}    ${ip}    ${user}    ${pass}=${None}    ${container_type}=${None}    ${container_name}=${None}
+    [Documentation]    Executes a particular wpa_cli reassociate, which performs force reassociation
+    #Below for loops are used instead of sleep time, to execute reassociate command and check status
+    : FOR    ${i}    IN RANGE    70
+    \    ${output}=    Login And Run Command On Remote System    wpa_cli -i ${iface} reassociate    ${ip}    ${user}
+    ...    ${pass}    ${container_type}    ${container_name}
+    \    ${passed}=    Run Keyword And Return Status    Should Contain    ${output}    OK
+    \    Run Keyword If    ${passed}    Exit For Loop
+    : FOR    ${i}    IN RANGE    70
+    \    ${output}=    Login And Run Command On Remote System    wpa_cli status | grep SUCCESS    ${ip}    ${user}
+    ...    ${pass}    ${container_type}    ${container_name}
+    \    ${passed}=    Run Keyword And Return Status    Should Contain    ${output}    SUCCESS
+    \    Run Keyword If    ${passed}    Exit For Loop
+	
+Validate Authentication After Reassociate
+    [Arguments]    ${auth_pass}    ${iface}    ${ip}    ${user}    ${pass}=${None}    ${container_type}=${None}    ${container_name}=${None}
+    [Documentation]    Executes a particular reassociate request on the RG using wpa_cli. auth_pass determines if authentication should pass
+    WPA Reassociate    ${iface}    ${ip}    ${user}    ${pass}    ${container_type}    ${container_name}
+    Run Keyword If    '${auth_pass}' == 'True'    Wait Until Keyword Succeeds    ${timeout}    2s    Check Remote File Contents
+    ...    True    /tmp/wpa.log    authentication completed successfully    ${ip}    ${user}    ${pass}    
+    ...    ${container_type}    ${container_name}
+    Run Keyword If    '${auth_pass}' == 'False'    Sleep    20s
+    Run Keyword If    '${auth_pass}' == 'False'    Check Remote File Contents    False    /tmp/wpa.log    
+    ...    authentication completed successfully    ${ip}    ${user}    ${pass}    ${container_type}    ${container_name}
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 24abaeb..1307da0 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -96,7 +96,7 @@
     ...    Perform enable on the ONUs and validate that the pings are successful
     [Tags]    functional    test2
     [Setup]    None
-    #[Teardown]    None
+    [Teardown]    None
 
     FOR    ${I}    IN RANGE    0    ${num_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
@@ -116,8 +116,11 @@
     END
 
 Check OLT/ONU Authentication After Radius Pod Restart
-    [Documentation]    After radius restart, validates eapol flows and dhcp allocation
-    ...    and validates onu in onos
+    [Documentation]    After radius restart, triggers reassociation, checks status and
+    ...    authentication, validates dhcp and ping. Note : wpa reassociate works only when
+    ...    wpa supplicant is running in background hence it is recommended to remove
+    ...    teardown from previous test or uncomment 'Teardown    None'.
+    ...    Assuming that test1 was executed where all the ONUs are authenticated/DHCP/pingable
     [Tags]    functional    test3
     [Setup]   NONE
     Wait Until Keyword Succeeds    ${timeout}    15s    Restart Pod    ${NAMESPACE}    ${RESTART_POD_NAME}
@@ -132,8 +135,8 @@
         ...    ${of_id}
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify Eapol Flows Added For ONU    ${k8s_node_ip}
         ...    ${ONOS_SSH_PORT}    ${onu_port}
-        Run Keyword If    ${has_dataplane}    Run Keyword And Continue On Failure    Validate Authentication    True
-        ...    ${src['dp_iface_name']}    wpa_supplicant.conf    ${src['ip']}    ${src['user']}    ${src['pass']}
+        Run Keyword If    ${has_dataplane}    Run Keyword And Continue On Failure    Validate Authentication After Reassociate
+        ...    True    ${src['dp_iface_name']}    ${src['ip']}    ${src['user']}    ${src['pass']}
         ...    ${src['container_type']}    ${src['container_name']}
         Wait Until Keyword Succeeds    ${timeout}    2s    Verify ONU in AAA-Users    ${k8s_node_ip}
         ...    ${ONOS_SSH_PORT}     ${onu_port}