def test_authenticate(self): # url is None check_url_none(self, auth.KeyStoneV2Authenticator) # url is not None, so it must not throw exception url = "test_url" cls_type = auth.KeyStoneV2Authenticator authObj = auth.KeyStoneV2Authenticator(url=url, type=cls_type, client=None, username=None, password=None, tenant=None) def side_effect_func(url): return url mock_obj = mock.Mock() mock_obj.side_effect = side_effect_func authObj._v2_auth = mock_obj r = authObj.authenticate() self.assertEqual(url, r)
def test__v2_auth(self): username = "******" password = "******" tenant = "tenant" cls_type = auth.KeyStoneV2Authenticator authObj = auth.KeyStoneV2Authenticator(url=None, type=cls_type, client=None, username=username, password=password, tenant=tenant) def side_effect_func(url, body): return body mock_obj = mock.Mock() mock_obj.side_effect = side_effect_func authObj._authenticate = mock_obj body = authObj._v2_auth(mock.Mock()) self.assertEqual(username, body['auth']['passwordCredentials']['username']) self.assertEqual(password, body['auth']['passwordCredentials']['password']) self.assertEqual(tenant, body['auth']['tenantName'])