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(httpretty.POST,
                         [self.collection_key],
                         status=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.º 2
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(exceptions.Forbidden, self.manager.update,
                          ref['id'], **utils.parameterize(req_ref))
Ejemplo n.º 3
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.º 4
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(httpretty.PATCH, [self.collection_key, ref["id"]], status=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.assertTrue(isinstance(returned, self.model))
        for attr in ref:
            self.assertEqual(getattr(returned, attr), ref[attr], "Expected different %s" % attr)
        self.assertEntityRequestBodyIs(req_ref)
Ejemplo n.º 5
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.º 6
0
    def test_create_with_project(self):
        # Can create a user with the deprecated project option rather than
        # default_project_id.
        ref = self.new_ref()

        self.stub_entity(httpretty.POST, [self.collection_key], status=201, entity=ref)

        req_ref = ref.copy()
        req_ref.pop("id")
        param_ref = req_ref.copy()
        # 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.create(**params)
        self.assertTrue(isinstance(returned, self.model))
        for attr in ref:
            self.assertEqual(getattr(returned, attr), ref[attr], "Expected different %s" % attr)
        self.assertEntityRequestBodyIs(req_ref)
Ejemplo n.º 7
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(httpretty.PATCH, [self.collection_key, ref['id']],
                         status=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.º 8
0
    def test_create_with_project(self):
        # Can create a user with the deprecated project option rather than
        # default_project_id.
        ref = self.new_ref()

        self.stub_entity(httpretty.POST, [self.collection_key],
                         status=201,
                         entity=ref)

        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()
        # 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.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.º 9
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)
Ejemplo n.º 10
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.
        ref = self.new_ref()

        self.stub_entity(httpretty.POST, [self.collection_key],
                         status=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.º 11
0
    def test_create_with_project(self):
        # Can create a user with the deprecated project option rather than
        # 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()
        # 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.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.º 12
0
    def test_update_with_project(self):
        # Can update a user with the deprecated project option rather than
        # default_project_id.
        ref = self.new_ref()
        req_ref = ref.copy()
        req_ref.pop('id')
        param_ref = req_ref.copy()

        self.stub_entity(httpretty.PATCH,
                         [self.collection_key, ref['id']],
                         status=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.assertTrue(isinstance(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_invalid_interface(self):
     ref = self.new_ref(interface=uuid.uuid4().hex)
     self.assertRaises(Exception, self.manager.update,
                       **utils.parameterize(ref))
Ejemplo n.º 14
0
 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))
Ejemplo n.º 15
0
 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))