Exemple #1
0
    def rewrite_http_redirect_url(self):
        """rewrite_http_redirect_url prepents CLI host to URL"""
        middleware = EmberCLIRedirectsMiddleware()

        url = '/thread/bob-boberson-rules-1/'
        rewrited_url = middleware.rewrite_http_redirect_url(url)

        self.assertTrue(
            rewrited_url.startswith(settings.MISAGO_EMBER_CLI_ORIGIN))
        self.assertTrue(rewrited_url.endswith(url))
    def rewrite_http_redirect_url(self):
        """rewrite_http_redirect_url prepents CLI host to URL"""
        middleware = EmberCLIRedirectsMiddleware()

        url = '/thread/bob-boberson-rules-1/'
        rewrited_url = middleware.rewrite_http_redirect_url(url)

        self.assertTrue(rewrited_url.startswith(
            settings.MISAGO_EMBER_CLI_ORIGIN))
        self.assertTrue(rewrited_url.endswith(url))
    def test_process_response_rewrites_redirect(self):
        """process_response rewrites redirect"""
        middleware = EmberCLIRedirectsMiddleware()

        request = MockRequest(settings.MISAGO_EMBER_CLI_ORIGIN)

        url = '/thread/bob-boberson-rules-1/'
        response = MockResponse(url, 301)

        with self.settings(DEBUG=True):
            response = MockResponse(url, 301)

            middleware.process_response(request, response)
            self.assertTrue(response['location'].startswith(
                settings.MISAGO_EMBER_CLI_ORIGIN))
            self.assertTrue(response['location'].endswith(url))

        with self.settings(DEBUG=False):
            response = MockResponse(url, 301)

            middleware.process_response(request, response)
            self.assertFalse(response['location'].startswith(
                settings.MISAGO_EMBER_CLI_ORIGIN))
            self.assertTrue(response['location'].endswith(url))
Exemple #4
0
    def test_process_response_rewrites_redirect(self):
        """process_response rewrites redirect"""
        middleware = EmberCLIRedirectsMiddleware()

        request = MockRequest(settings.MISAGO_EMBER_CLI_ORIGIN)

        url = '/thread/bob-boberson-rules-1/'
        response = MockResponse(url, 301)

        with self.settings(DEBUG=True):
            response = MockResponse(url, 301)

            middleware.process_response(request, response)
            self.assertTrue(response['location'].startswith(
                settings.MISAGO_EMBER_CLI_ORIGIN))
            self.assertTrue(response['location'].endswith(url))

        with self.settings(DEBUG=False):
            response = MockResponse(url, 301)

            middleware.process_response(request, response)
            self.assertFalse(response['location'].startswith(
                settings.MISAGO_EMBER_CLI_ORIGIN))
            self.assertTrue(response['location'].endswith(url))