コード例 #1
0
 def test_get_roles_lookup_use_cached(self):
     
     file_path = os.path.join("test_role_map", "roles_map.csv")
     
     ra = RadiusAuth()
     ra.user_roles_map = { "acme" : ['power', 'test'] }
     
     # This should work since the user is in the list
     self.assertEqual(ra.getRolesFromLookup(username="******", file_path=file_path), ['power', 'test'])
     
     # This should return none since jdoe isn't in the cached list
     self.assertEqual(ra.getRolesFromLookup(username="******", file_path=file_path), None)
     
     # Forcing a reload should allow jdoe to be looked up since he is in the list on disk
     self.assertEqual(ra.getRolesFromLookup(username="******", file_path=file_path, force_reload=True), ['admin', 'power', 'user'])
コード例 #2
0
 def test_get_roles_lookup_non_existent(self):
     
     ra = RadiusAuth()
     
     self.assertEqual(ra.user_roles_map, None)
     self.assertEqual(ra.getRolesFromLookup(username="******", file_path=os.path.join("non_existent_path", "roles_map.csv")), None)
     self.assertEqual(ra.user_roles_map, None)
コード例 #3
0
 def test_get_roles_lookup(self):
     
     ra = RadiusAuth()
     
     self.assertEqual(ra.user_roles_map, None)
     self.assertEqual(ra.getRolesFromLookup(username="******", file_path=os.path.join("test_role_map", "roles_map.csv")), ['admin', 'power', 'user'])
     
     # Make sure the roles map did not get cached since we did a user name specific lookup
     self.assertEqual(ra.user_roles_map, None)