forked from voxpupuli/puppet-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thai Pham
committed
Apr 4, 2018
1 parent
ab8733a
commit 46707c1
Showing
7 changed files
with
220 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,6 +384,33 @@ jenkins_credentials { '7e86e9fb-a8af-480f-b596-7191dc02bf38': | |
} | ||
``` | ||
|
||
### `GoogleRobotPrivateKeyCredentials` | ||
|
||
Using this credential type requires that the jenkins `google-oauth-plugin` plugin | ||
has been installed. | ||
|
||
``` | ||
jenkins_credentials { '587690b0-f793-44e6-bc46-889cce58fb71': | ||
ensure => 'present', | ||
impl => 'GoogleRobotPrivateKeyCredentials', | ||
json_key => @END | ||
{ | ||
"client_email": "[email protected]", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n" | ||
} | ||
| END, | ||
} | ||
``` | ||
or | ||
``` | ||
jenkins_credentials { '2f867d0d-e0c7-48a6-a355-1d4fd2ac6c22': | ||
ensure => 'present', | ||
impl => 'GoogleRobotPrivateKeyCredentials', | ||
email_address => '[email protected]', | ||
p12_key => 'LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCg==', | ||
} | ||
``` | ||
|
||
### `jenkins_job` | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,76 @@ | |
} | ||
end | ||
end | ||
|
||
context 'GoogleRobotPrivateKeyCredentials with json_key' do | ||
it 'works with no errors' do | ||
pending('jenkins plugin tests are not consistently failing or succeeding: https://github.com/voxpupuli/puppet-jenkins/issues/839') | ||
pp = base_manifest + <<-EOS | ||
jenkins::plugin { [ | ||
'google-oauth-plugin', | ||
'credentials', | ||
'structs', | ||
'oauth-credentials', | ||
]: } | ||
jenkins_credentials { '587690b0-f793-44e6-bc46-889cce58fb71': | ||
ensure => 'present', | ||
impl => 'GoogleRobotPrivateKeyCredentials', | ||
json_key => @END | ||
{ | ||
"client_email": "[email protected]", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n" | ||
} | ||
| END, | ||
} | ||
EOS | ||
|
||
apply2(pp) | ||
end | ||
|
||
describe file('/var/lib/jenkins/credentials.xml') do | ||
# XXX need to properly compare the XML doc | ||
# trying to match anything other than the id this way might match other | ||
# credentails | ||
it { | ||
pending('jenkins plugin tests are not consistently failing or succeeding: https://github.com/voxpupuli/puppet-jenkins/issues/839') | ||
is_expected.to contain '<projectId>587690b0-f793-44e6-bc46-889cce58fb71</projectId>' | ||
} | ||
end | ||
end | ||
|
||
context 'GoogleRobotPrivateKeyCredentials with email_address and p12_key' do | ||
it 'works with no errors' do | ||
pending('jenkins plugin tests are not consistently failing or succeeding: https://github.com/voxpupuli/puppet-jenkins/issues/839') | ||
pp = base_manifest + <<-EOS | ||
jenkins::plugin { [ | ||
'google-oauth-plugin', | ||
'credentials', | ||
'structs', | ||
'oauth-credentials', | ||
]: } | ||
jenkins_credentials { '2f867d0d-e0c7-48a6-a355-1d4fd2ac6c22': | ||
ensure => 'present', | ||
impl => 'GoogleRobotPrivateKeyCredentials', | ||
email_address => '[email protected]', | ||
p12_key => 'LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCg==', | ||
} | ||
EOS | ||
|
||
apply2(pp) | ||
end | ||
|
||
describe file('/var/lib/jenkins/credentials.xml') do | ||
# XXX need to properly compare the XML doc | ||
# trying to match anything other than the id this way might match other | ||
# credentails | ||
it { | ||
pending('jenkins plugin tests are not consistently failing or succeeding: https://github.com/voxpupuli/puppet-jenkins/issues/839') | ||
is_expected.to contain '<projectId>2f867d0d-e0c7-48a6-a355-1d4fd2ac6c22</projectId>' | ||
} | ||
end | ||
end | ||
end # 'present' do | ||
|
||
context 'absent' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,21 @@ | |
"impl": "GitLabApiTokenImpl", | ||
"description": "GitLab API token", | ||
"api_token": "tokens for days" | ||
}, | ||
{ | ||
"id": "587690b0-f793-44e6-bc46-889cce58fb71", | ||
"domain": null, | ||
"scope": null, | ||
"impl": "GoogleRobotPrivateKeyCredentials", | ||
"json_key": "{\"client_email\":\"[email protected]\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\\\n...\\\\n-----END PRIVATE KEY-----\\\\n\"}" | ||
}, | ||
{ | ||
"id": "2f867d0d-e0c7-48a6-a355-1d4fd2ac6c22", | ||
"domain": null, | ||
"scope": null, | ||
"impl": "GoogleRobotPrivateKeyCredentials", | ||
"email_address": "[email protected]", | ||
"p12_key": "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCg==", | ||
} | ||
] | ||
EOS | ||
|
@@ -92,6 +107,9 @@ | |
key_store_impl | ||
secret_key | ||
access_key | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
|
@@ -125,6 +143,9 @@ | |
key_store_impl | ||
secret_key | ||
access_key | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
|
@@ -158,6 +179,9 @@ | |
key_store_impl | ||
secret_key | ||
access_key | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
|
@@ -191,6 +215,9 @@ | |
key_store_impl | ||
secret_key | ||
access_key | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
|
@@ -223,6 +250,9 @@ | |
key_store_impl | ||
content | ||
file_name | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
|
@@ -245,6 +275,74 @@ | |
expect(provider.public_send(k.to_sym)).to eq cred[k].nil? ? :undef : cred[k] | ||
end | ||
|
||
%w[ | ||
username | ||
password | ||
private_key | ||
passphrase | ||
source | ||
key_store_impl | ||
content | ||
file_name | ||
secret_key | ||
access_key | ||
email_address | ||
p12_key | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
end | ||
end | ||
|
||
shared_examples 'a provider from example hash 7' do | ||
it do | ||
cred = credentials[5] | ||
|
||
expect(provider.name).to eq cred['id'] | ||
expect(provider.ensure).to eq :present | ||
%w[ | ||
domain | ||
scope | ||
impl | ||
json_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq cred[k].nil? ? :undef : cred[k] | ||
end | ||
|
||
%w[ | ||
username | ||
password | ||
private_key | ||
passphrase | ||
source | ||
key_store_impl | ||
content | ||
file_name | ||
secret_key | ||
access_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq :absent | ||
end | ||
end | ||
end | ||
|
||
shared_examples 'a provider from example hash 8' do | ||
it do | ||
cred = credentials[5] | ||
|
||
expect(provider.name).to eq cred['id'] | ||
expect(provider.ensure).to eq :present | ||
%w[ | ||
domain | ||
scope | ||
impl | ||
email_address | ||
p12_key | ||
].each do |k| | ||
expect(provider.public_send(k.to_sym)).to eq cred[k].nil? ? :undef : cred[k] | ||
end | ||
|
||
%w[ | ||
username | ||
password | ||
|
@@ -272,7 +370,7 @@ | |
end | ||
|
||
it 'returns the correct number of instances' do | ||
expect(described_class.instances.size).to eq 6 | ||
expect(described_class.instances.size).to eq 8 | ||
end | ||
|
||
context 'first instance returned' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters