Commit 67c4b2c 1 parent 5c6e05e commit 67c4b2c Copy full SHA for 67c4b2c
File tree 6 files changed +33
-16
lines changed
6 files changed +33
-16
lines changed Original file line number Diff line number Diff line change @@ -7,23 +7,24 @@ python:
7
7
- ' 3.4'
8
8
- ' 3.5'
9
9
- ' 3.6'
10
+ - ' 3.7'
11
+ - ' 3.8'
10
12
- pypy
11
13
12
- # from https://github.com/travis-ci/travis-ci/issues/9815
13
- # https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905
14
- # Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs
15
14
matrix :
16
- include :
17
- - python : 3.7
18
- dist : xenial
19
- sudo : true
20
-
15
+ exclude :
16
+ - python : 3.4
17
+ - env :
18
+ - DEPEENDENCIES="flask==1.1"
19
+
21
20
env :
22
- - FLASK=0.10.1
23
- - FLASK=0.10
21
+ - DEPEENDENCIES="flask==0.10.1 werkzeug==0.16.1" # pin werkzeug for Flask 10, 10.1 since Flask does not pin it itself.
22
+ - DEPEENDENCIES="flask==0.10 werkzeug==0.16.1"
23
+ - DEPEENDENCIES="flask==1.0"
24
+ - DEPEENDENCIES="flask==1.1"
24
25
25
26
install :
26
- - pip install -U setuptools pep8 six coverage docutils pygments flask==$FLASK
27
+ - pip install -U setuptools pep8 six coverage docutils pygments packaging $DEPEENDENCIES
27
28
28
29
script :
29
30
- coverage erase
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ def get_exception():
124
124
Browsers will first make a preflight request to verify that the resource
125
125
allows cross-origin POSTs with a JSON Content-Type, which can be simulated
126
126
as:
127
- $ curl --include -X OPTIONS http://127.0.0.1:5000/exception \
127
+ $ curl --include -X OPTIONS http://127.0.0.1:5000/api/ exception \
128
128
--header Access-Control-Request-Method:POST \
129
129
--header Access-Control-Request-Headers:Content-Type \
130
130
--header Origin:www.examplesite.com
Original file line number Diff line number Diff line change 10
10
"""
11
11
from flask import request
12
12
from .core import *
13
+ try :
14
+ from urllib .parse import unquote_plus
15
+ except ImportError :
16
+ from urllib import unquote_plus
13
17
14
18
LOG = logging .getLogger (__name__ )
15
19
@@ -173,9 +177,9 @@ def cors_after_request(resp):
173
177
if resp .headers is not None and resp .headers .get (ACL_ORIGIN ):
174
178
LOG .debug ('CORS have been already evaluated, skipping' )
175
179
return resp
176
-
180
+ normalized_path = unquote_plus ( request . path )
177
181
for res_regex , res_options in resources :
178
- if try_match (request . path , res_regex ):
182
+ if try_match (normalized_path , res_regex ):
179
183
LOG .debug ("Request to '%s' matches CORS resource '%s'. Using options: %s" ,
180
184
request .path , get_regexp_pattern (res_regex ), res_options )
181
185
set_cors_headers (resp , res_options )
Original file line number Diff line number Diff line change 33
33
platforms = 'any' ,
34
34
install_requires = install_requires ,
35
35
tests_require = [
36
- 'nose'
36
+ 'nose' ,
37
+ 'packaging'
37
38
],
38
39
test_suite = 'nose.collector' ,
39
40
classifiers = [
Original file line number Diff line number Diff line change 8
8
:copyright: (c) 2016 by Cory Dolphin.
9
9
:license: MIT, see LICENSE for more details.
10
10
"""
11
+ import unittest
12
+
13
+ import flask
14
+ from packaging import version
11
15
from ..base_test import FlaskCorsTestCase
12
16
from flask import Flask , abort
13
17
from flask_cors import *
@@ -198,6 +202,9 @@ def get_with_origins(path):
198
202
self .assertEqual (resp .status_code , 200 )
199
203
self .assertFalse (ACL_ORIGIN in resp .headers )
200
204
205
+ @unittest .skipIf (version .parse (flask .__version__ ) >= version .parse ("1.1" ),
206
+ "Flask 1.1 changed interception behavior, so after request handlers are always run. "
207
+ "This obviates the need for our hacky interception" )
201
208
def test_acl_uncaught_exception_500 (self ):
202
209
'''
203
210
Uncaught exceptions will trigger Flask's internal exception
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ class AppExtensionString(FlaskCorsTestCase):
204
204
def setUp (self ):
205
205
self .app = Flask (__name__ )
206
206
CORS (self .app , resources = r'/api/*' ,
207
- headers = 'Content-Type' ,
207
+ allow_headers = 'Content-Type' ,
208
208
expose_headers = 'X-Total-Count' ,
209
209
origins = 'http://bar.com' )
210
210
@@ -225,6 +225,10 @@ def overridden():
225
225
def index ():
226
226
return 'Welcome'
227
227
228
+ @self .app .route ('/foo.txt' )
229
+ def foo_txt ():
230
+ return 'Welcome'
231
+
228
232
def test_exposed (self ):
229
233
for path in '/api/v1/foo' , '/api/v1/bar' :
230
234
for resp in self .iter_responses (path , origin = 'http://bar.com' ):
You can’t perform that action at this time.
0 commit comments