Exemplo n.º 1
0
class TestHostnameMiddleware(TestCase):
    @override_settings(HOSTNAME='foobar', DEIS_APP='bedrock-dev', DEIS_DOMAIN='example.com')
    def test_base(self):
        self.middleware = HostnameMiddleware()
        self.request = HttpRequest()
        self.response = HttpResponse()

        self.middleware.process_response(self.request, self.response)
        self.assertEqual(self.response['X-Backend-Server'], 'foobar.bedrock-dev.example.com')

    @override_settings(MIDDLEWARE_CLASSES=(list(settings.MIDDLEWARE_CLASSES) +
                                           ['bedrock.mozorg.middleware.HostnameMiddleware']),
                       HOSTNAME='foobar', DEIS_APP='el-dudarino')
    def test_request(self):
        response = self.client.get('/en-US/')
        self.assertEqual(response['X-Backend-Server'], 'foobar.el-dudarino')
Exemplo n.º 2
0
class TestHostnameMiddleware(TestCase):
    @override_settings(HOSTNAME='foobar')
    def test_base(self):
        self.middleware = HostnameMiddleware()
        self.request = HttpRequest()
        self.response = HttpResponse()

        self.middleware.process_response(self.request, self.response)
        self.assertEqual(self.response['X-Backend-Server'], 'foobar')

    @override_settings(MIDDLEWARE_CLASSES=(list(settings.MIDDLEWARE_CLASSES) +
                                           ['bedrock.mozorg.middleware.HostnameMiddleware']),
                       HOSTNAME='foobar')
    def test_request(self):
        response = self.client.get('/en-US/')
        self.assertEqual(response['X-Backend-Server'], 'foobar')
Exemplo n.º 3
0
class TestHostnameMiddleware(TestCase):
    @override_settings(HOSTNAME="foobar", CLUSTER_NAME="oregon-b")
    def test_base(self):
        self.middleware = HostnameMiddleware()
        self.request = HttpRequest()
        self.response = HttpResponse()

        self.middleware.process_response(self.request, self.response)
        self.assertEqual(self.response["X-Backend-Server"], "foobar.oregon-b")

    @override_settings(
        MIDDLEWARE=(list(settings.MIDDLEWARE) +
                    ["bedrock.mozorg.middleware.HostnameMiddleware"]),
        HOSTNAME="foobar",
        CLUSTER_NAME="el-dudarino",
    )
    def test_request(self):
        response = self.client.get("/en-US/")
        self.assertEqual(response["X-Backend-Server"], "foobar.el-dudarino")