Ejemplo n.º 1
0
    def test_update_with_project(self):
        # Can update a user with the deprecated project option rather than
        # default_project_id.
        self.deprecations.expect_deprecations()

        ref = self.new_ref()
        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        self.stub_entity('PATCH',
                         [self.collection_key, ref['id']],
                         status_code=200, entity=ref)

        # Use deprecated project_id rather than new default_project_id.
        param_ref['project_id'] = param_ref.pop('default_project_id')
        params = utils.parameterize(param_ref)

        returned = self.manager.update(ref['id'], **params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(
                getattr(returned, attr),
                ref[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
    def test_create_with_project_and_default_project(self):
        # Can create a user with the deprecated project and default_project_id.
        # The backend call should only pass the default_project_id.
        ref = self.new_ref()

        self.stub_entity('POST',
                         [self.collection_key],
                         status_code=201, entity=ref)

        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        # Add the deprecated project_id in the call, the value will be ignored.
        param_ref['project_id'] = 'project'
        params = utils.parameterize(param_ref)

        returned = self.manager.create(**params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(
                getattr(returned, attr),
                ref[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
Ejemplo n.º 3
0
    def test_create_with_project_and_default_project(self):
        # Can create a user with the deprecated project and default_project_id.
        # The backend call should only pass the default_project_id.
        self.deprecations.expect_deprecations()

        ref = self.new_ref()

        self.stub_entity('POST',
                         [self.collection_key],
                         status_code=201, entity=ref)

        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        # Add the deprecated project_id in the call, the value will be ignored.
        param_ref['project_id'] = 'project'
        params = utils.parameterize(param_ref)

        returned = self.manager.create(**params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(
                getattr(returned, attr),
                ref[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
Ejemplo n.º 4
0
    def test_update_with_project(self):
        # Can update a user with the deprecated project option rather than
        # default_project_id.
        self.deprecations.expect_deprecations()

        ref = self.new_ref()
        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        self.stub_entity('PATCH',
                         [self.collection_key, ref['id']],
                         status_code=200, entity=ref)

        # Use deprecated project_id rather than new default_project_id.
        param_ref['project_id'] = param_ref.pop('default_project_id')
        params = utils.parameterize(param_ref)

        returned = self.manager.update(ref['id'], **params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(
                getattr(returned, attr),
                ref[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
    def test_create(self):
        # This test overrides the generic test case provided by the CrudTests
        # class because the registered limits API supports creating multiple
        # limits in a single POST request. As a result, it returns the
        # registered limits as a list of all the created limits from the
        # request. This is different from what the base test_create() method
        # assumes about keystone's API. The changes here override the base test
        # to closely model how the actual registered limit API behaves.
        ref = self.new_ref()
        manager_ref = ref.copy()
        manager_ref.pop('id')
        req_ref = [manager_ref.copy()]

        self.stub_entity('POST', entity=req_ref, status_code=201)

        returned = self.manager.create(**utils.parameterize(manager_ref))
        self.assertIsInstance(returned, self.model)

        expected_limit = req_ref.pop()
        for attr in expected_limit:
            self.assertEqual(
                getattr(returned, attr),
                expected_limit[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs([expected_limit])
Ejemplo n.º 6
0
    def test_update_with_parent_project(self):
        ref = self.new_ref()
        ref['parent_id'] = uuid.uuid4().hex

        self.stub_entity('PATCH', id=ref['id'], entity=ref, status_code=403)
        req_ref = ref.copy()
        req_ref.pop('id')

        # NOTE(rodrigods): this is the expected behaviour of the Identity
        # server, a different implementation might not fail this request.
        self.assertRaises(ksa_exceptions.Forbidden, self.manager.update,
                          ref['id'], **utils.parameterize(req_ref))
    def test_update_with_parent_project(self):
        ref = self.new_ref()
        ref['parent_id'] = uuid.uuid4().hex

        self.stub_entity('PATCH', id=ref['id'], entity=ref, status_code=403)
        req_ref = ref.copy()
        req_ref.pop('id')

        # NOTE(rodrigods): this is the expected behaviour of the Identity
        # server, a different implementation might not fail this request.
        self.assertRaises(exceptions.Forbidden, self.manager.update,
                          ref['id'], **utils.parameterize(req_ref))
    def test_create_doesnt_log_password(self):
        password = uuid.uuid4().hex
        ref = self.new_ref()

        self.stub_entity('POST', [self.collection_key],
                         status_code=201, entity=ref)

        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        param_ref['password'] = password
        params = utils.parameterize(param_ref)

        self.manager.create(**params)

        self.assertNotIn(password, self.logger.output)
Ejemplo n.º 9
0
    def test_create_doesnt_log_password(self):
        password = uuid.uuid4().hex
        ref = self.new_ref()

        self.stub_entity('POST', [self.collection_key],
                         status_code=201, entity=ref)

        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        param_ref['password'] = password
        params = utils.parameterize(param_ref)

        self.manager.create(**params)

        self.assertNotIn(password, self.logger.output)
Ejemplo n.º 10
0
    def test_update_with_project_and_default_project(self, ref=None):
        ref = self.new_ref()
        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        self.stub_entity('PATCH', [self.collection_key, ref['id']],
                         status_code=200,
                         entity=ref)

        # Add the deprecated project_id in the call, the value will be ignored.
        param_ref['project_id'] = 'project'
        params = utils.parameterize(param_ref)

        returned = self.manager.update(ref['id'], **params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(getattr(returned, attr), ref[attr],
                             'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
    def test_update_with_project_and_default_project(self, ref=None):
        ref = self.new_ref()
        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        self.stub_entity('PATCH',
                         [self.collection_key, ref['id']],
                         status_code=200, entity=ref)

        # Add the deprecated project_id in the call, the value will be ignored.
        param_ref['project_id'] = 'project'
        params = utils.parameterize(param_ref)

        returned = self.manager.update(ref['id'], **params)
        self.assertIsInstance(returned, self.model)
        for attr in ref:
            self.assertEqual(
                getattr(returned, attr),
                ref[attr],
                'Expected different %s' % attr)
        self.assertEntityRequestBodyIs(req_ref)
Ejemplo n.º 12
0
    def test_create(self):
        # This test overrides the generic test case provided by the CrudTests
        # class because the limits API supports creating multiple limits in a
        # single POST request. As a result, it returns the limits as a list of
        # all the created limits from the request. This is different from what
        # the base test_create() method assumes about keystone's API. The
        # changes here override the base test to closely model how the actual
        # limit API behaves.
        ref = self.new_ref()
        manager_ref = ref.copy()
        manager_ref.pop('id')
        req_ref = [manager_ref.copy()]

        self.stub_entity('POST', entity=req_ref, status_code=201)

        returned = self.manager.create(**utils.parameterize(manager_ref))
        self.assertIsInstance(returned, self.model)

        expected_limit = req_ref.pop()
        for attr in expected_limit:
            self.assertEqual(getattr(returned, attr), expected_limit[attr],
                             'Expected different %s' % attr)
        self.assertEntityRequestBodyIs([expected_limit])
 def test_update_invalid_interface(self):
     ref = self.new_ref(interface=uuid.uuid4().hex)
     ref['endpoint'] = "fake_endpoint"
     self.assertRaises(exceptions.ValidationError, self.manager.update,
                       **utils.parameterize(ref))
 def test_create_invalid_interface(self):
     ref = self.new_ref(interface=uuid.uuid4().hex)
     self.assertRaises(exceptions.ValidationError, self.manager.create,
                       **utils.parameterize(ref))
 def test_update_invalid_interface(self):
     ref = self.new_ref(interface=uuid.uuid4().hex)
     ref['endpoint'] = "fake_endpoint"
     self.assertRaises(exceptions.ValidationError, self.manager.update,
                       **utils.parameterize(ref))
 def test_create_invalid_interface(self):
     ref = self.new_ref(interface=uuid.uuid4().hex)
     self.assertRaises(exceptions.ValidationError, self.manager.create,
                       **utils.parameterize(ref))