-
Notifications
You must be signed in to change notification settings - Fork 8
API: fix GitHub access tests #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
GitHub no longer accepts user password authenitcation for its APIs, so we now use personal access tokens to make API requests.
src/punx/github_handler.py
Outdated
|
||
uname, pwd = open(creds_file_name, 'r').read().strip().split() | ||
return dict(user=uname, password=pwd) | ||
return open(creds_file_name, 'r').read().strip().split()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to keep the credentials file to contain: github_email password token
with any whitespace separator. As written, this returns github_email
which is then used below as token
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is used by multiple software, needs to keep same structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file can keep its structure but, to return the token, this function must return item the last item ([-1]
) from the list. Will this also work with your own version of the file that only contains the token?
src/punx/github_handler.py
Outdated
@@ -59,45 +59,45 @@ | |||
|
|||
def get_BasicAuth_credentials(creds_file_name = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function gets the GitHub credentials but they are no longer BasicAuth
(username & password). I suggest changing the name to get_GitHub_credentials
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request function name be changed.
src/punx/github_handler.py
Outdated
:param str repo_name: name of repository in https://github.com/nexusformat (default: *definitions*) | ||
:returns bool: True if using GitHub credentials | ||
""" | ||
repo_name = repo_name or self.appName | ||
|
||
|
||
token = get_BasicAuth_credentials() if token is None else token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with above refactor so get_GitHub_credentials()
returns a dict:
token = get_GitHub_credentials()["token"] if token is None else token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should get_GitHub_credentials return a dictionary? Only the token is ever used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true within this software. But on my system, the exact same file is used in other contexts that need the additional content and formatting. A change here would compel revision to the other software.
Why should the current interface change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you import get_GitHub_credentials
from punx to other packages?
src/punx/github_handler.py
Outdated
@@ -158,15 +162,15 @@ def download(self): | |||
#requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |||
disable_warnings(InsecureRequestWarning) | |||
|
|||
creds = get_BasicAuth_credentials() | |||
token = get_BasicAuth_credentials() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op cit.
token = get_GitHub_credentials()["token"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carterbox : Thanks for the PR! Changes requested as noted.
Also, once we are done with technical corrections and updates to make the code compliant with Python3, I intend to apply |
BTW, the commands to run the tests are listed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Structure of credentials file and how to get the token from the file still needs changes.
Ya, I just wanted feedback on my comments before I proceeded with any changes. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carterbox : LGTM, Thanks! Merge when ready!
Fixes broken tests by updating GitHub authentication from username/password to personal token and by changing the branch pointer to "main" from "master".