Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class GithubRepositoryProvider extends RepositoryProvider {

@Override
String getUser() {
super.getUser() ?: SysEnv.get('GITHUB_TOKEN')
super.getUser() ?: getToken() ?: SysEnv.get('GITHUB_TOKEN')
}

@Override
String getPassword() {
super.getPassword() ?: (SysEnv.containsKey('GITHUB_TOKEN') ? 'x-oauth-basic' : null)
super.getPassword() ?: ( (getToken() || SysEnv.containsKey('GITHUB_TOKEN')) ? 'x-oauth-basic' : null)
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,21 @@ class GithubRepositoryProviderTest extends Specification {
SysEnv.pop()
}

def 'should user specified token instead of github token as creds' () {
given:
SysEnv.push(['GITHUB_TOKEN': '1234567890'])
and:
def config = new ProviderConfig('github', [auth: '987654321'])
def provider = Spy(new GithubRepositoryProvider('foo/bar', config))

expect:
provider.getUser() == '987654321'
provider.getPassword() == 'x-oauth-basic'

cleanup:
SysEnv.pop()
}

def 'should user from config' () {
given:
SysEnv.push(['GITHUB_TOKEN': '1234567890'])
Expand Down
Loading