Exemple #1
0
    def test_get_auth(self):
        auth_lines = [
            """id = a1; type = InfrastructureManager; username = someuser; password = somepass """,
            """id = ''; type = VMRC; username = someuser; password = somepass; """
        ]
        auth = Authentication(Authentication.read_auth_data(auth_lines))
        auth_data = auth.getAuthInfoByID("a1")
        self.assertEqual(auth_data, [{
            'id': 'a1',
            'password': "******",
            'type': 'InfrastructureManager',
            'username': '******'
        }])
        auth_data = auth.getAuthInfo("VMRC")
        self.assertEqual(auth_data, [{
            'id': '',
            'password': "******",
            'type': 'VMRC',
            'username': '******'
        }])

        auth_lines = [
            """id = 1a; type = InfrastructureManager; username = someuser; password = somepass """
        ]
        with self.assertRaises(Exception) as ex:
            auth = Authentication(Authentication.read_auth_data(auth_lines))
        self.assertEqual("Incorrect value in auth item id: 1a",
                         str(ex.exception))
Exemple #2
0
 def test_get_auth(self):
     auth_lines = [
         """id = 1; type = InfrastructureManager; username = someuser; password = somepass """,
         """id = 2; type = VMRC; username = someuser; password = somepass; """
     ]
     auth = Authentication(Authentication.read_auth_data(auth_lines))
     auth_data = auth.getAuthInfoByID("1")
     self.assertEqual(auth_data, [{
         'id': '1',
         'password': "******",
         'type': 'InfrastructureManager',
         'username': '******'
     }])
     auth_data = auth.getAuthInfo("VMRC")
     self.assertEqual(auth_data, [{
         'id': '2',
         'password': "******",
         'type': 'VMRC',
         'username': '******'
     }])