Esempio n. 1
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
Esempio n. 2
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role", service_id="s1", tenant_id="t1")
     xml_str = role.to_xml()
     self.assertTrue(
         testutils.XMLTools.xmlEqual(xml_str, '<role id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     )
     self.assertEquals(role.service_id, "s1")
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
 def test_role_json_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "dynamic": "test"}}
     self.assertDictEqual(d1, d2)
Esempio n. 5
0
 def test_role_json_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "dynamic": "test"}}
     self.assertDictEqual(d1, d2)
Esempio n. 6
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role", service_id="s1", tenant_id="t1")
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
     self.assertEquals(role.service_id, "s1")
Esempio n. 7
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str,
         '<role id="1" name="the role" serviceId="s1" tenantId="t1"/>'))
     self.assertEquals(role.service_id, "s1")
    def test_role_json_deserialization(self):
        role = Role.from_json('{"name": "the role", "id": "1"}',
                            hints={"contract_attributes": ['id', 'name']})
        self.assertIsInstance(role, Role)
        self.assertEquals(role.id, "1")
        self.assertEquals(role.name, "the role")

        role = Role.from_json('{"role":{"name": "r1", "serviceId": "s1"}}')
        self.assertEquals(role.service_id, "s1")
 def test_role_json_serialization_mapped(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "serviceId": "s1",
                    "tenantId": "t1"}}
     self.assertDictEqual(d1, d2)
Esempio n. 10
0
    def test_role_json_deserialization(self):
        role = Role.from_json('{"name": "the role", "id": "1"}',
                              hints={"contract_attributes": ['id', 'name']})
        self.assertIsInstance(role, Role)
        self.assertEquals(role.id, "1")
        self.assertEquals(role.name, "the role")

        role = Role.from_json('{"role":{"name": "r1", "serviceId": "s1"}}')
        self.assertEquals(role.service_id, "s1")
Esempio n. 11
0
 def test_role_json_serialization_mapped(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "serviceId": "s1",
                    "tenantId": "t1"}}
     self.assertDictEqual(d1, d2)
Esempio n. 12
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
             msg='%s != %s' % (xml_str,
                 expected))
     self.assertEquals(role.service_id, "s1")
Esempio n. 13
0
 def to_model(ref):
     """ Returns Keystone model object based on SQLAlchemy model"""
     if ref:
         return Role(id=str(ref.id),
                     name=ref.name,
                     description=ref.desc,
                     service_id=ref.service_id)
Esempio n. 14
0
 def test_role_static_properties(self):
     role = Role(id=1, name="the role", service_id=1, blank=None)
     self.assertEquals(role.id, "1")
     self.assertEquals(role.name, "the role")
     self.assertEquals(role.service_id, "1")
     self.assertEquals(role.description, None)
     self.assertRaises(AttributeError, getattr, role, 'some_bad_property')
Esempio n. 15
0
 def test_role(self):
     role = Role()
     self.assertEquals(
         str(role.__class__), "<class 'keystone.models.Role'>",
         "role should be of instance "
         "class keystone.models.Role but instead "
         "was '%s'" % str(role.__class__))
     self.assertIsInstance(role, dict, "")
Esempio n. 16
0
 def test_role_validation(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertTrue(role.validate())
Esempio n. 17
0
 def test_role_validation(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertTrue(role.validate())
Esempio n. 18
0
 def test_role_inspection(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertFalse(role.inspect())
Esempio n. 19
0
 def test_role_xml_deserialization(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertIsInstance(role, Role)
Esempio n. 20
0
 def test_role_json_deserialization_types(self):
     role = Role.from_json('{"name": "the role", "id": 1}')
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1",
                       "'id' should always be returned as a string")
     self.assertEquals(role.name, "the role")
Esempio n. 21
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, '<role id="1" name="the role"/>'))
Esempio n. 22
0
 def test_role_json_deserialization(self):
     role = Role.from_json('{"name": "the role", "id": "1"}', hints={"contract_attributes": ["id", "name"]})
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1")
     self.assertEquals(role.name, "the role")
Esempio n. 23
0
 def test_role_json_deserialization_types(self):
     role = Role.from_json('{"name": "the role", "id": 1}')
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1",
                       "'id' should always be returned as a string")
     self.assertEquals(role.name, "the role")
Esempio n. 24
0
 def test_role_inspection(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertFalse(role.inspect())
Esempio n. 25
0
 def test_role_properties(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     self.assertEquals(role["dynamic"], "test")
Esempio n. 26
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str,
                     '<role id="1" name="the role"/>'))