-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: validate access token #308
Conversation
@@ -38,10 +39,10 @@ func (cmd ConfigCmd) HelpCalled() bool { | |||
return cmd.helpCalled | |||
} | |||
|
|||
func NewConfigCmd(analyticsTrackerFn analytics.TrackerFn) *ConfigCmd { | |||
func NewConfigCmd(service config.Service, analyticsTrackerFn analytics.TrackerFn) *ConfigCmd { |
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.
Pass in the service so we can mock its HTTP client in tests.
} | ||
|
||
// VerifyAccessToken is true if the given access token is valid to make API requests. | ||
func (s Service) VerifyAccessToken(accessToken string, baseURI string) bool { |
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 could move more of the config --set
code into the config domain if it would make the cmd more readable.
@@ -16,5 +21,9 @@ func (c *MockClient) MakeRequest( | |||
) ([]byte, error) { | |||
c.Input = data | |||
|
|||
if c.StatusCode > http.StatusBadRequest { |
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.
Added this for stubbing the HTTP client response.
When setting the access token in the config, check if it works by making an API request. If it's unauthorized, don't write to the config and tell the user.
Requirements
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.