Created
January 10, 2020 03:00
-
-
Save devgrok/6dd9afce7ad6eee31aa9dd82d2a196c6 to your computer and use it in GitHub Desktop.
fixes for minio IamEc2MetaData
This file contains hidden or 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
Index: .github/workflows/pythonpackage-linux.yml | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- .github/workflows/pythonpackage-linux.yml (revision 3331f178884ac36da622a81e73ab981e25183783) | |
+++ .github/workflows/pythonpackage-linux.yml (date 1578582406638) | |
@@ -26,7 +26,7 @@ | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
- python -m pip install --upgrade pip | |
+ python -m pip install --upgrade pip setuptools | |
pip install urllib3 certifi pytz pyflakes faker nose | |
- name: Test with nosetests | |
run: | | |
Index: minio/api.py | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- minio/api.py (revision 3331f178884ac36da622a81e73ab981e25183783) | |
+++ minio/api.py (date 1578587755526) | |
@@ -194,6 +194,7 @@ | |
Static(access_key, secret_key, session_token), | |
EnvAWS(), | |
EnvMinio(), | |
+ IamEc2MetaData(), | |
] | |
) | |
) | |
Index: .github/workflows/pythonpackage-windows.yml | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- .github/workflows/pythonpackage-windows.yml (revision 3331f178884ac36da622a81e73ab981e25183783) | |
+++ .github/workflows/pythonpackage-windows.yml (date 1578583529250) | |
@@ -26,7 +26,7 @@ | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
- python -m pip install --upgrade pip | |
+ python -m pip install --upgrade pip setuptools | |
pip install urllib3 certifi pytz pyflakes faker nose | |
- name: Test with nosetests | |
run: | | |
Index: minio/credentials/aws_iam.py | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- minio/credentials/aws_iam.py (revision 3331f178884ac36da622a81e73ab981e25183783) | |
+++ minio/credentials/aws_iam.py (date 1578587601955) | |
@@ -40,9 +40,12 @@ | |
def request_cred_list(self): | |
url = self._endpoint + self.iam_security_creds_path | |
- res = self._http_client.urlopen('GET', url) | |
- if res['status'] != 200: | |
- raise ResponseError(res) | |
+ try: | |
+ res = self._http_client.urlopen('GET', url) | |
+ if res['status'] != 200: | |
+ return [] | |
+ except: | |
+ return [] | |
creds = res['data'].split('\n') | |
return creds | |
@@ -50,7 +53,7 @@ | |
url = self._endpoint + self.iam_security_creds_path + "/" + creds_name | |
res = self._http_client.urlopen('GET', url) | |
if res['status'] != 200: | |
- raise ResponseError(res) | |
+ raise ResponseError(res, 'GET') | |
data = json.loads(res['data']) | |
if data['Code'] != 'Success': | |
Index: tests/unit/minio_mocks.py | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- tests/unit/minio_mocks.py (revision 3331f178884ac36da622a81e73ab981e25183783) | |
+++ tests/unit/minio_mocks.py (date 1578588059875) | |
@@ -58,6 +58,11 @@ | |
def release_conn(self): | |
return | |
+ def __getitem__(self, key): | |
+ if key == "status": | |
+ return self.status | |
+ | |
+ | |
class MockConnection(object): | |
def __init__(self): | |
self.requests = [] | |
@@ -67,11 +72,12 @@ | |
# noinspection PyUnusedLocal | |
def request(self, method, url, headers, redirect=False): | |
- return_request = self.requests.pop(0) | |
+ # only pop off matching requests | |
+ return_request = self.requests[0] | |
return_request.mock_verify(method, url, headers) | |
- return return_request | |
+ return self.requests.pop(0) | |
# noinspection PyRedeclaration,PyUnusedLocal,PyUnusedLocal | |
- def urlopen(self, method, url, headers, preload_content=False, body=None, | |
+ def urlopen(self, method, url, headers={}, preload_content=False, body=None, | |
redirect=False): | |
return self.request(method, url, headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment