Exemple #1
0
    def test_building_scoped_accessinfo(self):
        token = client_fixtures.project_scoped_token()
        auth_ref = access.AccessInfo.factory(body=token)

        self.assertTrue(auth_ref)
        self.assertIn("token", auth_ref)
        self.assertIn("serviceCatalog", auth_ref)
        self.assertTrue(auth_ref["serviceCatalog"])

        self.assertEqual(auth_ref.auth_token, "04c7d5ffaeef485f9dc69c06db285bdb")
        self.assertEqual(auth_ref.username, "exampleuser")
        self.assertEqual(auth_ref.user_id, "c4da488862bd435c9e6c0275a0d0e49a")

        self.assertEqual(auth_ref.role_ids, ["member_id"])
        self.assertEqual(auth_ref.role_names, ["Member"])

        self.assertEqual(auth_ref.tenant_name, "exampleproject")
        self.assertEqual(auth_ref.tenant_id, "225da22d3ce34b15877ea70b2a575f58")

        self.assertEqual(auth_ref.tenant_name, auth_ref.project_name)
        self.assertEqual(auth_ref.tenant_id, auth_ref.project_id)

        self.assertEqual(auth_ref.auth_url, ("http://public.com:5000/v2.0",))
        self.assertEqual(auth_ref.management_url, ("http://admin:35357/v2.0",))

        self.assertEqual(auth_ref.project_domain_id, "default")
        self.assertEqual(auth_ref.project_domain_name, "Default")
        self.assertEqual(auth_ref.user_domain_id, "default")
        self.assertEqual(auth_ref.user_domain_name, "Default")

        self.assertTrue(auth_ref.scoped)
        self.assertTrue(auth_ref.project_scoped)
        self.assertFalse(auth_ref.domain_scoped)
    def test_building_scoped_accessinfo(self):
        token = client_fixtures.project_scoped_token()
        auth_ref = access.AccessInfo.factory(body=token)

        self.assertTrue(auth_ref)
        self.assertIn('token', auth_ref)
        self.assertIn('serviceCatalog', auth_ref)
        self.assertTrue(auth_ref['serviceCatalog'])

        self.assertEqual(auth_ref.auth_token,
                         '04c7d5ffaeef485f9dc69c06db285bdb')
        self.assertEqual(auth_ref.username, 'exampleuser')
        self.assertEqual(auth_ref.user_id, 'c4da488862bd435c9e6c0275a0d0e49a')

        self.assertEqual(auth_ref.role_ids, ['member_id'])
        self.assertEqual(auth_ref.role_names, ['Member'])

        self.assertEqual(auth_ref.tenant_name, 'exampleproject')
        self.assertEqual(auth_ref.tenant_id,
                         '225da22d3ce34b15877ea70b2a575f58')

        self.assertEqual(auth_ref.tenant_name, auth_ref.project_name)
        self.assertEqual(auth_ref.tenant_id, auth_ref.project_id)

        self.assertEqual(auth_ref.auth_url, ('http://public.com:5000/v2.0',))
        self.assertEqual(auth_ref.management_url, ('http://admin:35357/v2.0',))

        self.assertEqual(auth_ref.project_domain_id, 'default')
        self.assertEqual(auth_ref.project_domain_name, 'Default')
        self.assertEqual(auth_ref.user_domain_id, 'default')
        self.assertEqual(auth_ref.user_domain_name, 'Default')

        self.assertTrue(auth_ref.scoped)
        self.assertTrue(auth_ref.project_scoped)
        self.assertFalse(auth_ref.domain_scoped)
    def test_scoped_init(self):
        self.stub_auth(json=client_fixtures.project_scoped_token())

        c = client.Client(username='******',
                          password='******',
                          tenant_name='exampleproject',
                          auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        self.assertTrue(c.auth_ref.scoped)
        self.assertTrue(c.auth_ref.project_scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
    def test_scoped_init(self):
        self.stub_auth(json=client_fixtures.project_scoped_token())

        c = client.Client(username='******',
                          password='******',
                          tenant_name='exampleproject',
                          auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        self.assertTrue(c.auth_ref.scoped)
        self.assertTrue(c.auth_ref.project_scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
    def test_auth_ref_load(self):
        self.stub_auth(json=client_fixtures.project_scoped_token())

        cl = client.Client(username='******',
                           password='******',
                           tenant_name='exampleproject',
                           auth_url=self.TEST_URL)
        cache = json.dumps(cl.auth_ref)
        new_client = client.Client(auth_ref=json.loads(cache))
        self.assertIsNotNone(new_client.auth_ref)
        self.assertTrue(new_client.auth_ref.scoped)
        self.assertTrue(new_client.auth_ref.project_scoped)
        self.assertFalse(new_client.auth_ref.domain_scoped)
        self.assertIsNone(new_client.auth_ref.trust_id)
        self.assertFalse(new_client.auth_ref.trust_scoped)
        self.assertEqual(new_client.username, 'exampleuser')
        self.assertIsNone(new_client.password)
        self.assertEqual(new_client.management_url, 'http://admin:35357/v2.0')
    def test_auth_ref_load(self):
        self.stub_auth(json=client_fixtures.project_scoped_token())

        cl = client.Client(username='******',
                           password='******',
                           tenant_name='exampleproject',
                           auth_url=self.TEST_URL)
        cache = json.dumps(cl.auth_ref)
        new_client = client.Client(auth_ref=json.loads(cache))
        self.assertIsNotNone(new_client.auth_ref)
        self.assertTrue(new_client.auth_ref.scoped)
        self.assertTrue(new_client.auth_ref.project_scoped)
        self.assertFalse(new_client.auth_ref.domain_scoped)
        self.assertIsNone(new_client.auth_ref.trust_id)
        self.assertFalse(new_client.auth_ref.trust_scoped)
        self.assertEqual(new_client.username, 'exampleuser')
        self.assertIsNone(new_client.password)
        self.assertEqual(new_client.management_url,
                         'http://admin:35357/v2.0')
import mock

from keystoneclient import access
from keystoneclient import httpclient
from keystoneclient.openstack.common import timeutils
from keystoneclient.tests import utils
from keystoneclient.tests.v2_0 import client_fixtures

try:
    import keyring  # noqa
    import pickle  # noqa
except ImportError:
    keyring = None


PROJECT_SCOPED_TOKEN = client_fixtures.project_scoped_token()

# These mirror values from PROJECT_SCOPED_TOKEN
USERNAME = '******'
AUTH_URL = 'http://public.com:5000/v2.0'
TOKEN = '04c7d5ffaeef485f9dc69c06db285bdb'

PASSWORD = '******'
TENANT = 'tenant'
TENANT_ID = 'tenant_id'


class KeyringTest(utils.TestCase):

    def setUp(self):
        if keyring is None:
import mock

from keystoneclient import access
from keystoneclient import httpclient
from keystoneclient.openstack.common import timeutils
from keystoneclient.tests import utils
from keystoneclient.tests.v2_0 import client_fixtures

try:
    import keyring  # noqa
    import pickle  # noqa
except ImportError:
    keyring = None

PROJECT_SCOPED_TOKEN = client_fixtures.project_scoped_token()

# These mirror values from PROJECT_SCOPED_TOKEN
USERNAME = '******'
AUTH_URL = 'http://public.com:5000/v2.0'
TOKEN = '04c7d5ffaeef485f9dc69c06db285bdb'

PASSWORD = '******'
TENANT = 'tenant'
TENANT_ID = 'tenant_id'


class KeyringTest(utils.TestCase):
    def setUp(self):
        if keyring is None:
            self.skipTest(