Exemplo n.º 1
0
    def test_add_api_superuser_to_project_logs_error(self):
        auth.api_client_set().AndRaise(RuntimeError('catch me'))
        self.app.logger.exception(IsA(basestring), 'PID', IsA(RuntimeError))

        self.mox.ReplayAll()
        with self.app.test_request_context():
            auth.add_api_superuser_to_project('PID')
Exemplo n.º 2
0
    def test_add_api_superuser_to_project_logs_error(self):
        auth.api_client_set().AndRaise(RuntimeError('catch me'))
        self.app.logger.exception(IsA(basestring), 'PID', IsA(RuntimeError))

        self.mox.ReplayAll()
        with self.app.test_request_context():
            auth.add_api_superuser_to_project('PID')
Exemplo n.º 3
0
    def test_api_cs_for_project_denied_at_last(self):
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndRaise(Unauthorized('denied'))
        auth.add_api_superuser_to_project('PID')
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndReturn('FAKE_CS')
        auth.admin_role_id('FAKE_CS').AndReturn(None)

        self.mox.ReplayAll()
        with self.app.test_request_context():
            self.assertRaises(RuntimeError, auth.api_client_set, 'PID')
Exemplo n.º 4
0
    def test_api_cs_for_project_denied_at_last(self):
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndRaise(Unauthorized('denied'))
        auth.add_api_superuser_to_project('PID')
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndReturn('FAKE_CS')
        auth.admin_role_id('FAKE_CS').AndReturn(None)

        self.mox.ReplayAll()
        with self.app.test_request_context():
            self.assertRaises(RuntimeError, auth.api_client_set, 'PID')
Exemplo n.º 5
0
    def test_add_api_superuser_to_project_works(self):
        tcs = self._fake_client_set_factory()
        tcs.http_client.access['user'] = {
            'id': 'API_SU_UID',
            'roles': [ { 'id': 'AR_ID', 'name': 'admin' } ]
        }

        auth.api_client_set().AndReturn(tcs)
        tcs.identity_admin.roles.add_user_role('API_SU_UID', 'AR_ID', 'PID')

        self.mox.ReplayAll()
        with self.app.test_request_context():
            auth.add_api_superuser_to_project('PID')
Exemplo n.º 6
0
    def test_api_cs_for_project_denied_at_first(self):
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndRaise(Unauthorized('denied'))
        auth.add_api_superuser_to_project('PID')
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndReturn('FAKE_CS')
        auth.admin_role_id('FAKE_CS').AndReturn('ROLE')

        self.mox.ReplayAll()
        with self.app.test_request_context():
            cs = auth.api_client_set('PID')
        self.assertEquals(cs, 'FAKE_CS')
Exemplo n.º 7
0
    def test_api_cs_for_project_denied_at_first(self):
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndRaise(Unauthorized('denied'))
        auth.add_api_superuser_to_project('PID')
        auth._client_set('test_admin', 'test_p@ssw0rd',
                         tenant_id='PID') \
                .AndReturn('FAKE_CS')
        auth.admin_role_id('FAKE_CS').AndReturn('ROLE')

        self.mox.ReplayAll()
        with self.app.test_request_context():
            cs = auth.api_client_set('PID')
        self.assertEquals(cs, 'FAKE_CS')
Exemplo n.º 8
0
    def test_add_api_superuser_to_project_works(self):
        tcs = self._fake_client_set_factory()
        tcs.http_client.access['user'] = {
            'id': 'API_SU_UID',
            'roles': [{
                'id': 'AR_ID',
                'name': 'admin'
            }]
        }

        auth.api_client_set().AndReturn(tcs)
        tcs.identity_admin.roles.add_user_role('API_SU_UID', 'AR_ID', 'PID')

        self.mox.ReplayAll()
        with self.app.test_request_context():
            auth.add_api_superuser_to_project('PID')