getOAuthAppClient returns a GitHub client for authorization testing. The client uses BasicAuth, but instead of username and password, it uses the client id and client secret passed in via environment variables (and will skip the calling test if those vars are not present). Certain API operations (ch
(t *testing.T)
| 125 | // |
| 126 | // See GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#check-an-authorization |
| 127 | func getOAuthAppClient(t *testing.T) *github.Client { |
| 128 | t.Helper() |
| 129 | |
| 130 | username, ok := os.LookupEnv(envKeyClientID) |
| 131 | if !ok { |
| 132 | t.Skipf(msgEnvMissing, envKeyClientID) |
| 133 | } |
| 134 | |
| 135 | password, ok := os.LookupEnv(envKeyClientSecret) |
| 136 | if !ok { |
| 137 | t.Skipf(msgEnvMissing, envKeyClientSecret) |
| 138 | } |
| 139 | |
| 140 | tp := github.BasicAuthTransport{ |
| 141 | Username: strings.TrimSpace(username), |
| 142 | Password: strings.TrimSpace(password), |
| 143 | } |
| 144 | |
| 145 | c, err := github.NewClient(github.WithHTTPClient(tp.Client())) |
| 146 | if err != nil { |
| 147 | t.Fatal(err) |
| 148 | } |
| 149 | return c |
| 150 | } |
no test coverage detected
searching dependent graphs…