-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NXPY-258: File download from aws S3 with auto-redirect not working in…
… case of OAuth (#305) * NXPY-258: File download from aws S3 with auto-redirect not working in case of OAuth
- Loading branch information
1 parent
dd53b7a
commit 8a1fec9
Showing
3 changed files
with
67 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
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,41 @@ | ||
def test_request(server): | ||
|
||
import requests | ||
from unittest.mock import patch, Mock | ||
from ..constants import NUXEO_SERVER_URL | ||
|
||
flag = True | ||
|
||
def _request_no_aws(*args, **kwargs): | ||
nonlocal flag | ||
resp = Mock() | ||
resp.status_code = 302 | ||
resp.headers = {"Location": f"{NUXEO_SERVER_URL}/api/v1/drive/configuration"} | ||
if flag: | ||
flag = False | ||
return resp | ||
resp = Mock() | ||
resp.status_code = 200 | ||
flag = True | ||
return resp | ||
|
||
def _request_aws(*args, **kwargs): | ||
nonlocal flag | ||
resp = Mock() | ||
resp.status_code = 302 | ||
resp.headers = {"Location": "amazonaws.com"} | ||
if flag: | ||
flag = False | ||
return resp | ||
resp = Mock() | ||
resp.status_code = 200 | ||
flag = True | ||
return resp | ||
|
||
with patch.object(requests.sessions.Session, "request", new=_request_no_aws): | ||
resp = server.client.request("GET", "json/cmis") | ||
assert resp.status_code == 200 | ||
|
||
with patch.object(requests.sessions.Session, "request", new=_request_aws): | ||
resp = server.client.request("GET", "json/cmis") | ||
assert resp.status_code == 200 |