diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py index f0ef6cb0..5c957032 100644 --- a/github/tests/AllTests.py +++ b/github/tests/AllTests.py @@ -61,3 +61,4 @@ from Issue54 import * from Issue80 import * from Issue87 import * from Issue133 import * +from Issue134 import * diff --git a/github/tests/Issue134.py b/github/tests/Issue134.py new file mode 100644 index 00000000..3da83f82 --- /dev/null +++ b/github/tests/Issue134.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +# Copyright 2012 Vincent Jacques +# vincent@vincent-jacques.net + +# This file is part of PyGithub. http://vincent-jacques.net/PyGithub + +# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see . + +import Framework +import github + + +class Issue134(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/pull/134 + def testGetAuthorizationsFailsWhenAutenticatedThroughOAuth(self): + g = github.Github(self.oauth_token) + raised = False + try: + list(g.get_user().get_authorizations()) + except github.GithubException, exception: + raised = True + self.assertEqual(exception.status, 404) + self.assertTrue(raised) + + def testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword(self): + g = github.Github(self.login, self.password) + self.assertListKeyEqual(g.get_user().get_authorizations(), lambda a: a.note, [None, None, 'cligh', None, None, 'GitHub Android App']) diff --git a/github/tests/ReplayData/Issue134.testGetAuthorizationsFailsWhenAutenticatedThroughOAuth.txt b/github/tests/ReplayData/Issue134.testGetAuthorizationsFailsWhenAutenticatedThroughOAuth.txt new file mode 100644 index 00000000..5c1f709f --- /dev/null +++ b/github/tests/ReplayData/Issue134.testGetAuthorizationsFailsWhenAutenticatedThroughOAuth.txt @@ -0,0 +1,5 @@ +https GET api.github.com None /authorizations {'Authorization': 'token private_token_removed'} null +404 +[('status', '404 Not Found'), ('content-length', '23'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-remaining', '55'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '60'), ('cache-control', ''), ('date', 'Tue, 29 Jan 2013 18:19:32 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"message":"Not Found"} + diff --git a/github/tests/ReplayData/Issue134.testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword.txt b/github/tests/ReplayData/Issue134.testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword.txt new file mode 100644 index 00000000..84eff783 --- /dev/null +++ b/github/tests/ReplayData/Issue134.testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword.txt @@ -0,0 +1,5 @@ +https GET api.github.com None /authorizations {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('content-length', '1930'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4928'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 29 Jan 2013 17:36:52 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1ee9c020e28a8e60c0ed7eee863a79fc"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Tue, 29 Jan 2013 18:19:33 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"token":"private_token_removed","url":"https://api.github.com/authorizations/619306","updated_at":"2012-09-03T08:35:36Z","scopes":[],"created_at":"2012-09-02T15:30:23Z","app":{"url":"http://upverter.com","name":"Upverter"},"note":null,"id":619306,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/648494","updated_at":"2013-01-29T17:36:52Z","scopes":["public_repo","user:email"],"created_at":"2012-09-16T07:13:01Z","app":{"url":"https://travis-ci.org","name":"Travis"},"note":null,"id":648494,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/651653","updated_at":"2012-09-17T21:05:19Z","scopes":["user","repo","gists","delete_repo"],"created_at":"2012-09-17T21:05:19Z","app":{"url":"https://github.com/CMB/cligh","name":"cligh (API)"},"note":"cligh","id":651653,"note_url":"https://github.com/CMB/cligh"},{"token":"private_token_removed","url":"https://api.github.com/authorizations/816763","updated_at":"2012-12-19T09:22:09Z","scopes":[],"created_at":"2012-11-15T17:47:48Z","app":{"url":"https://coderwall.com","name":"coderwall.com"},"note":null,"id":816763,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/974947","updated_at":"2012-12-19T09:17:20Z","scopes":["public_repo"],"created_at":"2012-12-19T09:15:32Z","app":{"url":"http://geekli.st/","name":"Geeklist, Inc."},"note":null,"id":974947,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/1348532","updated_at":"2013-01-27T11:51:21Z","scopes":["repo","user","gist"],"created_at":"2013-01-27T11:51:21Z","app":{"url":"https://github.com/github/android","name":"GitHub Android App (API)"},"note":"GitHub Android App","id":1348532,"note_url":"https://github.com/github/android"}] +