heirloom 0.5.0rc3 → 0.5.0rc4

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.
Files changed (38) hide show
  1. data/CHANGELOG +11 -4
  2. data/README.md +3 -1
  3. data/heirloom.gemspec +3 -4
  4. data/lib/heirloom/archive.rb +15 -4
  5. data/lib/heirloom/archive/authorizer.rb +20 -3
  6. data/lib/heirloom/archive/builder.rb +2 -1
  7. data/lib/heirloom/archive/destroyer.rb +9 -2
  8. data/lib/heirloom/archive/setuper.rb +48 -0
  9. data/lib/heirloom/archive/verifier.rb +20 -10
  10. data/lib/heirloom/aws/s3.rb +7 -0
  11. data/lib/heirloom/cipher/data.rb +5 -2
  12. data/lib/heirloom/cipher/file.rb +1 -1
  13. data/lib/heirloom/cli.rb +14 -14
  14. data/lib/heirloom/cli/authorize.rb +3 -1
  15. data/lib/heirloom/cli/destroy.rb +1 -1
  16. data/lib/heirloom/cli/shared.rb +8 -9
  17. data/lib/heirloom/cli/{update.rb → tag.rb} +14 -9
  18. data/lib/heirloom/cli/{build.rb → upload.rb} +22 -25
  19. data/lib/heirloom/directory/directory.rb +2 -2
  20. data/lib/heirloom/uploader/s3.rb +2 -2
  21. data/lib/heirloom/version.rb +1 -1
  22. data/spec/archive/authorizer_spec.rb +14 -4
  23. data/spec/archive/builder_spec.rb +12 -5
  24. data/spec/archive/destroyer_spec.rb +24 -14
  25. data/spec/archive/setup_spec.rb +66 -0
  26. data/spec/archive/verifier_spec.rb +54 -22
  27. data/spec/archive/writer_spec.rb +2 -2
  28. data/spec/archive_spec.rb +3 -2
  29. data/spec/aws/s3_spec.rb +16 -0
  30. data/spec/cipher/data_spec.rb +3 -3
  31. data/spec/cipher/file_spec.rb +4 -3
  32. data/spec/cli/authorize_spec.rb +9 -2
  33. data/spec/cli/destroy_spec.rb +1 -1
  34. data/spec/cli/shared_spec.rb +2 -1
  35. data/spec/cli/{update_spec.rb → tag_spec.rb} +19 -13
  36. data/spec/cli/{build_spec.rb → upload_spec.rb} +26 -26
  37. data/spec/directory/directory_spec.rb +4 -2
  38. metadata +26 -34
@@ -17,7 +17,7 @@ describe Heirloom do
17
17
  File.should_receive(:open).with('/tmp/tempfile', 'w')
18
18
  Heirloom::Writer.any_instance.should_receive(:`).
19
19
  with('tar xzf /tmp/tempfile -C /output')
20
- $?.should_receive(:success?).and_return true
20
+ $?.stub :success? => true
21
21
  @writer.save_archive(:archive => 'archive_data',
22
22
  :output => '/output',
23
23
  :file => 'id.tar.gz',
@@ -28,8 +28,8 @@ describe Heirloom do
28
28
  File.should_receive(:open).with('/tmp/tempfile', 'w')
29
29
  Heirloom::Writer.any_instance.should_receive(:`).
30
30
  with('tar xzf /tmp/tempfile -C /output')
31
+ $?.stub :success? => false
31
32
  @logger_mock.should_receive(:error).with "Error extracting archive."
32
- $?.should_receive(:success?).and_return false
33
33
  @writer.save_archive(:archive => 'archive_data',
34
34
  :output => '/output',
35
35
  :file => 'id.tar.gz',
@@ -164,8 +164,9 @@ describe Heirloom do
164
164
  :id => '123').
165
165
  and_return destroyer_mock
166
166
  destroyer_mock.should_receive(:destroy).
167
- with(:regions => ['us-west-1', 'us-west-2'])
168
- @archive.destroy
167
+ with(:regions => ['us-west-1', 'us-west-2'],
168
+ :keep_domain => false)
169
+ @archive.destroy :keep_domain => false
169
170
  end
170
171
 
171
172
  it "should call the regions method for an archive" do
@@ -51,5 +51,21 @@ describe Heirloom do
51
51
  @s3.put_object_acl 'bucket', 'object', 'grants'
52
52
  end
53
53
 
54
+ it "should call put bucket with location_constraint us-west-1" do
55
+ options = { 'LocationConstraint' => 'us-west-1',
56
+ 'x-amz-acl' => 'private' }
57
+ @fog_mock.should_receive(:put_bucket).
58
+ with('name', options)
59
+ @s3.put_bucket 'name', 'us-west-1'
60
+ end
61
+
62
+ it "should call put bucket with location_constraint nil when region us-west-1" do
63
+ options = { 'LocationConstraint' => nil,
64
+ 'x-amz-acl' => 'private' }
65
+ @fog_mock.should_receive(:put_bucket).
66
+ with('name', options)
67
+ @s3.put_bucket 'name', 'us-east-1'
68
+ end
69
+
54
70
 
55
71
  end
@@ -18,10 +18,10 @@ describe Heirloom do
18
18
 
19
19
  it "should decrypt the given data" do
20
20
  @aes_mock.should_receive(:decrypt)
21
- @aes_mock.should_receive(:key=).with 'mysecret'
21
+ @aes_mock.should_receive(:key=).with Digest::SHA256.hexdigest 'mysecret'
22
22
  @aes_mock.should_receive(:iv=).with 'firstsixteenchar'
23
23
  @aes_mock.should_receive(:update).with('crypteddata').and_return 'cleartext'
24
- @aes_mock.should_receive(:final).and_return 'final'
24
+ @aes_mock.stub :final => 'final'
25
25
  @data.decrypt_data(:data => 'firstsixteencharcrypteddata',
26
26
  :secret => 'mysecret').
27
27
  should == 'cleartextfinal'
@@ -31,7 +31,7 @@ describe Heirloom do
31
31
  @logger_mock.should_receive(:error).
32
32
  with "Unable to decrypt archive: 'OpenSSL::Cipher::CipherError'"
33
33
  @aes_mock.should_receive(:decrypt)
34
- @aes_mock.should_receive(:key=).with 'badsecret'
34
+ @aes_mock.should_receive(:key=).with Digest::SHA256.hexdigest 'badsecret'
35
35
  @aes_mock.should_receive(:iv=).with 'firstsixteenchar'
36
36
  @aes_mock.should_receive(:update).with('crypteddata').and_return 'crap'
37
37
  @aes_mock.should_receive(:final).and_raise OpenSSL::Cipher::CipherError
@@ -9,6 +9,7 @@ describe Heirloom do
9
9
  @tempfile_stub = stub 'tempfile', :path => '/path_to_encrypted_archive'
10
10
  Tempfile.stub :new => @tempfile_stub
11
11
  @aes_mock = mock 'aes'
12
+ @aes_mock.stub :random_iv => 'firstsixteenchar'
12
13
  OpenSSL::Cipher::AES256.should_receive(:new).
13
14
  with(:CBC).and_return @aes_mock
14
15
  @file = Heirloom::Cipher::File.new :config => @config_mock
@@ -16,12 +17,12 @@ describe Heirloom do
16
17
 
17
18
  it "should encrypt the given file" do
18
19
  @aes_mock.should_receive(:encrypt)
19
- @aes_mock.should_receive(:random_iv).and_return 'firstsixteenchar'
20
20
  @aes_mock.should_receive(:iv=).with 'firstsixteenchar'
21
- @aes_mock.should_receive(:key=).with 'mysecret'
21
+ @aes_mock.should_receive(:key=).with Digest::SHA256.hexdigest 'mysecret'
22
22
  ::File.should_receive(:open)
23
23
  @file.encrypt_file(:file => '/file',
24
- :secret => 'mysecret').should == '/path_to_encrypted_archive'
24
+ :secret => 'mysecret').
25
+ should == '/path_to_encrypted_archive'
25
26
  end
26
27
 
27
28
  end
@@ -8,7 +8,7 @@ describe Heirloom do
8
8
  :accounts => ['test@test.com'],
9
9
  :name => 'archive_name',
10
10
  :id => '1.0.0' }
11
- @logger_stub = stub
11
+ @logger_stub = stub 'logger', :error => true
12
12
  @config_mock = mock 'config'
13
13
  @archive_mock = mock 'archive'
14
14
  @config_mock.stub :logger => @logger_stub,
@@ -35,8 +35,15 @@ describe Heirloom do
35
35
  end
36
36
 
37
37
  it "should authorize an account" do
38
- @archive_mock.should_receive(:authorize).with ['test@test.com']
38
+ @archive_mock.should_receive(:authorize).with(['test@test.com']).
39
+ and_return true
39
40
  @cli_authorize.authorize
40
41
  end
41
42
 
43
+ it "should exit if authorize returns false" do
44
+ @archive_mock.should_receive(:authorize).with(['test@test.com']).
45
+ and_return false
46
+ lambda { @cli_authorize.authorize }.should raise_error SystemExit
47
+ end
48
+
42
49
  end
@@ -34,7 +34,7 @@ describe Heirloom do
34
34
  end
35
35
 
36
36
  it "should destroy an archive" do
37
- @archive_mock.should_receive(:destroy)
37
+ @archive_mock.should_receive(:destroy).with :keep_domain => false
38
38
  @cli_destroy.destroy
39
39
  end
40
40
 
@@ -16,8 +16,9 @@ describe Heirloom do
16
16
  @object.extend Heirloom::CLI::Shared
17
17
  end
18
18
 
19
- it "should exit if the secret is given and under 32 characters" do
19
+ it "should exit if the secret is given and under 8 characters" do
20
20
  @logger_mock.should_receive(:error)
21
+ @logger_mock.stub :info => true
21
22
  lambda { @object.ensure_valid_secret(:secret => 'shorty',
22
23
  :config => @config_mock) }.
23
24
  should raise_error SystemExit
@@ -4,12 +4,12 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- options = { :name => 'archive_name',
8
- :id => '1.0.0',
9
- :level => 'info',
10
- :attribute => 'att',
11
- :updated_value => 'val' }
12
- @logger_stub = stub :debug => true
7
+ options = { :name => 'archive_name',
8
+ :id => '1.0.0',
9
+ :level => 'info',
10
+ :attribute => 'att',
11
+ :value => 'val' }
12
+ @logger_stub = stub :debug => true, :error => true
13
13
  @config_mock = mock 'config'
14
14
  @archive_mock = mock 'archive'
15
15
  @config_mock.stub :logger => @logger_stub,
@@ -18,10 +18,10 @@ describe Heirloom do
18
18
  Trollop.stub(:options).and_return options
19
19
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
20
20
  and_return @logger_stub
21
- Heirloom::CLI::Update.any_instance.should_receive(:load_config).
22
- with(:logger => @logger_stub,
23
- :opts => options).
24
- and_return @config_mock
21
+ Heirloom::CLI::Tag.any_instance.should_receive(:load_config).
22
+ with(:logger => @logger_stub,
23
+ :opts => options).
24
+ and_return @config_mock
25
25
  Heirloom::Archive.should_receive(:new).
26
26
  with(:name => 'archive_name',
27
27
  :config => @config_mock).
@@ -32,14 +32,20 @@ describe Heirloom do
32
32
  :config => @config_mock).
33
33
  and_return @archive_mock
34
34
  @archive_mock.should_receive(:domain_exists?).and_return true
35
- @cli_update = Heirloom::CLI::Update.new
35
+ @cli_tag = Heirloom::CLI::Tag.new
36
36
  end
37
37
 
38
- it "should update an attribute for a given id" do
38
+ it "should tag an archive attribute with a given id" do
39
+ @archive_mock.stub :exists? => true
39
40
  @archive_mock.should_receive(:update).
40
41
  with(:attribute => 'att',
41
42
  :value => 'val')
42
- @cli_update.update
43
+ @cli_tag.tag
44
+ end
45
+
46
+ it "should exit if the archive does not exist" do
47
+ @archive_mock.stub :exists? => false
48
+ lambda { @cli_tag.tag }.should raise_error SystemExit
43
49
  end
44
50
 
45
51
  end
@@ -4,17 +4,17 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- options = { :level => 'info',
8
- :base_prefix => 'base',
9
- :git => false,
10
- :exclude => ['exclude1', 'exclude2'],
11
- :region => ['us-west-1', 'us-west-2'],
12
- :directory => '/buildme',
13
- :public => false,
14
- :name => 'archive_name',
15
- :id => '1.0.0' }
7
+ options = { :level => 'info',
8
+ :base => 'base',
9
+ :git => false,
10
+ :exclude => ['exclude1', 'exclude2'],
11
+ :region => ['us-west-1', 'us-west-2'],
12
+ :directory => '/buildme',
13
+ :public => false,
14
+ :name => 'archive_name',
15
+ :id => '1.0.0' }
16
16
 
17
- @logger_stub = stub :error => true, :info => true
17
+ @logger_stub = stub 'logger', :error => true, :info => true
18
18
  @config_mock = mock 'config'
19
19
  @config_mock.stub :logger => @logger_stub,
20
20
  :access_key => 'key',
@@ -23,38 +23,38 @@ describe Heirloom do
23
23
  Trollop.stub(:options).and_return options
24
24
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
25
25
  and_return @logger_stub
26
- Heirloom::CLI::Build.any_instance.should_receive(:load_config).
27
- with(:logger => @logger_stub,
28
- :opts => options).
29
- and_return @config_mock
26
+ Heirloom::CLI::Upload.any_instance.should_receive(:load_config).
27
+ with(:logger => @logger_stub,
28
+ :opts => options).
29
+ and_return @config_mock
30
30
  Heirloom::Archive.should_receive(:new).
31
31
  with(:id => '1.0.0',
32
32
  :name => 'archive_name',
33
33
  :config => @config_mock).
34
34
  and_return @archive_mock
35
- @build = Heirloom::CLI::Build.new
35
+ @upload = Heirloom::CLI::Upload.new
36
36
  end
37
37
 
38
- it "should build an archive" do
39
- @build.stub :ensure_directory => true
40
- @archive_mock.should_receive(:buckets_exist?).
38
+ it "should upload an archive" do
39
+ @upload.stub :ensure_directory => true
40
+ @upload.stub :ensure_valid_secret => true
41
+ @archive_mock.should_receive(:setup).
41
42
  with(:bucket_prefix => 'base',
42
- :regions => ["us-west-1", "us-west-2"]).
43
- and_return true
43
+ :regions => ["us-west-1", "us-west-2"])
44
44
  @archive_mock.stub :exists? => false
45
45
  @archive_mock.should_receive(:build).
46
- with(:bucket_prefix => 'base',
47
- :directory => '/buildme',
48
- :exclude => ["exclude1", "exclude2"],
49
- :git => false,
50
- :secret => nil).
46
+ with(:base => 'base',
47
+ :directory => '/buildme',
48
+ :exclude => ["exclude1", "exclude2"],
49
+ :git => false,
50
+ :secret => nil).
51
51
  and_return '/tmp/build123.tar.gz'
52
52
  @archive_mock.should_receive(:upload).
53
53
  with(:bucket_prefix => 'base',
54
54
  :regions => ['us-west-1', 'us-west-2'],
55
55
  :public_readable => false,
56
56
  :file => '/tmp/build123.tar.gz')
57
- @build.build
57
+ @upload.upload
58
58
  end
59
59
 
60
60
  end
@@ -22,9 +22,12 @@ describe Heirloom::Directory do
22
22
  end
23
23
 
24
24
  context 'when succesful' do
25
+ before do
26
+ $?.stub :success? => true
27
+ end
28
+
25
29
  context 'without secret provided' do
26
30
  it "should build an archive from the path" do
27
- $?.should_receive(:success?).and_return true
28
31
  @directory.build_artifact_from_directory(:secret => nil).
29
32
  should be_true
30
33
  end
@@ -39,7 +42,6 @@ describe Heirloom::Directory do
39
42
  end
40
43
 
41
44
  it "should build and encrypt an archive from the path" do
42
- $?.should_receive(:success?).and_return true
43
45
  @cipher_mock.should_receive(:encrypt_file).
44
46
  with(:file => '/tmp/file.tar.gz',
45
47
  :secret => 'supersecret').
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heirloom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0rc3
4
+ version: 0.5.0rc4
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70151211289720 !ruby/object:Gem::Requirement
16
+ requirement: &70328442595660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,51 +21,40 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70151211289720
24
+ version_requirements: *70328442595660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fog
27
- requirement: &70151211289060 !ruby/object:Gem::Requirement
27
+ requirement: &70328442595020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 1.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70151211289060
35
+ version_requirements: *70328442595020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: grit
38
- requirement: &70151211287820 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70151211287820
47
- - !ruby/object:Gem::Dependency
48
- name: logger
49
- requirement: &70151211287040 !ruby/object:Gem::Requirement
38
+ requirement: &70328442594520 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
- - - ! '>='
41
+ - - ~>
53
42
  - !ruby/object:Gem::Version
54
- version: '0'
43
+ version: 2.5.0
55
44
  type: :runtime
56
45
  prerelease: false
57
- version_requirements: *70151211287040
46
+ version_requirements: *70328442594520
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: trollop
60
- requirement: &70151211286040 !ruby/object:Gem::Requirement
49
+ requirement: &70328442594040 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
- - - ! '>='
52
+ - - =
64
53
  - !ruby/object:Gem::Version
65
- version: '0'
54
+ version: '2.0'
66
55
  type: :runtime
67
56
  prerelease: false
68
- version_requirements: *70151211286040
57
+ version_requirements: *70328442594040
69
58
  description: I help build and manage building tar.gz files and deploying them into
70
59
  the cloud
71
60
  email:
@@ -94,6 +83,7 @@ files:
94
83
  - lib/heirloom/archive/downloader.rb
95
84
  - lib/heirloom/archive/lister.rb
96
85
  - lib/heirloom/archive/reader.rb
86
+ - lib/heirloom/archive/setuper.rb
97
87
  - lib/heirloom/archive/updater.rb
98
88
  - lib/heirloom/archive/uploader.rb
99
89
  - lib/heirloom/archive/verifier.rb
@@ -106,13 +96,13 @@ files:
106
96
  - lib/heirloom/cipher/file.rb
107
97
  - lib/heirloom/cli.rb
108
98
  - lib/heirloom/cli/authorize.rb
109
- - lib/heirloom/cli/build.rb
110
99
  - lib/heirloom/cli/destroy.rb
111
100
  - lib/heirloom/cli/download.rb
112
101
  - lib/heirloom/cli/list.rb
113
102
  - lib/heirloom/cli/shared.rb
114
103
  - lib/heirloom/cli/show.rb
115
- - lib/heirloom/cli/update.rb
104
+ - lib/heirloom/cli/tag.rb
105
+ - lib/heirloom/cli/upload.rb
116
106
  - lib/heirloom/config.rb
117
107
  - lib/heirloom/destroyer.rb
118
108
  - lib/heirloom/destroyer/s3.rb
@@ -133,6 +123,7 @@ files:
133
123
  - spec/archive/downloader_spec.rb
134
124
  - spec/archive/lister_spec.rb
135
125
  - spec/archive/reader_spec.rb
126
+ - spec/archive/setup_spec.rb
136
127
  - spec/archive/updater_spec.rb
137
128
  - spec/archive/uploader_spec.rb
138
129
  - spec/archive/verifier_spec.rb
@@ -143,13 +134,13 @@ files:
143
134
  - spec/cipher/data_spec.rb
144
135
  - spec/cipher/file_spec.rb
145
136
  - spec/cli/authorize_spec.rb
146
- - spec/cli/build_spec.rb
147
137
  - spec/cli/destroy_spec.rb
148
138
  - spec/cli/download_spec.rb
149
139
  - spec/cli/list_spec.rb
150
140
  - spec/cli/shared_spec.rb
151
141
  - spec/cli/show_spec.rb
152
- - spec/cli/update_spec.rb
142
+ - spec/cli/tag_spec.rb
143
+ - spec/cli/upload_spec.rb
153
144
  - spec/config_spec.rb
154
145
  - spec/destroyer/s3_spec.rb
155
146
  - spec/directory/directory_spec.rb
@@ -171,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
162
  version: '0'
172
163
  segments:
173
164
  - 0
174
- hash: -4293229693492168052
165
+ hash: -3871179857834754510
175
166
  required_rubygems_version: !ruby/object:Gem::Requirement
176
167
  none: false
177
168
  requirements:
@@ -192,6 +183,7 @@ test_files:
192
183
  - spec/archive/downloader_spec.rb
193
184
  - spec/archive/lister_spec.rb
194
185
  - spec/archive/reader_spec.rb
186
+ - spec/archive/setup_spec.rb
195
187
  - spec/archive/updater_spec.rb
196
188
  - spec/archive/uploader_spec.rb
197
189
  - spec/archive/verifier_spec.rb
@@ -202,13 +194,13 @@ test_files:
202
194
  - spec/cipher/data_spec.rb
203
195
  - spec/cipher/file_spec.rb
204
196
  - spec/cli/authorize_spec.rb
205
- - spec/cli/build_spec.rb
206
197
  - spec/cli/destroy_spec.rb
207
198
  - spec/cli/download_spec.rb
208
199
  - spec/cli/list_spec.rb
209
200
  - spec/cli/shared_spec.rb
210
201
  - spec/cli/show_spec.rb
211
- - spec/cli/update_spec.rb
202
+ - spec/cli/tag_spec.rb
203
+ - spec/cli/upload_spec.rb
212
204
  - spec/config_spec.rb
213
205
  - spec/destroyer/s3_spec.rb
214
206
  - spec/directory/directory_spec.rb