Bug Fix: Can use app auth

This commit is contained in:
Kyle Hornberg
2018-06-01 13:34:58 -05:00
parent 5fb7ff30ed
commit 27dc4bc361
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -131,10 +131,10 @@ class Base(object):
'Authorization': 'Bearer {}'.format(getattr(self, 'jwt', None))
},
'token': {
'Authorization': 'token {}'.format(self.token)
'Authorization': 'token {}'.format(getattr(self, 'token', None))
},
'installation': {
'Authorization': 'token {}'.format(self.token)
'Authorization': 'token {}'.format(getattr(self, 'token', None))
},
}
headers = requests_kwargs['headers']
+9
View File
@@ -123,3 +123,12 @@ class TestAuth(object):
sut = Octokit(auth='app', app_id=42, private_key=private_key)
assert sut.auth == 'app'
assert sut.jwt is not None
def test_can_get_with_app_authentication(self, mocker):
Request = namedtuple('Request', ['json'])
get = mocker.patch('requests.get')
get.return_value = Request(json=lambda: [{'id': 37}])
with open(os.path.join(os.path.dirname(__file__), 'test.pem'), 'r') as f:
private_key = f.read()
sut = Octokit(auth='app', app_id=42, private_key=private_key)
assert sut.apps.get()