SEBA-752 fixing atests in voltha-1.7

Change-Id: Id99a24a72e35baa31096750bf7fb12424017124f
diff --git a/tests/atests/common/authentication.py b/tests/atests/common/authentication.py
index aedbbf2..a03f17e 100644
--- a/tests/atests/common/authentication.py
+++ b/tests/atests/common/authentication.py
@@ -19,7 +19,6 @@
 """
 
 import time
-import os
 import subprocess
 import testCaseUtils
 import logging
@@ -37,37 +36,16 @@
         self.dirs['log'] = None
         self.dirs['root'] = None
         self.dirs['voltha'] = None
-        
+
+        self.__onuCount = None
         self.__rgName = testCaseUtils.discover_rg_pod_name()
-        self.__radiusName = None
-        self.__radiusIp = None
-        
+
     def a_set_log_dirs(self, root_dir, voltha_dir, log_dir):
         testCaseUtils.config_dirs(self, log_dir, root_dir, voltha_dir)
 
-    def discover_freeradius_pod_name(self):
-        self.__radiusName = testCaseUtils.extract_pod_name('freeradius').strip()
-        logging.info('freeradius Name = %s' % self.__radiusName)
-        
-    def discover_freeradius_ip_addr(self):
-        ipAddr = testCaseUtils.extract_radius_ip_addr(self.__radiusName)
-        assert ipAddr, 'No IP address listed for freeradius'
-        self.__radiusIp = ipAddr.strip()
-        logging.info('freeradius IP = %s' % self.__radiusIp)
-        
-    def set_current_freeradius_ip_in_aaa_json(self):
-        status = testCaseUtils.modify_radius_ip_in_json_using_sed(self, self.__radiusIp)
-        assert (status == 0), 'Setting Radius Ip in Json File did not return Success'
-          
-    def alter_aaa_application_configuration_in_onos_using_aaa_json(self):
-        logging.info('Altering the Onos NetCfg AAA apps with Freeradius IP address')
-        logging.debug('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
-                      'http://localhost:30120/onos/v1/network/configuration/apps/ -d @%s/tests/atests/build/aaa_json'
-                      % testCaseUtils.get_dir(self, 'voltha'))
-        os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
-                  'http://localhost:30120/onos/v1/network/configuration/apps/ -d @%s/tests/atests/build/aaa_json'
-                  % testCaseUtils.get_dir(self, 'voltha'))
-     
+    def a_configure(self, onu_count):
+        self.__onuCount = onu_count
+
     def execute_authentication_on_rg(self):
         logging.info('Running Radius Authentication from RG')
         process_output = open('%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.AUTHENTICATE_FILENAME), 'w')
@@ -126,32 +104,40 @@
 
         testCaseUtils.print_log_file(self, self.AUTHENTICATE_FILENAME)
         
-    def verify_authentication_should_have_started(self):
+    def authentication_should_have_started(self):
         statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-EAP-STARTED', self.AUTHENTICATE_FILENAME)
         assert statusLines, 'Authentication was not started'
         
-    def verify_authentication_should_have_completed(self):
+    def authentication_should_have_completed(self):
         statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-EAP-SUCCESS', self.AUTHENTICATE_FILENAME)
         assert statusLines, 'Authentication was not completed successfully'
 
-    def verify_authentication_should_have_disconnected(self):
+    def authentication_should_have_disconnected(self):
         statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-DISCONNECTED', self.AUTHENTICATE_FILENAME)
         assert statusLines, 'Authentication was not disconnected'
 
-    def verify_authentication_should_have_terminated(self):
+    def authentication_should_have_terminated(self):
         statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-TERMINATING', self.AUTHENTICATE_FILENAME)
         assert statusLines, 'Authentication was not terminated'
-       
 
-def run_test(root_dir, voltha_dir, log_dir):
+    def should_have_all_onus_authenticated(self):
+        testCaseUtils.send_command_to_onos_cli(testCaseUtils.get_dir(self, 'log'),
+                                               'voltha_onu_auth.log', 'aaa-users')
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, 'AUTHORIZED', 'voltha_onu_auth.log')
+        lines = statusLines.splitlines()
+        auth_count = len(lines)
+        assert self.__onuCount == auth_count, 'There are only %s ONUS Authenticated' % auth_count
+
+
+def run_test(onu_count, root_dir, voltha_dir, log_dir, simtype):
     auth = Authentication()
     auth.a_set_log_dirs(root_dir, voltha_dir, log_dir)
-    auth.discover_freeradius_pod_name()
-    auth.discover_freeradius_ip_addr()
-    auth.set_current_freeradius_ip_in_aaa_json()
-    auth.alter_aaa_application_configuration_in_onos_using_aaa_json()
-    auth.execute_authentication_on_rg()
-    auth.verify_authentication_should_have_started()
-    auth.verify_authentication_should_have_completed()
-    auth.verify_authentication_should_have_disconnected()
-    auth.verify_authentication_should_have_terminated()
+    auth.a_configure(onu_count)
+    if simtype == 'ponsim':
+        auth.execute_authentication_on_rg()
+        auth.authentication_should_have_started()
+        auth.authentication_should_have_completed()
+        auth.authentication_should_have_disconnected()
+        auth.authentication_should_have_terminated()
+    elif simtype == 'bbsim':
+        auth.should_have_all_onus_authenticated()