File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -55,12 +55,12 @@ class GithubRepositoryProvider extends RepositoryProvider {
5555
5656 @Override
5757 String getUser () {
58- super . getUser() ?: SysEnv . get(' GITHUB_TOKEN' )
58+ super . getUser() ?: getToken() ?: SysEnv . get(' GITHUB_TOKEN' )
5959 }
6060
6161 @Override
6262 String getPassword () {
63- super . getPassword() ?: (SysEnv . containsKey(' GITHUB_TOKEN' ) ? ' x-oauth-basic' : null )
63+ super . getPassword() ?: ( (getToken() || SysEnv . containsKey(' GITHUB_TOKEN' ) ) ? ' x-oauth-basic' : null )
6464 }
6565
6666 /* * {@inheritDoc} */
Original file line number Diff line number Diff line change @@ -130,6 +130,21 @@ class GithubRepositoryProviderTest extends Specification {
130130 SysEnv . pop()
131131 }
132132
133+ def ' should user specified token instead of github token as creds' () {
134+ given :
135+ SysEnv . push([' GITHUB_TOKEN' : ' 1234567890' ])
136+ and :
137+ def config = new ProviderConfig (' github' , [auth : ' 987654321' ])
138+ def provider = Spy (new GithubRepositoryProvider (' foo/bar' , config))
139+
140+ expect :
141+ provider. getUser() == ' 987654321'
142+ provider. getPassword() == ' x-oauth-basic'
143+
144+ cleanup :
145+ SysEnv . pop()
146+ }
147+
133148 def ' should user from config' () {
134149 given :
135150 SysEnv . push([' GITHUB_TOKEN' : ' 1234567890' ])
You can’t perform that action at this time.
0 commit comments