Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit a6d7974

Browse files
committed
#3 Validate get gpg key
Signed-off-by: Uilian Ries <uilianries@gmail.com>
1 parent 4fdc229 commit a6d7974

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

bintray/requester.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import requests
4+
import json
45

56
from requests.auth import HTTPBasicAuth
67

@@ -31,7 +32,10 @@ def _add_status_code(self, response):
3132
:param response: Requests response
3233
:return: Response JSON
3334
"""
34-
json_data = response.json()
35+
try:
36+
json_data = response.json()
37+
except json.decoder.JSONDecodeError:
38+
json_data = {'message': response.content.decode()}
3539
if isinstance(json_data, list):
3640
json_data.append({"statusCode": response.status_code, "error": not response.ok})
3741
else:

tests/test_content_signing.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from bintray.bintray import Bintray
4+
5+
6+
def test_get_org_gpg_public_key():
7+
bintray = Bintray()
8+
response = bintray.get_org_gpg_public_key("jfrog")
9+
assert response.get("error") == False
10+
assert response.get("statusCode") == 200
11+
assert "BEGIN PGP PUBLIC KEY BLOCK" in response.get("message")
12+
13+
14+
def test_get_user_gpg_public_key():
15+
bintray = Bintray()
16+
response = bintray.get_user_gpg_public_key("bintray")
17+
assert response.get("error") == False
18+
assert response.get("statusCode") == 200
19+
assert "BEGIN PGP PUBLIC KEY BLOCK" in response.get("message")
20+

0 commit comments

Comments
 (0)