Exemplo n.º 1
0
    def test_building_unscoped_accessinfo(self):
        token = client_fixtures.unscoped_token()
        auth_ref = access.AccessInfo.factory(body=token)

        self.assertTrue(auth_ref)
        self.assertIn('token', auth_ref)

        self.assertEqual(auth_ref.auth_token,
                         '3e2813b7ba0b4006840c3825860b86ed')
        self.assertEqual(auth_ref.username, 'exampleuser')
        self.assertEqual(auth_ref.user_id, 'c4da488862bd435c9e6c0275a0d0e49a')

        self.assertEqual(auth_ref.role_ids, [])
        self.assertEqual(auth_ref.role_names, [])

        self.assertIsNone(auth_ref.tenant_name)
        self.assertIsNone(auth_ref.tenant_id)

        self.assertIsNone(auth_ref.auth_url)
        self.assertIsNone(auth_ref.management_url)

        self.assertFalse(auth_ref.scoped)
        self.assertFalse(auth_ref.domain_scoped)
        self.assertFalse(auth_ref.project_scoped)
        self.assertFalse(auth_ref.trust_scoped)

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

        self.assertEqual(auth_ref.expires, token.expires)
        self.assertEqual(auth_ref.issued, token.issued)
Exemplo n.º 2
0
    def test_building_unscoped_accessinfo(self):
        token = client_fixtures.unscoped_token()
        auth_ref = access.AccessInfo.factory(body=token)

        self.assertTrue(auth_ref)
        self.assertIn('token', auth_ref)

        self.assertEqual(auth_ref.auth_token,
                         '3e2813b7ba0b4006840c3825860b86ed')
        self.assertEqual(auth_ref.username, 'exampleuser')
        self.assertEqual(auth_ref.user_id, 'c4da488862bd435c9e6c0275a0d0e49a')

        self.assertEqual(auth_ref.role_ids, [])
        self.assertEqual(auth_ref.role_names, [])

        self.assertIsNone(auth_ref.tenant_name)
        self.assertIsNone(auth_ref.tenant_id)

        self.assertIsNone(auth_ref.auth_url)
        self.assertIsNone(auth_ref.management_url)

        self.assertFalse(auth_ref.scoped)
        self.assertFalse(auth_ref.domain_scoped)
        self.assertFalse(auth_ref.project_scoped)
        self.assertFalse(auth_ref.trust_scoped)

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

        self.assertEqual(auth_ref.expires, token.expires)
        self.assertEqual(auth_ref.issued, token.issued)
Exemplo n.º 3
0
 def test_will_expire_soon(self):
     token = client_fixtures.unscoped_token()
     expires = timeutils.utcnow() + datetime.timedelta(minutes=5)
     token.expires = expires
     auth_ref = access.AccessInfo.factory(body=token)
     self.assertFalse(auth_ref.will_expire_soon(stale_duration=120))
     self.assertTrue(auth_ref.will_expire_soon(stale_duration=300))
     self.assertFalse(auth_ref.will_expire_soon())
Exemplo n.º 4
0
    def test_unscoped_init(self):
        token = client_fixtures.unscoped_token()
        self.stub_auth(json=token)

        c = client.Client(username='******',
                          password='******',
                          auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        self.assertFalse(c.auth_ref.scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertFalse(c.auth_ref.project_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
        self.assertIsNone(c.get_project_id(session=None))
        self.assertEqual(token.user_id, c.get_user_id(session=None))
    def test_unscoped_init(self):
        token = client_fixtures.unscoped_token()
        self.stub_auth(json=token)

        c = client.Client(username='******',
                          password='******',
                          auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        self.assertFalse(c.auth_ref.scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertFalse(c.auth_ref.project_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
        self.assertIsNone(c.get_project_id(session=None))
        self.assertEqual(token.user_id, c.get_user_id(session=None))
Exemplo n.º 6
0
    def test_unscoped_init(self):
        token = client_fixtures.unscoped_token()
        self.stub_auth(json=token)

        # Creating a HTTPClient not using session is deprecated.
        with self.deprecations.expect_deprecations_here():
            c = client.Client(username='******',
                              password='******',
                              auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        with self.deprecations.expect_deprecations_here():
            self.assertFalse(c.auth_ref.scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertFalse(c.auth_ref.project_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
        self.assertIsNone(c.get_project_id(session=None))
        self.assertEqual(token.user_id, c.get_user_id(session=None))
Exemplo n.º 7
0
    def test_unscoped_init(self):
        token = client_fixtures.unscoped_token()
        self.stub_auth(json=token)

        # Creating a HTTPClient not using session is deprecated.
        with self.deprecations.expect_deprecations_here():
            c = client.Client(username='******',
                              password='******',
                              auth_url=self.TEST_URL)
        self.assertIsNotNone(c.auth_ref)
        with self.deprecations.expect_deprecations_here():
            self.assertFalse(c.auth_ref.scoped)
        self.assertFalse(c.auth_ref.domain_scoped)
        self.assertFalse(c.auth_ref.project_scoped)
        self.assertIsNone(c.auth_ref.trust_id)
        self.assertFalse(c.auth_ref.trust_scoped)
        self.assertIsNone(c.get_project_id(session=None))
        self.assertEqual(token.user_id, c.get_user_id(session=None))