beaker-aws 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/beaker-aws/version.rb +1 -1
- data/lib/beaker/hypervisor/aws_sdk.rb +10 -7
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +38 -3
- data/spec/helpers.rb +30 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGZkMzdjNjc1Y2JkNzVhODczYWU5MTQ2YjZkNzQ0NDlmYjBmZTA2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWViMzI5MTIxMDRmZDk0NGE3Y2NjNDJmMjY2NzY5MDI0MWEwZmJlMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTUwODFlZmZlOGMxZTI4MDdjZDVlNTc1MWI2N2Y5Y2IxYjZiOTEzOGJhNWEx
|
10
|
+
YTAwODg5ODI1ZjIxNTI3MDgyYjRlMWIyNzFjMTM4ZDIyNGJkNGFkMDcyYTVh
|
11
|
+
MjljZGMzNDJkNTg5NmQ2YjYyZTY5MWI5NzYwMDkwMWQ2NGU0NjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzVmOGUzOWQ3NTY2ODBkN2I4M2QwNDQ5NGRhYWYyNmQ2MjNiYjYyYWYyNjg3
|
14
|
+
YmFiNDA2ZmFjMzk0YThmZGU3OTExNTljY2MxODQ5OTAwYWMxZGNkNzdhMWE2
|
15
|
+
ZDIxMDZkNjg4NzZjNTkxNzE3NDAwMTlkYmMwYTRlMWI1YjI4ZGI=
|
data/lib/beaker-aws/version.rb
CHANGED
@@ -23,16 +23,17 @@ module Beaker
|
|
23
23
|
@logger = options[:logger]
|
24
24
|
|
25
25
|
# Get AWS credentials
|
26
|
-
creds = load_credentials()
|
26
|
+
creds = options[:use_fog_credentials] ? load_credentials() : Hash.new
|
27
27
|
|
28
28
|
config = {
|
29
29
|
:access_key_id => creds[:access_key],
|
30
30
|
:secret_access_key => creds[:secret_key],
|
31
|
+
:session_token => creds[:session_token],
|
31
32
|
:logger => Logger.new($stdout),
|
32
33
|
:log_level => :debug,
|
33
34
|
:log_formatter => AWS::Core::LogFormatter.colored,
|
34
35
|
:max_retries => 12,
|
35
|
-
}
|
36
|
+
}.delete_if{ |k,v| v.nil? }
|
36
37
|
AWS.config(config)
|
37
38
|
|
38
39
|
@ec2 = AWS::EC2.new()
|
@@ -643,7 +644,7 @@ module Beaker
|
|
643
644
|
def set_hostnames
|
644
645
|
if @options[:use_beaker_hostnames]
|
645
646
|
@hosts.each do |host|
|
646
|
-
host[:vmhostname] = host
|
647
|
+
host[:vmhostname] = host.name
|
647
648
|
if host['platform'] =~ /el-7/
|
648
649
|
# on el-7 hosts, the hostname command doesn't "stick" randomly
|
649
650
|
host.exec(Command.new("hostnamectl set-hostname #{host.name}"))
|
@@ -961,8 +962,9 @@ module Beaker
|
|
961
962
|
|
962
963
|
if provider.set?
|
963
964
|
{
|
964
|
-
:access_key
|
965
|
-
:secret_key
|
965
|
+
:access_key => provider.access_key_id,
|
966
|
+
:secret_key => provider.secret_access_key,
|
967
|
+
:session_token => provider.session_token,
|
966
968
|
}
|
967
969
|
else
|
968
970
|
{}
|
@@ -981,8 +983,9 @@ module Beaker
|
|
981
983
|
raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_secret_access_key]
|
982
984
|
|
983
985
|
{
|
984
|
-
:access_key
|
985
|
-
:secret_key
|
986
|
+
:access_key => default[:aws_access_key_id],
|
987
|
+
:secret_key => default[:aws_secret_access_key],
|
988
|
+
:session_token => default[:aws_session_token],
|
986
989
|
}
|
987
990
|
end
|
988
991
|
|
@@ -10,6 +10,7 @@ module Beaker
|
|
10
10
|
and_return({
|
11
11
|
:access_key => fog_file_contents[:default][:aws_access_key_id],
|
12
12
|
:secret_key => fog_file_contents[:default][:aws_secret_access_key],
|
13
|
+
:session_token => fog_file_contents[:default][:aws_session_token],
|
13
14
|
})
|
14
15
|
|
15
16
|
|
@@ -60,6 +61,7 @@ module Beaker
|
|
60
61
|
creds = aws.load_fog_credentials
|
61
62
|
expect( creds[:access_key] ).to eq("IMANACCESSKEY")
|
62
63
|
expect( creds[:secret_key] ).to eq("supersekritkey")
|
64
|
+
expect( creds[:session_token] ).to eq('somecrazylongsupersessiontoken!#%^^*(%$^&@$%#!!#$asd;fjapugfrejklvznb;jdgfjiadvij')
|
63
65
|
end
|
64
66
|
|
65
67
|
|
@@ -70,6 +72,30 @@ module Beaker
|
|
70
72
|
creds = aws.load_env_credentials
|
71
73
|
expect( creds[:access_key] ).to eq("IMANACCESSKEY")
|
72
74
|
expect( creds[:secret_key] ).to eq("supersekritkey")
|
75
|
+
expect( creds[:session_token] ).to be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'from environment variables with session_token' do
|
79
|
+
ENV['AWS_ACCESS_KEY_ID'] = "IMANACCESSKEY"
|
80
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = "supersekritkey"
|
81
|
+
ENV['AWS_SESSION_TOKEN'] = 'somesuperlongsessiontokenspecialcharsblah!#%$#@$^!@qewpofudjsvjm'
|
82
|
+
|
83
|
+
creds = aws.load_env_credentials
|
84
|
+
expect( creds[:access_key] ).to eq("IMANACCESSKEY")
|
85
|
+
expect( creds[:secret_key] ).to eq("supersekritkey")
|
86
|
+
expect( creds[:session_token] ).to eq('somesuperlongsessiontokenspecialcharsblah!#%$#@$^!@qewpofudjsvjm')
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'dont read fog credentials' do
|
92
|
+
let(:options) { make_opts.merge({ 'use_fog_credentials' => false }) }
|
93
|
+
|
94
|
+
it 'not using fog' do
|
95
|
+
creds = aws.load_env_credentials
|
96
|
+
expect( creds[:access_key] ).to eq(nil)
|
97
|
+
expect( creds[:secret_key] ).to eq(nil)
|
98
|
+
expect( options[:use_fog_credentials] ).to eq(false)
|
73
99
|
end
|
74
100
|
end
|
75
101
|
|
@@ -626,11 +652,12 @@ module Beaker
|
|
626
652
|
it 'sets the the vmhostname to the beaker config name for each host' do
|
627
653
|
options[:use_beaker_hostnames] = true
|
628
654
|
@hosts.each do |host|
|
629
|
-
host
|
655
|
+
host.instance_eval("@name = 'prettyponyprincess'")
|
630
656
|
end
|
631
657
|
expect(set_hostnames).to eq(@hosts)
|
632
658
|
@hosts.each do |host|
|
633
|
-
expect(host[:vmhostname]).
|
659
|
+
expect(host[:vmhostname]).not_to eq(nil)
|
660
|
+
expect(host[:vmhostname]).to eq(host.name)
|
634
661
|
expect(host[:vmhostname]).to eq(host.hostname)
|
635
662
|
end
|
636
663
|
end
|
@@ -949,17 +976,25 @@ module Beaker
|
|
949
976
|
|
950
977
|
describe '#load_fog_credentials' do
|
951
978
|
# Receive#and_call_original below allows us to test the core load_fog_credentials method
|
952
|
-
let(:creds) { {:access_key => 'awskey', :secret_key => 'awspass'} }
|
953
979
|
let(:dot_fog) { '.fog' }
|
954
980
|
subject(:load_fog_credentials) { aws.load_fog_credentials(dot_fog) }
|
955
981
|
|
956
982
|
it 'returns loaded fog credentials' do
|
983
|
+
creds = {:access_key => 'awskey', :secret_key => 'awspass', :session_token => nil}
|
957
984
|
fog_hash = {:default => {:aws_access_key_id => 'awskey', :aws_secret_access_key => 'awspass'}}
|
958
985
|
expect(aws).to receive(:load_fog_credentials).and_call_original
|
959
986
|
expect(YAML).to receive(:load_file).and_return(fog_hash)
|
960
987
|
expect(load_fog_credentials).to eq(creds)
|
961
988
|
end
|
962
989
|
|
990
|
+
it 'returns loaded fog credentials with session token' do
|
991
|
+
creds = {:access_key => 'awskey', :secret_key => 'awspass', :session_token => 'sometoken'}
|
992
|
+
fog_hash = {:default => {:aws_access_key_id => 'awskey', :aws_secret_access_key => 'awspass', :aws_session_token => 'sometoken'}}
|
993
|
+
expect(aws).to receive(:load_fog_credentials).and_call_original
|
994
|
+
expect(YAML).to receive(:load_file).and_return(fog_hash)
|
995
|
+
expect(load_fog_credentials).to eq(creds)
|
996
|
+
end
|
997
|
+
|
963
998
|
context 'raises errors' do
|
964
999
|
it 'if missing access_key credential' do
|
965
1000
|
fog_hash = {:default => {:aws_secret_access_key => 'awspass'}}
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# setup & require beaker's spec_helper.rb
|
2
|
+
beaker_gem_spec = Gem::Specification.find_by_name('beaker')
|
3
|
+
beaker_gem_dir = beaker_gem_spec.gem_dir
|
4
|
+
beaker_spec_path = File.join(beaker_gem_dir, 'spec')
|
5
|
+
$LOAD_PATH << beaker_spec_path
|
6
|
+
require File.join(beaker_spec_path, 'helpers.rb')
|
7
|
+
|
8
|
+
module TestFileHelpers
|
9
|
+
|
10
|
+
def fog_file_contents
|
11
|
+
{ :default => { :aws_access_key_id => "IMANACCESSKEY",
|
12
|
+
:aws_secret_access_key => "supersekritkey",
|
13
|
+
:aws_session_token => 'somecrazylongsupersessiontoken!#%^^*(%$^&@$%#!!#$asd;fjapugfrejklvznb;jdgfjiadvij',
|
14
|
+
:aix_hypervisor_server => "aix_hypervisor.labs.net",
|
15
|
+
:aix_hypervisor_username => "aixer",
|
16
|
+
:aix_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-acceptance",
|
17
|
+
:solaris_hypervisor_server => "solaris_hypervisor.labs.net",
|
18
|
+
:solaris_hypervisor_username => "harness",
|
19
|
+
:solaris_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-old.private",
|
20
|
+
:solaris_hypervisor_vmpath => "rpoooool/zs",
|
21
|
+
:solaris_hypervisor_snappaths => ["rpoooool/USER/z0"],
|
22
|
+
:vsphere_server => "vsphere.labs.net",
|
23
|
+
:vsphere_username => "vsphere@labs.com",
|
24
|
+
:vsphere_password => "supersekritpassword"} }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# Beaker HostHelpers
|
30
|
+
include HostHelpers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rishi Javia, Kevin Imber, Tony Vu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/beaker/hypervisor/ec2_helper.rb
|
191
191
|
- spec/beaker/hypervisor/aws_sdk_spec.rb
|
192
192
|
- spec/beaker/hypervisor/ec2_helper_spec.rb
|
193
|
+
- spec/helpers.rb
|
193
194
|
- spec/spec_helper.rb
|
194
195
|
homepage: https://github.com/puppetlabs/beaker-aws
|
195
196
|
licenses:
|
@@ -211,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
212
|
version: '0'
|
212
213
|
requirements: []
|
213
214
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.4.
|
215
|
+
rubygems_version: 2.4.8
|
215
216
|
signing_key:
|
216
217
|
specification_version: 4
|
217
218
|
summary: Beaker DSL Extension Helpers!
|