Beispiel #1
0
 def from_xml(xml_str):
     try:
         dom = etree.Element("root")
         dom.append(etree.fromstring(xml_str))
         root = dom.find(
             "{http://docs.openstack.org/identity/api/v2.0}tenant")
         if root is None:
             raise fault.BadRequestFault("Expecting Tenant")
         id = root.get("id")
         name = root.get("name")
         enabled = root.get("enabled")
         if enabled is None or enabled == "true" or enabled == "yes":
             set_enabled = True
         elif enabled == "false" or enabled == "no":
             set_enabled = False
         else:
             raise fault.BadRequestFault("Bad enabled attribute!")
         desc = root.find("{http://docs.openstack.org/identity/api/v2.0}"
                          "description")
         if desc is None:
             description = None
         else:
             description = desc.text
         return models.Tenant(id=id, name=name, description=description,
             enabled=set_enabled)
     except etree.LxmlError as e:
         raise fault.BadRequestFault("Cannot parse Tenant", str(e))
    def __init__(self, *args, **kwargs):
        super(LogicTypesAuthTestCase, self).__init__(*args, **kwargs)

        self.user = models.User(id='u1', name='john', username='******')
        self.role = models.Role(id=1, name='Admin')
        self.user.rolegrants = models.Roles([self.role], links=None)
        self.token = models.Token(id='abc123T',
                                  user_id=self.user.id,
                                  expires=datetime.date(2000, 1, 31))
        self.tenant = models.Tenant(id='ten8', name='The Tenant')
        self.token.tenant = self.tenant
        self.base_urls = [
            models.EndpointTemplate(
                id="1",
                internal_url="http://127.0.0.1/v1/%tenant_id%",
                public_url="http://internet.com/v1/%tenant_id%",
                admin_url="http://private.net/v1/",
                version_id="v1",
                version_url="http://127.0.0.1/v1/",
                version_info="http://127.0.0.1/",
                region="RegionOne",
                service_id="0"),
            models.EndpointTemplate(
                id="2",
                internal_url="http://127.0.0.1/v1/%tenant_id%",
                public_url="http://internet.com/v1/%tenant_id%",
                service_id="0")
        ]
        self.url_types = ["internal", "public", "admin"]
Beispiel #3
0
    def test_basic_tenant_create(self):
        tenant = models.Tenant(name="Tee One", description="This is T1",
                               enabled=True)

        original_tenant = tenant.copy()
        new_tenant = api.TENANT.create(tenant)
        self.assertIsInstance(new_tenant, models.Tenant)
        for k, v in original_tenant.items():
            if k not in ['id'] and k in new_tenant:
                self.assertEquals(new_tenant[k], v)
 def test_tenant_update(self):
     id = "T3%s" % uuid.uuid4().hex
     tenant = models.Tenant(id=id,
                            name="Tee Three",
                            description="This is T3",
                            enabled=True)
     new_tenant = api.TENANT.create(tenant)
     new_tenant.enabled = False
     new_tenant.description = "This is UPDATED T3"
     api.TENANT.update(id, new_tenant)
     updated_tenant = api.TENANT.get(id)
     self.assertEqual(new_tenant, updated_tenant)
Beispiel #5
0
    def test_tenant_create_with_id(self):
        tenant = models.Tenant(id="T2%s" % uuid.uuid4().hex, name="Tee Two",
                               description="This is T2", enabled=True)

        original_tenant = tenant.to_dict()
        new_tenant = api.TENANT.create(tenant)
        self.assertIsInstance(new_tenant, models.Tenant)
        for k, v in original_tenant.items():
            if k in new_tenant:
                self.assertEquals(new_tenant[k], v,
                                  "'%s' did not match" % k)
        self.assertEqual(original_tenant['tenant'], tenant,
                         "Backend modified provided tenant")
Beispiel #6
0
def add_tenant(name):
    obj = models.Tenant()
    obj.name = name
    obj.enabled = True
    db_api.TENANT.create(obj)