heirloom 0.11.0.beta.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +3 -0
- data/lib/heirloom/aws/s3.rb +10 -4
- data/lib/heirloom/aws/simpledb.rb +11 -3
- data/lib/heirloom/cli/authorize.rb +1 -0
- data/lib/heirloom/cli/catalog.rb +1 -0
- data/lib/heirloom/cli/destroy.rb +1 -0
- data/lib/heirloom/cli/download.rb +1 -0
- data/lib/heirloom/cli/list.rb +1 -0
- data/lib/heirloom/cli/setup.rb +1 -0
- data/lib/heirloom/cli/shared.rb +5 -2
- data/lib/heirloom/cli/show.rb +1 -0
- data/lib/heirloom/cli/tag.rb +1 -0
- data/lib/heirloom/cli/teardown.rb +1 -0
- data/lib/heirloom/cli/upload.rb +1 -0
- data/lib/heirloom/config.rb +3 -1
- data/lib/heirloom/version.rb +1 -1
- data/spec/aws/s3_spec.rb +215 -192
- data/spec/aws/simpledb_spec.rb +98 -74
- data/spec/cli/authorize_spec.rb +1 -5
- data/spec/cli/catalog_spec.rb +1 -5
- data/spec/cli/destroy_spec.rb +1 -5
- data/spec/cli/download_spec.rb +1 -5
- data/spec/cli/list_spec.rb +1 -5
- data/spec/cli/setup_spec.rb +1 -5
- data/spec/cli/shared_spec.rb +1 -5
- data/spec/cli/show_spec.rb +1 -5
- data/spec/cli/tag_spec.rb +2 -5
- data/spec/cli/teardown_spec.rb +1 -5
- data/spec/cli/upload_spec.rb +1 -5
- data/spec/spec_helper.rb +19 -1
- metadata +9 -6
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## HEAD:
|
2
2
|
|
3
|
+
## 0.11.0 (04/26/2013):
|
4
|
+
|
3
5
|
* Add support for multiple environments
|
4
6
|
* Environment named 'default' is now the default
|
5
7
|
* Added functionality to the show command to include permissions of objects
|
@@ -9,6 +11,7 @@
|
|
9
11
|
* Catalog output renamed Bucket Prefix to bucket_prefix
|
10
12
|
* Catalog output renamed Region to region
|
11
13
|
* Add `rotate` command to allow for encryption key rotation
|
14
|
+
* Add support for IAM instance roles
|
12
15
|
|
13
16
|
## 0.10.1 (02/28/2013):
|
14
17
|
|
data/lib/heirloom/aws/s3.rb
CHANGED
@@ -9,10 +9,16 @@ module Heirloom
|
|
9
9
|
@region = args[:region]
|
10
10
|
@logger = @config.logger
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
fog_args = { :region => @region, :provider => 'AWS' }
|
13
|
+
|
14
|
+
if @config.use_iam_profile
|
15
|
+
fog_args[:use_iam_profile] = true
|
16
|
+
else
|
17
|
+
fog_args[:aws_access_key_id] = @config.access_key
|
18
|
+
fog_args[:aws_secret_access_key] = @config.secret_key
|
19
|
+
end
|
20
|
+
|
21
|
+
@s3 = Fog::Storage.new fog_args
|
16
22
|
end
|
17
23
|
|
18
24
|
def delete_object(bucket_name, object_name, options = {})
|
@@ -6,9 +6,17 @@ module Heirloom
|
|
6
6
|
|
7
7
|
def initialize(args)
|
8
8
|
@config = args[:config]
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
fog_args = { :region => @config.metadata_region }
|
11
|
+
|
12
|
+
if @config.use_iam_profile
|
13
|
+
fog_args[:use_iam_profile] = true
|
14
|
+
else
|
15
|
+
fog_args[:aws_access_key_id] = @config.access_key
|
16
|
+
fog_args[:aws_secret_access_key] = @config.secret_key
|
17
|
+
end
|
18
|
+
|
19
|
+
@sdb = Fog::AWS::SimpleDB.new fog_args
|
12
20
|
end
|
13
21
|
|
14
22
|
def domains
|
@@ -60,6 +60,7 @@ EOS
|
|
60
60
|
:short => :none
|
61
61
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
62
62
|
:short => :none
|
63
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
63
64
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
64
65
|
end
|
65
66
|
end
|
data/lib/heirloom/cli/catalog.rb
CHANGED
@@ -59,6 +59,7 @@ EOS
|
|
59
59
|
:short => :none
|
60
60
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
61
61
|
:short => :none
|
62
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
62
63
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
63
64
|
end
|
64
65
|
end
|
data/lib/heirloom/cli/destroy.rb
CHANGED
@@ -55,6 +55,7 @@ EOS
|
|
55
55
|
:short => :none
|
56
56
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
57
57
|
:short => :none
|
58
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
58
59
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
59
60
|
end
|
60
61
|
end
|
@@ -86,6 +86,7 @@ EOS
|
|
86
86
|
:short => :none
|
87
87
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
88
88
|
:short => :none
|
89
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
89
90
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
90
91
|
end
|
91
92
|
end
|
data/lib/heirloom/cli/list.rb
CHANGED
@@ -58,6 +58,7 @@ EOS
|
|
58
58
|
:short => :none
|
59
59
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
60
60
|
:short => :none
|
61
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
61
62
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
62
63
|
end
|
63
64
|
end
|
data/lib/heirloom/cli/setup.rb
CHANGED
@@ -88,6 +88,7 @@ Can be specified multiple times.", :type => :string,
|
|
88
88
|
:short => :none
|
89
89
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
90
90
|
:short => :none
|
91
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
91
92
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
92
93
|
end
|
93
94
|
end
|
data/lib/heirloom/cli/shared.rb
CHANGED
@@ -9,6 +9,7 @@ module Heirloom
|
|
9
9
|
config.access_key = opts[:aws_access_key] if opts[:aws_access_key]
|
10
10
|
config.secret_key = opts[:aws_secret_key] if opts[:aws_secret_key]
|
11
11
|
config.metadata_region = opts[:metadata_region] if opts[:metadata_region]
|
12
|
+
config.use_iam_profile = opts[:use_iam_profile] if opts[:use_iam_profile]
|
12
13
|
config
|
13
14
|
end
|
14
15
|
|
@@ -28,8 +29,10 @@ module Heirloom
|
|
28
29
|
config = args[:config]
|
29
30
|
logger = config.logger
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
unless config.use_iam_profile
|
33
|
+
required << :aws_access_key unless config.access_key
|
34
|
+
required << :aws_secret_key unless config.secret_key
|
35
|
+
end
|
33
36
|
|
34
37
|
missing_opts = required.sort.map do |opt|
|
35
38
|
case provided[opt]
|
data/lib/heirloom/cli/show.rb
CHANGED
@@ -69,6 +69,7 @@ EOS
|
|
69
69
|
:short => :none
|
70
70
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
71
71
|
:short => :none
|
72
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
72
73
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
73
74
|
end
|
74
75
|
end
|
data/lib/heirloom/cli/tag.rb
CHANGED
@@ -61,6 +61,7 @@ EOS
|
|
61
61
|
:short => :none
|
62
62
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
63
63
|
:short => :none
|
64
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
64
65
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
65
66
|
end
|
66
67
|
end
|
@@ -72,6 +72,7 @@ EOS
|
|
72
72
|
:short => :none
|
73
73
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
74
74
|
:short => :none
|
75
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
75
76
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
76
77
|
end
|
77
78
|
end
|
data/lib/heirloom/cli/upload.rb
CHANGED
@@ -100,6 +100,7 @@ Can be specified multiple times.", :type => :string, :multi => true, :short =>
|
|
100
100
|
:short => :none
|
101
101
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
102
102
|
:short => :none
|
103
|
+
opt :use_iam_profile, "Use IAM EC2 Profile", :short => :none
|
103
104
|
opt :environment, "Environment (defined in ~/.heirloom.yml)", :type => :string
|
104
105
|
end
|
105
106
|
end
|
data/lib/heirloom/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Heirloom
|
2
2
|
class Config
|
3
3
|
|
4
|
-
attr_accessor :access_key, :secret_key, :metadata_region, :logger, :environment
|
4
|
+
attr_accessor :access_key, :secret_key, :metadata_region, :logger, :environment, :use_iam_profile
|
5
5
|
|
6
6
|
def initialize(args={})
|
7
7
|
@opts = args[:opts] ||= Hash.new
|
@@ -18,6 +18,8 @@ module Heirloom
|
|
18
18
|
@config['secret_key']
|
19
19
|
@metadata_region = @opts.fetch :metadata_region,
|
20
20
|
@config['metadata_region']
|
21
|
+
@use_iam_profile = @opts.fetch :use_iam_profile,
|
22
|
+
false
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
data/lib/heirloom/version.rb
CHANGED
data/spec/aws/s3_spec.rb
CHANGED
@@ -1,244 +1,267 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Heirloom do
|
4
|
-
|
5
|
-
@directories_mock = mock 'directories'
|
6
|
-
@bucket_mock = mock 'bucket'
|
7
|
-
@logger_stub = stub 'logger', :debug => true,
|
8
|
-
:info => true,
|
9
|
-
:warn => true
|
10
|
-
@config_mock = mock 'config'
|
11
|
-
@config_mock.stub :access_key => 'the-key',
|
12
|
-
:secret_key => 'the-secret',
|
13
|
-
:logger => @logger_stub
|
14
|
-
@fog_mock = mock 'fog'
|
15
|
-
@fog_mock.stub :directories => @directories_mock
|
16
|
-
Fog::Storage.should_receive(:new).and_return @fog_mock
|
17
|
-
@s3 = Heirloom::AWS::S3.new :config => @config_mock,
|
18
|
-
:region => 'us-west-1'
|
19
|
-
end
|
4
|
+
context "using IAM roles" do
|
20
5
|
|
21
|
-
|
22
|
-
it "should return true if the bucket exists" do
|
23
|
-
@directories_mock.should_receive(:get).
|
24
|
-
with('bucket').and_return @bucket_mock
|
25
|
-
@s3.bucket_exists?('bucket').should be_true
|
26
|
-
end
|
6
|
+
it "should use the access and secret keys by default" do
|
27
7
|
|
28
|
-
|
29
|
-
|
30
|
-
with('bucket').and_return nil
|
31
|
-
@s3.bucket_exists?('bucket').should be_false
|
32
|
-
end
|
8
|
+
config = mock_config :aws_access_key_id => 'key',
|
9
|
+
:aws_secret_access_key => 'secret'
|
33
10
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
11
|
+
Fog::Storage.should_receive(:new).
|
12
|
+
with :provider => 'AWS',
|
13
|
+
:aws_access_key_id => 'key',
|
14
|
+
:aws_secret_access_key => 'secret',
|
15
|
+
:region => 'us-west-1'
|
16
|
+
s3 = Heirloom::AWS::S3.new :config => config, :region => 'us-west-1'
|
41
17
|
|
42
|
-
context "bucket_exists_in_another_region?" do
|
43
|
-
it "should return true if the bucket exists in another region" do
|
44
|
-
@bucket_mock.stub :location => 'us-east-1'
|
45
|
-
@directories_mock.should_receive(:get).
|
46
|
-
with('bucket').at_least(:once).
|
47
|
-
and_return @bucket_mock
|
48
|
-
@s3.bucket_exists_in_another_region?('bucket').should be_true
|
49
18
|
end
|
50
19
|
|
51
|
-
it "should
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
20
|
+
it "should use the iam role if asked to" do
|
21
|
+
|
22
|
+
config = mock_config :use_iam_profile => true
|
23
|
+
|
24
|
+
Fog::Storage.should_receive(:new).
|
25
|
+
with :provider => 'AWS',
|
26
|
+
:use_iam_profile => true,
|
27
|
+
:region => 'us-west-1'
|
28
|
+
s3 = Heirloom::AWS::S3.new :config => config, :region => 'us-west-1'
|
58
29
|
|
59
|
-
it "should return false if bucket owned by another account" do
|
60
|
-
@directories_mock.should_receive(:get).
|
61
|
-
with('bucket').
|
62
|
-
and_raise Excon::Errors::Forbidden.new('msg')
|
63
|
-
@s3.bucket_exists_in_another_region?('bucket').should be_false
|
64
30
|
end
|
65
31
|
end
|
66
32
|
|
67
|
-
context "
|
68
|
-
it "should return false if bucket owned by this account" do
|
69
|
-
@directories_mock.should_receive(:get).
|
70
|
-
with('bucket').
|
71
|
-
and_return @bucket_mock
|
72
|
-
@s3.bucket_owned_by_another_account?('bucket').should be_false
|
73
|
-
end
|
33
|
+
context "s3 / bucket operations" do
|
74
34
|
|
75
|
-
|
76
|
-
@directories_mock
|
77
|
-
|
78
|
-
|
79
|
-
@
|
35
|
+
before do
|
36
|
+
@directories_mock = mock 'directories'
|
37
|
+
@bucket_mock = mock 'bucket'
|
38
|
+
@fog_mock = mock 'fog'
|
39
|
+
@fog_mock.stub :directories => @directories_mock
|
40
|
+
Fog::Storage.stub :new => @fog_mock
|
41
|
+
@s3 = Heirloom::AWS::S3.new :config => mock_config, :region => 'us-west-1'
|
80
42
|
end
|
81
43
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
44
|
+
context "bucket_exists?" do
|
45
|
+
it "should return true if the bucket exists" do
|
46
|
+
@directories_mock.should_receive(:get).
|
47
|
+
with('bucket').and_return @bucket_mock
|
48
|
+
@s3.bucket_exists?('bucket').should be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return false if the bucket does not exist" do
|
52
|
+
@directories_mock.should_receive(:get).
|
53
|
+
with('bucket').and_return nil
|
54
|
+
@s3.bucket_exists?('bucket').should be_false
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return false if bucket owned by another account" do
|
58
|
+
@directories_mock.should_receive(:get).
|
59
|
+
with('bucket').
|
60
|
+
and_raise Excon::Errors::Forbidden.new('msg')
|
61
|
+
@s3.bucket_exists?('bucket').should be_false
|
62
|
+
end
|
87
63
|
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should delete an object from s3" do
|
91
|
-
@fog_mock.should_receive(:delete_object).
|
92
|
-
with('bucket', 'object', { :option => 'test' })
|
93
|
-
@s3.delete_object('bucket', 'object', { :option => 'test' })
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should get a bucket from s3" do
|
97
|
-
@directories_mock.should_receive(:get).with 'bucket'
|
98
|
-
@s3.get_bucket 'bucket'
|
99
|
-
end
|
100
|
-
|
101
|
-
context "testing bucket availability" do
|
102
64
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
65
|
+
context "bucket_exists_in_another_region?" do
|
66
|
+
it "should return true if the bucket exists in another region" do
|
67
|
+
@bucket_mock.stub :location => 'us-east-1'
|
68
|
+
@directories_mock.should_receive(:get).
|
69
|
+
with('bucket').at_least(:once).
|
70
|
+
and_return @bucket_mock
|
71
|
+
@s3.bucket_exists_in_another_region?('bucket').should be_true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return false if the bucket exists in the curren region" do
|
75
|
+
@bucket_mock.stub :location => 'us-west-1'
|
76
|
+
@directories_mock.should_receive(:get).
|
77
|
+
with('bucket').at_least(:once).
|
78
|
+
and_return @bucket_mock
|
79
|
+
@s3.bucket_exists_in_another_region?('bucket').should be_false
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return false if bucket owned by another account" do
|
83
|
+
@directories_mock.should_receive(:get).
|
84
|
+
with('bucket').
|
85
|
+
and_raise Excon::Errors::Forbidden.new('msg')
|
86
|
+
@s3.bucket_exists_in_another_region?('bucket').should be_false
|
87
|
+
end
|
108
88
|
end
|
109
89
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
90
|
+
context "bucket_owned_by_another_account?" do
|
91
|
+
it "should return false if bucket owned by this account" do
|
92
|
+
@directories_mock.should_receive(:get).
|
93
|
+
with('bucket').
|
94
|
+
and_return @bucket_mock
|
95
|
+
@s3.bucket_owned_by_another_account?('bucket').should be_false
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return false if bucket does not exist" do
|
99
|
+
@directories_mock.should_receive(:get).
|
100
|
+
with('bucket').
|
101
|
+
and_return nil
|
102
|
+
@s3.bucket_owned_by_another_account?('bucket').should be_false
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should return true if bucket is not owned by another account" do
|
106
|
+
@directories_mock.should_receive(:get).
|
107
|
+
with('bucket').
|
108
|
+
and_raise Excon::Errors::Forbidden.new('msg')
|
109
|
+
@s3.bucket_owned_by_another_account?('bucket').should be_true
|
110
|
+
end
|
116
111
|
end
|
117
112
|
|
118
|
-
it "should
|
119
|
-
@
|
120
|
-
with('bucket'
|
121
|
-
|
122
|
-
@bucket_mock.stub :location => 'us-west-1'
|
123
|
-
@s3.bucket_name_available?('bucket').should be_true
|
113
|
+
it "should delete an object from s3" do
|
114
|
+
@fog_mock.should_receive(:delete_object).
|
115
|
+
with('bucket', 'object', { :option => 'test' })
|
116
|
+
@s3.delete_object('bucket', 'object', { :option => 'test' })
|
124
117
|
end
|
125
118
|
|
126
|
-
it "should
|
127
|
-
@directories_mock.should_receive(:get).
|
128
|
-
|
129
|
-
and_return nil
|
130
|
-
@s3.bucket_name_available?('bucket').should be_true
|
119
|
+
it "should get a bucket from s3" do
|
120
|
+
@directories_mock.should_receive(:get).with 'bucket'
|
121
|
+
@s3.get_bucket 'bucket'
|
131
122
|
end
|
132
123
|
|
133
|
-
|
124
|
+
context "testing bucket availability" do
|
125
|
+
|
126
|
+
it "should return false if the bucket is forbidden" do
|
127
|
+
@directories_mock.should_receive(:get).
|
128
|
+
with('bucket').
|
129
|
+
and_raise Excon::Errors::Forbidden.new('msg')
|
130
|
+
@s3.bucket_name_available?('bucket').should be_false
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should return false if bucket in different region" do
|
134
|
+
@directories_mock.should_receive(:get).
|
135
|
+
with('bucket').at_least(:once).
|
136
|
+
and_return @bucket_mock
|
137
|
+
@bucket_mock.stub :location => 'us-east-1'
|
138
|
+
@s3.bucket_name_available?('bucket').should be_false
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return true if the bucket is in this account / region" do
|
142
|
+
@directories_mock.should_receive(:get).
|
143
|
+
with('bucket').at_least(:once).
|
144
|
+
and_return @bucket_mock
|
145
|
+
@bucket_mock.stub :location => 'us-west-1'
|
146
|
+
@s3.bucket_name_available?('bucket').should be_true
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return true if the bucket is not found" do
|
150
|
+
@directories_mock.should_receive(:get).
|
151
|
+
with('bucket').at_least(:once).
|
152
|
+
and_return nil
|
153
|
+
@s3.bucket_name_available?('bucket').should be_true
|
154
|
+
end
|
134
155
|
|
135
|
-
|
136
|
-
body_mock = mock 'body'
|
137
|
-
@fog_mock.should_receive(:get_bucket_object_versions).
|
138
|
-
with('bucket').
|
139
|
-
and_return body_mock
|
140
|
-
body_mock.stub :body => 'body_hash'
|
141
|
-
@s3.get_bucket_object_versions('bucket').should == 'body_hash'
|
142
|
-
end
|
156
|
+
end
|
143
157
|
|
144
|
-
|
145
|
-
it "should return true if the bucket has 0 objects" do
|
158
|
+
it "should return object versions for a given bucket" do
|
146
159
|
body_mock = mock 'body'
|
147
160
|
@fog_mock.should_receive(:get_bucket_object_versions).
|
148
161
|
with('bucket').
|
149
162
|
and_return body_mock
|
150
|
-
body_mock.stub :body =>
|
151
|
-
@s3.
|
163
|
+
body_mock.stub :body => 'body_hash'
|
164
|
+
@s3.get_bucket_object_versions('bucket').should == 'body_hash'
|
152
165
|
end
|
153
166
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
167
|
+
context "testing bucket deletion" do
|
168
|
+
it "should return true if the bucket has 0 objects" do
|
169
|
+
body_mock = mock 'body'
|
170
|
+
@fog_mock.should_receive(:get_bucket_object_versions).
|
171
|
+
with('bucket').
|
172
|
+
and_return body_mock
|
173
|
+
body_mock.stub :body => { "Versions" => [ ] }
|
174
|
+
@s3.bucket_empty?('bucket').should be_true
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should return false if the bucket has any objects" do
|
178
|
+
body_mock = mock 'body'
|
179
|
+
@fog_mock.should_receive(:get_bucket_object_versions).
|
180
|
+
with('bucket').
|
181
|
+
and_return body_mock
|
182
|
+
body_mock.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
|
183
|
+
@s3.bucket_empty?('bucket').should be_false
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should delete a bucket from s3 if empty" do
|
187
|
+
body_mock = mock 'body'
|
188
|
+
@fog_mock.should_receive(:get_bucket_object_versions).
|
189
|
+
with('bucket').
|
190
|
+
and_return body_mock
|
191
|
+
body_mock.stub :body => { "Versions" => [ ] }
|
192
|
+
@fog_mock.should_receive(:delete_bucket).
|
193
|
+
with('bucket').and_return true
|
194
|
+
@s3.delete_bucket('bucket').should be_true
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should return false and not attempt to delete a non empty s3 bucket" do
|
198
|
+
body_mock = mock 'body'
|
199
|
+
@fog_mock.should_receive(:get_bucket_object_versions).
|
200
|
+
with('bucket').
|
201
|
+
and_return body_mock
|
202
|
+
body_mock.stub :body => { "Versions" => [ 'obj1', 'obj2' ] }
|
203
|
+
@fog_mock.should_receive(:delete_bucket).never
|
204
|
+
@s3.delete_bucket('bucket').should be_false
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should return true if Excon::Errors::NotFound raised when deleting bucket" do
|
208
|
+
@fog_mock.should_receive(:get_bucket_object_versions).
|
209
|
+
with('bucket').
|
210
|
+
and_raise Excon::Errors::NotFound.new 'Bucket does not exist.'
|
211
|
+
@fog_mock.should_receive(:delete_bucket).never
|
212
|
+
@s3.delete_bucket('bucket').should be_true
|
213
|
+
end
|
161
214
|
end
|
162
215
|
|
163
|
-
it "should
|
216
|
+
it "should get an object from s3" do
|
164
217
|
body_mock = mock 'body'
|
165
|
-
@fog_mock.should_receive(:
|
166
|
-
with('bucket').
|
218
|
+
@fog_mock.should_receive(:get_object).
|
219
|
+
with('bucket', 'object').
|
167
220
|
and_return body_mock
|
168
|
-
body_mock.stub :body =>
|
169
|
-
@
|
170
|
-
with('bucket').and_return true
|
171
|
-
@s3.delete_bucket('bucket').should be_true
|
221
|
+
body_mock.stub :body => 'body_hash'
|
222
|
+
@s3.get_object('bucket', 'object').should == 'body_hash'
|
172
223
|
end
|
173
224
|
|
174
|
-
it "should
|
225
|
+
it "should get a buckets acl from s3" do
|
175
226
|
body_mock = mock 'body'
|
176
|
-
@fog_mock.should_receive(:
|
177
|
-
with('bucket').
|
227
|
+
@fog_mock.should_receive(:get_object).
|
228
|
+
with('bucket', 'object').
|
178
229
|
and_return body_mock
|
179
|
-
body_mock.
|
180
|
-
@
|
181
|
-
@s3.delete_bucket('bucket').should be_false
|
230
|
+
body_mock.should_receive(:body)
|
231
|
+
@s3.get_object('bucket', 'object')
|
182
232
|
end
|
183
233
|
|
184
|
-
it "should
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
@s3.
|
234
|
+
it "should get an objects acl from s3" do
|
235
|
+
body_mock = mock 'body'
|
236
|
+
@fog_mock.should_receive(:get_object_acl).
|
237
|
+
with('bucket', 'object').and_return(body_mock)
|
238
|
+
body_mock.stub :body => 'data'
|
239
|
+
@s3.get_object_acl({ :bucket => 'bucket', :object_name => 'object'}).
|
240
|
+
should == 'data'
|
190
241
|
end
|
191
|
-
end
|
192
242
|
|
193
|
-
it "should get an object from s3" do
|
194
|
-
body_mock = mock 'body'
|
195
|
-
@fog_mock.should_receive(:get_object).
|
196
|
-
with('bucket', 'object').
|
197
|
-
and_return body_mock
|
198
|
-
body_mock.stub :body => 'body_hash'
|
199
|
-
@s3.get_object('bucket', 'object').should == 'body_hash'
|
200
|
-
end
|
201
|
-
|
202
|
-
it "should get a buckets acl from s3" do
|
203
|
-
body_mock = mock 'body'
|
204
|
-
@fog_mock.should_receive(:get_object).
|
205
|
-
with('bucket', 'object').
|
206
|
-
and_return body_mock
|
207
|
-
body_mock.should_receive(:body)
|
208
|
-
@s3.get_object('bucket', 'object')
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should get an objects acl from s3" do
|
212
|
-
body_mock = mock 'body'
|
213
|
-
@fog_mock.should_receive(:get_object_acl).
|
214
|
-
with('bucket', 'object').and_return(body_mock)
|
215
|
-
body_mock.stub :body => 'data'
|
216
|
-
@s3.get_object_acl({ :bucket => 'bucket', :object_name => 'object'}).
|
217
|
-
should == 'data'
|
218
|
-
end
|
219
243
|
|
244
|
+
it "should set object acls" do
|
245
|
+
@fog_mock.should_receive(:put_object_acl).
|
246
|
+
with 'bucket', 'object', 'grants'
|
247
|
+
@s3.put_object_acl 'bucket', 'object', 'grants'
|
248
|
+
end
|
220
249
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
250
|
+
it "should call put bucket with location_constraint us-west-1" do
|
251
|
+
options = { 'LocationConstraint' => 'us-west-1',
|
252
|
+
'x-amz-acl' => 'private' }
|
253
|
+
@fog_mock.should_receive(:put_bucket).
|
254
|
+
with('name', options)
|
255
|
+
@s3.put_bucket 'name', 'us-west-1'
|
256
|
+
end
|
226
257
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
258
|
+
it "should call put bucket with location_constraint nil when region us-west-1" do
|
259
|
+
options = { 'LocationConstraint' => nil,
|
260
|
+
'x-amz-acl' => 'private' }
|
261
|
+
@fog_mock.should_receive(:put_bucket).
|
262
|
+
with('name', options)
|
263
|
+
@s3.put_bucket 'name', 'us-east-1'
|
264
|
+
end
|
234
265
|
|
235
|
-
it "should call put bucket with location_constraint nil when region us-west-1" do
|
236
|
-
options = { 'LocationConstraint' => nil,
|
237
|
-
'x-amz-acl' => 'private' }
|
238
|
-
@fog_mock.should_receive(:put_bucket).
|
239
|
-
with('name', options)
|
240
|
-
@s3.put_bucket 'name', 'us-east-1'
|
241
266
|
end
|
242
|
-
|
243
|
-
|
244
267
|
end
|
data/spec/aws/simpledb_spec.rb
CHANGED
@@ -1,97 +1,121 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Heirloom do
|
4
|
-
before do
|
5
|
-
@config_mock = mock 'config'
|
6
|
-
@config_mock.should_receive(:access_key).and_return 'the-key'
|
7
|
-
@config_mock.should_receive(:secret_key).and_return 'the-secret'
|
8
|
-
@config_mock.should_receive(:metadata_region).and_return 'us-west-1'
|
9
|
-
@fog_mock = mock 'fog'
|
10
|
-
Fog::AWS::SimpleDB.should_receive(:new).
|
11
|
-
with(:aws_access_key_id => 'the-key',
|
12
|
-
:aws_secret_access_key => 'the-secret',
|
13
|
-
:region => 'us-west-1').
|
14
|
-
and_return @fog_mock
|
15
|
-
@sdb = Heirloom::AWS::SimpleDB.new :config => @config_mock
|
16
|
-
end
|
17
4
|
|
18
|
-
|
19
|
-
body_mock = mock 'body'
|
20
|
-
@fog_mock.should_receive(:list_domains).
|
21
|
-
and_return body_mock
|
22
|
-
body_mock.should_receive(:body).
|
23
|
-
and_return 'Domains' => ['domain1']
|
24
|
-
@sdb.domains.should == ['domain1']
|
25
|
-
end
|
5
|
+
context "credential management" do
|
26
6
|
|
27
|
-
|
28
|
-
@sdb.should_receive(:domains).and_return([])
|
29
|
-
@fog_mock.should_receive(:create_domain).with('new_domain')
|
30
|
-
@sdb.create_domain('new_domain')
|
31
|
-
end
|
7
|
+
it "should use the access and secret keys by default" do
|
32
8
|
|
33
|
-
|
34
|
-
|
35
|
-
@sdb.delete_domain('new_domain')
|
36
|
-
end
|
9
|
+
config = mock_config :aws_access_key_id => 'key',
|
10
|
+
:aws_secret_access_key => 'secret'
|
37
11
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
12
|
+
Fog::AWS::SimpleDB.should_receive(:new).
|
13
|
+
with :aws_access_key_id => 'key',
|
14
|
+
:aws_secret_access_key => 'secret',
|
15
|
+
:region => 'us-west-1'
|
43
16
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
17
|
+
s3 = Heirloom::AWS::SimpleDB.new :config => config
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should use the iam role if asked to" do
|
22
|
+
|
23
|
+
config = mock_config :use_iam_profile => true
|
24
|
+
|
25
|
+
Fog::AWS::SimpleDB.should_receive(:new).
|
26
|
+
with :use_iam_profile => true,
|
27
|
+
:region => 'us-west-1'
|
28
|
+
s3 = Heirloom::AWS::SimpleDB.new :config => config
|
29
|
+
|
30
|
+
end
|
49
31
|
|
50
|
-
it "should delete the given entry from sdb" do
|
51
|
-
@fog_mock.should_receive(:delete_attributes).with('domain', 'key')
|
52
|
-
@sdb.delete('domain', 'key')
|
53
32
|
end
|
54
33
|
|
55
|
-
context "
|
34
|
+
context "sdb operations" do
|
35
|
+
|
56
36
|
before do
|
57
|
-
@
|
37
|
+
@fog_mock = mock 'fog'
|
38
|
+
Fog::AWS::SimpleDB.stub :new => @fog_mock
|
39
|
+
@sdb = Heirloom::AWS::SimpleDB.new :config => mock_config
|
58
40
|
end
|
59
41
|
|
60
|
-
it "should
|
61
|
-
|
62
|
-
@fog_mock.should_receive(:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@sdb.
|
42
|
+
it "should list the domains in simples db" do
|
43
|
+
body_mock = mock 'body'
|
44
|
+
@fog_mock.should_receive(:list_domains).
|
45
|
+
and_return body_mock
|
46
|
+
body_mock.should_receive(:body).
|
47
|
+
and_return 'Domains' => ['domain1']
|
48
|
+
@sdb.domains.should == ['domain1']
|
67
49
|
end
|
68
50
|
|
69
|
-
it "should
|
70
|
-
|
71
|
-
@fog_mock.should_receive(:
|
72
|
-
|
73
|
-
and_return @body_stub
|
74
|
-
@body_stub.stub :body => data
|
75
|
-
@sdb.domain_empty?('heirloom_domain').should be_true
|
51
|
+
it "should create a new domain when it does not exist" do
|
52
|
+
@sdb.should_receive(:domains).and_return([])
|
53
|
+
@fog_mock.should_receive(:create_domain).with('new_domain')
|
54
|
+
@sdb.create_domain('new_domain')
|
76
55
|
end
|
77
56
|
|
78
|
-
it "should
|
79
|
-
|
80
|
-
@
|
81
|
-
with('SELECT count(*) FROM `heirloom_domain`').
|
82
|
-
and_return @body_stub
|
83
|
-
@body_stub.stub :body => data
|
84
|
-
@sdb.domain_empty?('heirloom_domain').should be_false
|
57
|
+
it "should destroy the specified domain" do
|
58
|
+
@fog_mock.should_receive(:delete_domain).with('new_domain')
|
59
|
+
@sdb.delete_domain('new_domain')
|
85
60
|
end
|
86
61
|
|
87
|
-
it "should
|
88
|
-
|
89
|
-
@fog_mock.should_receive(:
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
62
|
+
it "should not create a new domain when already exists" do
|
63
|
+
@sdb.should_receive(:domains).and_return(['new_domain'])
|
64
|
+
@fog_mock.should_receive(:create_domain).exactly(0).times
|
65
|
+
@sdb.create_domain('new_domain')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should update the attributes for an entry" do
|
69
|
+
@fog_mock.should_receive(:put_attributes).
|
70
|
+
with('domain', 'key', {'key' => 'value'}, { "option" => "123" })
|
71
|
+
@sdb.put_attributes('domain', 'key', {'key' => 'value'}, { "option" => "123" })
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should delete the given entry from sdb" do
|
75
|
+
@fog_mock.should_receive(:delete_attributes).with('domain', 'key')
|
76
|
+
@sdb.delete('domain', 'key')
|
94
77
|
end
|
95
|
-
end
|
96
78
|
|
79
|
+
context "testing counts" do
|
80
|
+
before do
|
81
|
+
@body_stub = stub 'body'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should count the number of entries in the domain" do
|
85
|
+
data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
|
86
|
+
@fog_mock.should_receive(:select).
|
87
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
88
|
+
and_return @body_stub
|
89
|
+
@body_stub.stub :body => data
|
90
|
+
@sdb.count('heirloom_domain').should == 1
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return true if no entries for the domain" do
|
94
|
+
data = { 'Items' => { 'Domain' => { 'Count' => ['0'] } } }
|
95
|
+
@fog_mock.should_receive(:select).
|
96
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
97
|
+
and_return @body_stub
|
98
|
+
@body_stub.stub :body => data
|
99
|
+
@sdb.domain_empty?('heirloom_domain').should be_true
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should return false if entries exist for the domain" do
|
103
|
+
data = { 'Items' => { 'Domain' => { 'Count' => ['50'] } } }
|
104
|
+
@fog_mock.should_receive(:select).
|
105
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
106
|
+
and_return @body_stub
|
107
|
+
@body_stub.stub :body => data
|
108
|
+
@sdb.domain_empty?('heirloom_domain').should be_false
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return the count for a specific itemName within a domain" do
|
112
|
+
data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
|
113
|
+
@fog_mock.should_receive(:select).
|
114
|
+
with("SELECT count(*) FROM `heirloom` WHERE itemName() = 'archive'").
|
115
|
+
and_return @body_stub
|
116
|
+
@body_stub.stub :body => data
|
117
|
+
@sdb.item_count('heirloom', 'archive').should == 1
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
97
121
|
end
|
data/spec/cli/authorize_spec.rb
CHANGED
@@ -10,12 +10,8 @@ describe Heirloom do
|
|
10
10
|
:id => '1.0.0',
|
11
11
|
:metadata_region => 'us-west-1' }
|
12
12
|
@logger_stub = stub 'logger', :error => true
|
13
|
-
@config_mock =
|
13
|
+
@config_mock = mock_config :logger => @logger_stub
|
14
14
|
@archive_mock = mock 'archive'
|
15
|
-
@config_mock.stub :logger => @logger_stub,
|
16
|
-
:access_key => 'key',
|
17
|
-
:secret_key => 'secret',
|
18
|
-
:metadata_region => 'us-west-1'
|
19
15
|
Trollop.stub(:options).and_return options
|
20
16
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
21
17
|
and_return @logger_stub
|
data/spec/cli/catalog_spec.rb
CHANGED
@@ -10,13 +10,9 @@ describe Heirloom do
|
|
10
10
|
{ 'regions' => ['us-west-1'],
|
11
11
|
'bucket_prefix' => ['bp'] } }
|
12
12
|
@logger_stub = stub :debug => true
|
13
|
-
@config_mock =
|
13
|
+
@config_mock = mock_config :logger => @logger_stub
|
14
14
|
@catalog_mock = mock 'catalog'
|
15
15
|
@catalog_mock.stub :catalog_domain_exists? => true
|
16
|
-
@config_mock.stub :logger => @logger_mock,
|
17
|
-
:access_key => 'key',
|
18
|
-
:secret_key => 'secret',
|
19
|
-
:metadata_region => 'us-west-1'
|
20
16
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
21
17
|
and_return @logger_stub
|
22
18
|
Heirloom::CLI::Catalog.any_instance.should_receive(:load_config).
|
data/spec/cli/destroy_spec.rb
CHANGED
@@ -9,12 +9,8 @@ describe Heirloom do
|
|
9
9
|
:level => 'info',
|
10
10
|
:metadata_region => 'us-west-1' }
|
11
11
|
@logger_stub = stub 'logger'
|
12
|
-
@config_mock =
|
12
|
+
@config_mock = mock_config :logger => @logger_stub
|
13
13
|
@archive_mock = mock 'archive'
|
14
|
-
@config_mock.stub :logger => @logger_stub,
|
15
|
-
:access_key => 'key',
|
16
|
-
:secret_key => 'secret',
|
17
|
-
:metadata_region => 'us-west-1'
|
18
14
|
Trollop.stub(:options).and_return options
|
19
15
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
20
16
|
and_return @logger_stub
|
data/spec/cli/download_spec.rb
CHANGED
@@ -5,12 +5,8 @@ describe Heirloom do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
@logger_stub = stub 'logger'
|
8
|
-
@config_mock =
|
8
|
+
@config_mock = mock_config :logger => @logger_stub
|
9
9
|
@archive_mock = mock 'archive'
|
10
|
-
@config_mock.stub :logger => @logger_stub,
|
11
|
-
:access_key => 'key',
|
12
|
-
:secret_key => 'secret',
|
13
|
-
:metadata_region => 'us-west-1'
|
14
10
|
Heirloom::HeirloomLogger.should_receive(:new).
|
15
11
|
with(:log_level => 'info').
|
16
12
|
and_return @logger_stub
|
data/spec/cli/list_spec.rb
CHANGED
@@ -9,12 +9,8 @@ describe Heirloom do
|
|
9
9
|
:metadata_region => 'us-west-1',
|
10
10
|
:count => 100 }
|
11
11
|
@logger_stub = stub :debug => true
|
12
|
-
@config_mock =
|
12
|
+
@config_mock = mock_config :logger => @logger_stub
|
13
13
|
@archive_mock = mock 'archive'
|
14
|
-
@config_mock.stub :logger => @logger_mock,
|
15
|
-
:access_key => 'key',
|
16
|
-
:secret_key => 'secret',
|
17
|
-
:metadata_region => 'us-west-1'
|
18
14
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
19
15
|
and_return @logger_stub
|
20
16
|
Heirloom::CLI::List.any_instance.should_receive(:load_config).
|
data/spec/cli/setup_spec.rb
CHANGED
@@ -12,11 +12,7 @@ describe Heirloom do
|
|
12
12
|
:metadata_region => 'us-west-1' }
|
13
13
|
|
14
14
|
@logger_stub = stub 'logger', :error => true, :info => true
|
15
|
-
@config_mock =
|
16
|
-
@config_mock.stub :logger => @logger_stub,
|
17
|
-
:access_key => 'key',
|
18
|
-
:secret_key => 'secret',
|
19
|
-
:metadata_region => 'us-west-1'
|
15
|
+
@config_mock = mock_config :logger => @logger_stub
|
20
16
|
@archive_mock = mock 'archive'
|
21
17
|
@catalog_mock = mock 'catalog'
|
22
18
|
@checker_mock = mock 'checker'
|
data/spec/cli/shared_spec.rb
CHANGED
@@ -7,12 +7,8 @@ describe Heirloom do
|
|
7
7
|
context "testing ensure_valid_options" do
|
8
8
|
|
9
9
|
before do
|
10
|
-
@config_mock = mock 'config'
|
11
10
|
@logger_mock = mock 'logger'
|
12
|
-
@config_mock
|
13
|
-
:access_key => 'key',
|
14
|
-
:secret_key => 'secret',
|
15
|
-
:metadata_region => 'us-west-1'
|
11
|
+
@config_mock = mock_config(:logger => @logger_mock)
|
16
12
|
@object = Object.new
|
17
13
|
@object.extend Heirloom::CLI::Shared
|
18
14
|
end
|
data/spec/cli/show_spec.rb
CHANGED
@@ -10,12 +10,8 @@ describe Heirloom do
|
|
10
10
|
:level => 'info',
|
11
11
|
:metadata_region => 'us-west-1' }
|
12
12
|
@logger_stub = stub :debug => true
|
13
|
-
@config_mock =
|
13
|
+
@config_mock = mock_config(:logger => @logger_stub)
|
14
14
|
@archive_mock = mock 'archive'
|
15
|
-
@config_mock.stub :logger => @logger_stub,
|
16
|
-
:access_key => 'key',
|
17
|
-
:secret_key => 'secret',
|
18
|
-
:metadata_region => 'us-west-1'
|
19
15
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
20
16
|
and_return @logger_stub
|
21
17
|
Heirloom::CLI::Show.any_instance.should_receive(:load_config).
|
data/spec/cli/tag_spec.rb
CHANGED
@@ -11,12 +11,9 @@ describe Heirloom do
|
|
11
11
|
:value => 'val',
|
12
12
|
:metadata_region => 'us-west-1' }
|
13
13
|
@logger_stub = stub :debug => true, :error => true
|
14
|
-
@config_mock =
|
14
|
+
@config_mock = mock_config(:logger => @logger_stub)
|
15
15
|
@archive_mock = mock 'archive'
|
16
|
-
|
17
|
-
:access_key => 'key',
|
18
|
-
:secret_key => 'secret',
|
19
|
-
:metadata_region => 'us-west-1'
|
16
|
+
|
20
17
|
Trollop.stub(:options).and_return options
|
21
18
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
22
19
|
and_return @logger_stub
|
data/spec/cli/teardown_spec.rb
CHANGED
@@ -9,11 +9,7 @@ describe Heirloom do
|
|
9
9
|
:metadata_region => 'us-west-1' }
|
10
10
|
|
11
11
|
@logger_stub = stub 'logger', :error => true, :info => true
|
12
|
-
@config_mock =
|
13
|
-
@config_mock.stub :logger => @logger_stub,
|
14
|
-
:access_key => 'key',
|
15
|
-
:secret_key => 'secret',
|
16
|
-
:metadata_region => 'us-west-1'
|
12
|
+
@config_mock = mock_config(:logger => @logger_stub)
|
17
13
|
@archive_mock = mock 'archive'
|
18
14
|
@catalog_mock = mock 'catalog'
|
19
15
|
@catalog_mock.stub :regions => ['us-west-1', 'us-west-2']
|
data/spec/cli/upload_spec.rb
CHANGED
@@ -15,11 +15,7 @@ describe Heirloom do
|
|
15
15
|
:metadata_region => 'us-west-1' }
|
16
16
|
|
17
17
|
@logger_stub = stub 'logger', :error => true, :info => true
|
18
|
-
@config_mock =
|
19
|
-
@config_mock.stub :logger => @logger_stub,
|
20
|
-
:access_key => 'key',
|
21
|
-
:secret_key => 'secret',
|
22
|
-
:metadata_region => 'us-west-1'
|
18
|
+
@config_mock = mock_config(:logger => @logger_stub)
|
23
19
|
@archive_mock = mock 'archive'
|
24
20
|
@catalog_mock = mock 'catalog'
|
25
21
|
@catalog_mock.stub :regions => @regions,
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,24 @@ require 'bundler/setup'
|
|
3
3
|
|
4
4
|
require 'heirloom'
|
5
5
|
|
6
|
+
module SpecHelpers
|
7
|
+
|
8
|
+
def mock_config(args={})
|
9
|
+
args[:logger] ||= stub :debug => true, :info => true, :warn => true, :error => true
|
10
|
+
args[:access_key] ||= 'key'
|
11
|
+
args[:secret_key] ||= 'secret'
|
12
|
+
args[:metadata_region] ||= 'us-west-1'
|
13
|
+
args[:use_iam_profile] ||= false
|
14
|
+
|
15
|
+
config_mock = mock 'config'
|
16
|
+
config_mock.stub args
|
17
|
+
|
18
|
+
config_mock
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
6
23
|
RSpec.configure do |config|
|
7
|
-
|
24
|
+
config.include SpecHelpers
|
8
25
|
end
|
26
|
+
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heirloom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.11.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brett Weaver
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -235,13 +235,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
segments:
|
237
237
|
- 0
|
238
|
-
hash: -
|
238
|
+
hash: -4406439853802667005
|
239
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
240
|
none: false
|
241
241
|
requirements:
|
242
|
-
- - ! '
|
242
|
+
- - ! '>='
|
243
243
|
- !ruby/object:Gem::Version
|
244
|
-
version:
|
244
|
+
version: '0'
|
245
|
+
segments:
|
246
|
+
- 0
|
247
|
+
hash: -4406439853802667005
|
245
248
|
requirements: []
|
246
249
|
rubyforge_project: heirloom
|
247
250
|
rubygems_version: 1.8.24
|