コード例 #1
0
    def test_object_store(self):
        # Returns the object store service data when it's in the catalog
        context = context_processors.horizon(self.request)
        self.assertNotEqual(None, context['object_store_configured'])

        # Returns None when the object store is not in the catalog
        new_catalog = [service for service in self.request.user.service_catalog
                            if service['type'] != 'object-store']
        self.request.user.service_catalog = new_catalog
        context = context_processors.horizon(self.request)
        self.assertEqual(None, context['object_store_configured'])
コード例 #2
0
    def test_authorized_tenants(self):
        tenant_list = self.context['authorized_tenants']
        self.request.user.authorized_tenants = None  # Reset from setUp
        self.mox.StubOutWithMock(api, 'tenant_list_for_token')
        api.tenant_list_for_token(IsA(http.HttpRequest), self.token.id) \
                                  .AndReturn(tenant_list)
        self.mox.ReplayAll()

        middleware.HorizonMiddleware().process_request(self.request)
        # Without dashboard that has "supports_tenants = True"
        context = context_processors.horizon(self.request)
        self.assertEqual(len(context['authorized_tenants']), 0)

        # With dashboard that has "supports_tenants = True"
        class ProjectDash(Dashboard):
            supports_tenants = True

        self.request.horizon['dashboard'] = ProjectDash
        self.assertTrue(self.request.user.is_authenticated())
        context = context_processors.horizon(self.request)
        self.assertItemsEqual(context['authorized_tenants'], tenant_list)
コード例 #3
0
    def test_authorized_tenants(self):
        tenant_list = self.TEST_CONTEXT['authorized_tenants']
        self.mox.StubOutWithMock(api, 'tenant_list_for_token')
        api.tenant_list_for_token(IsA(http.HttpRequest),
                                  self.TEST_TOKEN,
                                  endpoint_type='internalURL') \
                                  .AndReturn(tenant_list)
        self.mox.ReplayAll()

        context = context_processors.horizon(self.request)
        self.assertEqual(len(context['authorized_tenants']), 1)
        tenant = context['authorized_tenants'].pop()
        self.assertEqual(tenant['id'], self.TEST_TENANT)
コード例 #4
0
    def test_authorized_tenants(self):
        tenant_list = self.context['authorized_tenants']
        self.request.user.authorized_tenants = None  # Reset from setUp
        self.mox.StubOutWithMock(api, 'tenant_list_for_token')
        api.tenant_list_for_token(IsA(http.HttpRequest),
                                  self.token.id,
                                  endpoint_type='internalURL') \
                                  .AndReturn(tenant_list)
        self.mox.ReplayAll()

        middleware.HorizonMiddleware().process_request(self.request)
        context = context_processors.horizon(self.request)
        self.assertEqual(len(context['authorized_tenants']), 1)
        tenant = context['authorized_tenants'].pop()
        self.assertEqual(tenant.id, self.tenant.id)