Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Bug 1088752: Add Shape of the Web app to serve JSON.
Shape of the Web is a standalone site that pulls data from JSON files. In order to make the l10n easier initially, we’re going to host the JSON files on Bedrock to take advantage of the existing l10n process. Also adds a middleware to handle adding CORS headers to the locale redirects when loading the JSON.
- Loading branch information
Michael Kelly
committed
Jan 5, 2015
1 parent
305192a
commit fb81024
Showing
12 changed files
with
6,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
from django.http import HttpRequest, HttpResponse | ||
|
||
from bedrock.mozorg.middleware import CrossOriginResourceSharingMiddleware | ||
from bedrock.mozorg.tests import TestCase | ||
|
||
|
||
class TestCrossOriginResourceSharingMiddleware(TestCase): | ||
def setUp(self): | ||
self.middleware = CrossOriginResourceSharingMiddleware() | ||
self.request = HttpRequest() | ||
self.response = HttpResponse() | ||
|
||
def test_match(self): | ||
self.request.path = '/foo/bar/baz/' | ||
|
||
cors_urls = {r'^/foo/bar': '*'} | ||
with self.settings(CORS_URLS=cors_urls): | ||
self.middleware.process_response(self.request, self.response) | ||
self.assertEqual(self.response['Access-Control-Allow-Origin'], '*') | ||
|
||
def test_middle_match(self): | ||
# Ensure that matches in the middle of the URL work. | ||
self.request.path = '/foo/bar/baz/' | ||
|
||
cors_urls = {r'/bar': '*'} | ||
with self.settings(CORS_URLS=cors_urls): | ||
self.middleware.process_response(self.request, self.response) | ||
self.assertEqual(self.response['Access-Control-Allow-Origin'], '*') | ||
|
||
def test_no_match(self): | ||
self.request.path = '/foo/bar/baz/' | ||
|
||
cors_urls = {r'^/biff/bak': '*'} | ||
with self.settings(CORS_URLS=cors_urls): | ||
self.middleware.process_response(self.request, self.response) | ||
self.assertFalse('Access-Control-Allow-Origin' in self.response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Oops, something went wrong.