VOL-1665: BBSim Radius Authentication Test Case

BBSim specific Test Case for Radius Authentication
Consists of verifying that all 16 ONUs have authenticated
- Restart Onos AAA application whcih is know to return exception
  upon executing aaa-users command
- Address comments from review

Change-Id: I5f7fb231067f77a1f2e52ecde7328f702b333fd1
diff --git a/tests/atests/common/authentication.py b/tests/atests/common/authentication.py
index b5196d7..a03f17e 100644
--- a/tests/atests/common/authentication.py
+++ b/tests/atests/common/authentication.py
@@ -36,14 +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 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')
@@ -102,28 +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.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()