Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquev6 committed Apr 25, 2013
2 parents aa7df88 + 97af2b6 commit 319ff29
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
6 changes: 3 additions & 3 deletions github/Requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __requestEncode(self, verb, url, parameters, input, encode):
parameters = dict()

requestHeaders = dict()
self.__authenticate(requestHeaders, parameters)
self.__authenticate(url, requestHeaders, parameters)
requestHeaders["User-Agent"] = self.__userAgent

url = self.__makeAbsoluteUrl(url)
Expand Down Expand Up @@ -186,8 +186,8 @@ def __requestRaw(self, verb, url, requestHeaders, input):

return status, responseHeaders, output

def __authenticate(self, requestHeaders, parameters):
if self.__clientId and self.__clientSecret:
def __authenticate(self, url, requestHeaders, parameters):
if self.__clientId and self.__clientSecret and "client_id=" not in url:
parameters["client_id"] = self.__clientId
parameters["client_secret"] = self.__clientSecret
if self.__authorizationHeader is not None:
Expand Down
1 change: 1 addition & 0 deletions github/tests/AllTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@
from Issue139 import *
from Issue140 import *
from Issue142 import *
from Issue158 import *
23 changes: 23 additions & 0 deletions github/tests/Issue158.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

# Copyright 2013 Vincent Jacques vincent@vincent-jacques.net

# This file is part of PyGithub. http://jacquev6.github.com/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 <http://www.gnu.org/licenses/>.

import Framework
import github


class Issue158(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/158
# Warning: I don't have a scret key, so the requests for this test are forged
def testPaginationWithSecretKeyAuthentication(self):
g = github.Github(client_id=self.client_id, client_secret=self.client_secret)
self.assertListKeyEqual(g.get_organization("BeaverSoftware").get_repos("public"), lambda r: r.name, ["FatherBeaver", "PyGithub"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
https
GET
api.github.com
None
/orgs/BeaverSoftware?client_secret=client_secret&client_id=client_id
{'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '716'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"bd349122929faf5f9be3e53d9ad41d08"'), ('date', 'Fri, 11 May 2012 09:07:56 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"Organization","url":"https://api.github.com/orgs/BeaverSoftware","billing_email":"BeaverSoftware@vincent-jacques.net","disk_usage":112,"plan":{"private_repos":0,"space":307200,"name":"free"},"html_url":"https://github.com/BeaverSoftware","blog":null,"login":"BeaverSoftware","public_gists":0,"email":null,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","total_private_repos":0,"private_gists":0,"collaborators":0,"created_at":"2012-02-09T19:20:12Z","company":null,"location":"Paris, France","followers":0,"following":0,"name":null,"owned_private_repos":0,"id":1424031,"public_repos":2}

https
GET
api.github.com
None
/orgs/BeaverSoftware/repos?client_secret=client_secret&type=public&client_id=client_id
{'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '2291'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4bcc5321db433ac18171c121303c77d2"'), ('date', 'Tue, 29 May 2012 18:11:16 GMT'), ('content-type', 'application/json; charset=utf-8'), ('link', '<https://api.github.com/orgs/BeaverSoftware/repos?client_secret=client_secret&type=public&client_id=client_id&page=2>; rel="next", <https://api.github.com/orgs/BeaverSoftware/repos?client_secret=client_secret&type=public&client_id=client_id&page=2>; rel="last"')]
[{"mirror_url":null,"clone_url":"https://github.com/BeaverSoftware/FatherBeaver.git","has_downloads":true,"watchers":2,"updated_at":"2012-02-16T21:51:15Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"","url":"https://api.github.com/repos/BeaverSoftware/FatherBeaver","html_url":"https://github.com/BeaverSoftware/FatherBeaver","has_wiki":true,"has_issues":true,"fork":false,"git_url":"git://github.com/BeaverSoftware/FatherBeaver.git","forks":1,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/BeaverSoftware/FatherBeaver","owner":{"url":"https://api.github.com/users/BeaverSoftware","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","login":"BeaverSoftware","id":1424031},"name":"FatherBeaver","language":null,"description":"","ssh_url":"git@github.com:BeaverSoftware/FatherBeaver.git","pushed_at":null,"created_at":"2012-02-09T19:32:21Z","id":3400397,"full_name":"BeaverSoftware/FatherBeaver"}]

https
GET
api.github.com
None
/orgs/BeaverSoftware/repos?client_secret=client_secret&type=public&client_id=client_id&page=2
{'User-Agent': 'PyGithub/Python'}
null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '2291'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4bcc5321db433ac18171c121303c77d2"'), ('date', 'Tue, 29 May 2012 18:11:16 GMT'), ('content-type', 'application/json; charset=utf-8'), ('link', '<https://api.github.com/orgs/BeaverSoftware/repos?client_secret=client_secret&type=public&client_id=client_id&page=2>; rel="last"')]
[{"mirror_url":null,"clone_url":"https://github.com/BeaverSoftware/PyGithub.git","has_downloads":true,"watchers":1,"updated_at":"2012-05-29T18:09:14Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/BeaverSoftware/PyGithub","html_url":"https://github.com/BeaverSoftware/PyGithub","has_wiki":false,"has_issues":false,"fork":true,"git_url":"git://github.com/BeaverSoftware/PyGithub.git","forks":0,"size":428,"private":false,"open_issues":0,"svn_url":"https://github.com/BeaverSoftware/PyGithub","owner":{"url":"https://api.github.com/users/BeaverSoftware","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","login":"BeaverSoftware","id":1424031},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:BeaverSoftware/PyGithub.git","pushed_at":"2012-05-29T18:05:10Z","created_at":"2012-05-29T18:03:19Z","id":4485562,"full_name":"BeaverSoftware/PyGithub"}]

2 changes: 1 addition & 1 deletion manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function publish {
test
bump
readme
# doc
doc
push
}

Expand Down

0 comments on commit 319ff29

Please sign in to comment.