omnibus 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/CHANGELOG.md +21 -0
  4. data/Gemfile +8 -5
  5. data/README.md +3 -1
  6. data/Rakefile +20 -13
  7. data/appveyor.yml +4 -3
  8. data/bin/omnibus +3 -3
  9. data/features/commands/manifest.feature +19 -5
  10. data/features/step_definitions/generator_steps.rb +5 -6
  11. data/features/support/env.rb +4 -4
  12. data/lib/omnibus/build_version.rb +14 -14
  13. data/lib/omnibus/build_version_dsl.rb +3 -3
  14. data/lib/omnibus/builder.rb +50 -61
  15. data/lib/omnibus/changelog.rb +2 -2
  16. data/lib/omnibus/changelog_printer.rb +4 -4
  17. data/lib/omnibus/cleaner.rb +4 -4
  18. data/lib/omnibus/cli/base.rb +15 -15
  19. data/lib/omnibus/cli/cache.rb +13 -13
  20. data/lib/omnibus/cli/changelog.rb +8 -9
  21. data/lib/omnibus/cli/publish.rb +12 -13
  22. data/lib/omnibus/cli.rb +26 -27
  23. data/lib/omnibus/compressor.rb +6 -6
  24. data/lib/omnibus/compressors/base.rb +7 -2
  25. data/lib/omnibus/compressors/dmg.rb +12 -12
  26. data/lib/omnibus/compressors/null.rb +1 -1
  27. data/lib/omnibus/compressors/tgz.rb +8 -8
  28. data/lib/omnibus/config.rb +37 -26
  29. data/lib/omnibus/core_extensions/open_uri.rb +3 -3
  30. data/lib/omnibus/core_extensions.rb +1 -1
  31. data/lib/omnibus/digestable.rb +5 -4
  32. data/lib/omnibus/download_helpers.rb +7 -6
  33. data/lib/omnibus/exceptions.rb +29 -13
  34. data/lib/omnibus/fetcher.rb +0 -1
  35. data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
  36. data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
  37. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  38. data/lib/omnibus/file_syncer.rb +3 -3
  39. data/lib/omnibus/generator.rb +60 -47
  40. data/lib/omnibus/git_cache.rb +33 -22
  41. data/lib/omnibus/git_repository.rb +5 -5
  42. data/lib/omnibus/health_check.rb +122 -119
  43. data/lib/omnibus/instrumentation.rb +1 -1
  44. data/lib/omnibus/licensing.rb +348 -60
  45. data/lib/omnibus/logger.rb +12 -9
  46. data/lib/omnibus/logging.rb +1 -1
  47. data/lib/omnibus/manifest.rb +4 -4
  48. data/lib/omnibus/manifest_diff.rb +6 -7
  49. data/lib/omnibus/manifest_entry.rb +1 -1
  50. data/lib/omnibus/metadata.rb +36 -36
  51. data/lib/omnibus/ohai.rb +6 -7
  52. data/lib/omnibus/package.rb +1 -1
  53. data/lib/omnibus/packager.rb +37 -28
  54. data/lib/omnibus/packagers/appx.rb +86 -0
  55. data/lib/omnibus/packagers/base.rb +21 -18
  56. data/lib/omnibus/packagers/bff.rb +22 -24
  57. data/lib/omnibus/packagers/deb.rb +20 -20
  58. data/lib/omnibus/packagers/ips.rb +18 -17
  59. data/lib/omnibus/packagers/makeself.rb +7 -7
  60. data/lib/omnibus/packagers/msi.rb +38 -193
  61. data/lib/omnibus/packagers/pkg.rb +16 -16
  62. data/lib/omnibus/packagers/rpm.rb +53 -54
  63. data/lib/omnibus/packagers/solaris.rb +14 -14
  64. data/lib/omnibus/packagers/windows_base.rb +192 -0
  65. data/lib/omnibus/project.rb +45 -43
  66. data/lib/omnibus/publisher.rb +3 -3
  67. data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
  68. data/lib/omnibus/publishers/s3_publisher.rb +7 -7
  69. data/lib/omnibus/reports.rb +10 -10
  70. data/lib/omnibus/s3_cache.rb +7 -7
  71. data/lib/omnibus/s3_helpers.rb +8 -7
  72. data/lib/omnibus/semantic_version.rb +1 -1
  73. data/lib/omnibus/software.rb +131 -81
  74. data/lib/omnibus/sugarable.rb +10 -10
  75. data/lib/omnibus/templating.rb +5 -5
  76. data/lib/omnibus/thread_pool.rb +1 -1
  77. data/lib/omnibus/util.rb +5 -5
  78. data/lib/omnibus/version.rb +1 -1
  79. data/lib/omnibus.rb +65 -65
  80. data/omnibus.gemspec +34 -32
  81. data/resources/appx/AppxManifest.xml.erb +18 -0
  82. data/resources/appx/assets/clear.png +0 -0
  83. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
  84. data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
  85. data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
  86. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
  87. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
  88. data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
  89. data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
  90. data/spec/functional/builder_spec.rb +149 -150
  91. data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
  92. data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
  93. data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
  94. data/spec/functional/file_syncer_spec.rb +74 -74
  95. data/spec/functional/licensing_spec.rb +344 -35
  96. data/spec/functional/templating_spec.rb +17 -17
  97. data/spec/spec_helper.rb +20 -20
  98. data/spec/support/examples.rb +21 -15
  99. data/spec/support/file_helpers.rb +1 -1
  100. data/spec/support/git_helpers.rb +37 -37
  101. data/spec/support/matchers.rb +3 -3
  102. data/spec/support/ohai_helpers.rb +4 -4
  103. data/spec/support/path_helpers.rb +2 -2
  104. data/spec/support/shell_helpers.rb +2 -2
  105. data/spec/unit/build_version_dsl_spec.rb +5 -5
  106. data/spec/unit/build_version_spec.rb +63 -63
  107. data/spec/unit/builder_spec.rb +86 -70
  108. data/spec/unit/changelog_spec.rb +4 -4
  109. data/spec/unit/changelogprinter_spec.rb +130 -0
  110. data/spec/unit/cleanroom_spec.rb +11 -11
  111. data/spec/unit/compressor_spec.rb +16 -16
  112. data/spec/unit/compressors/base_spec.rb +6 -6
  113. data/spec/unit/compressors/dmg_spec.rb +76 -76
  114. data/spec/unit/compressors/null_spec.rb +4 -4
  115. data/spec/unit/compressors/tgz_spec.rb +20 -20
  116. data/spec/unit/config_spec.rb +44 -43
  117. data/spec/unit/digestable_spec.rb +13 -13
  118. data/spec/unit/fetcher_spec.rb +11 -12
  119. data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
  120. data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
  121. data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
  122. data/spec/unit/generator_spec.rb +38 -38
  123. data/spec/unit/git_cache_spec.rb +56 -54
  124. data/spec/unit/git_repository_spec.rb +2 -2
  125. data/spec/unit/health_check_spec.rb +40 -40
  126. data/spec/unit/library_spec.rb +35 -35
  127. data/spec/unit/manifest_diff_spec.rb +10 -11
  128. data/spec/unit/manifest_spec.rb +17 -17
  129. data/spec/unit/metadata_spec.rb +152 -152
  130. data/spec/unit/ohai_spec.rb +5 -5
  131. data/spec/unit/omnibus_spec.rb +31 -31
  132. data/spec/unit/package_spec.rb +20 -20
  133. data/spec/unit/packager_spec.rb +48 -42
  134. data/spec/unit/packagers/appx_spec.rb +165 -0
  135. data/spec/unit/packagers/base_spec.rb +34 -34
  136. data/spec/unit/packagers/bff_spec.rb +60 -60
  137. data/spec/unit/packagers/deb_spec.rb +71 -71
  138. data/spec/unit/packagers/ips_spec.rb +45 -45
  139. data/spec/unit/packagers/makeself_spec.rb +22 -22
  140. data/spec/unit/packagers/msi_spec.rb +141 -147
  141. data/spec/unit/packagers/pkg_spec.rb +59 -60
  142. data/spec/unit/packagers/rpm_spec.rb +125 -126
  143. data/spec/unit/packagers/solaris_spec.rb +52 -52
  144. data/spec/unit/project_spec.rb +137 -135
  145. data/spec/unit/publisher_spec.rb +70 -70
  146. data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
  147. data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
  148. data/spec/unit/s3_cacher_spec.rb +34 -34
  149. data/spec/unit/s3_helpers_spec.rb +6 -6
  150. data/spec/unit/semantic_version_spec.rb +2 -2
  151. data/spec/unit/software_spec.rb +346 -384
  152. data/spec/unit/sugarable_spec.rb +10 -10
  153. data/spec/unit/util_spec.rb +60 -60
  154. metadata +54 -6
  155. data/.rubocop.yml +0 -48
@@ -1,32 +1,32 @@
1
- require 'omnibus'
2
- require 'spec_helper'
1
+ require "omnibus"
2
+ require "spec_helper"
3
3
 
4
4
  describe Omnibus do
5
5
  before do
6
6
  allow(File).to receive(:directory?).and_return(true)
7
7
 
8
8
  allow(Gem::Specification).to receive(:find_all_by_name)
9
- .with('omnibus-software')
10
- .and_return([double(gem_dir: File.join(tmp_path, '/gem/omnibus-software'))])
9
+ .with("omnibus-software")
10
+ .and_return([double(gem_dir: File.join(tmp_path, "/gem/omnibus-software"))])
11
11
 
12
12
  allow(Gem::Specification).to receive(:find_all_by_name)
13
- .with('custom-omnibus-software')
14
- .and_return([double(gem_dir: File.join(tmp_path, '/gem/custom-omnibus-software'))])
13
+ .with("custom-omnibus-software")
14
+ .and_return([double(gem_dir: File.join(tmp_path, "/gem/custom-omnibus-software"))])
15
15
 
16
- Omnibus::Config.project_root(File.join(tmp_path, '/foo/bar'))
17
- Omnibus::Config.local_software_dirs([File.join(tmp_path, '/local'), File.join(tmp_path, '/other')])
18
- Omnibus::Config.software_gems(['omnibus-software', 'custom-omnibus-software'])
16
+ Omnibus::Config.project_root(File.join(tmp_path, "/foo/bar"))
17
+ Omnibus::Config.local_software_dirs([File.join(tmp_path, "/local"), File.join(tmp_path, "/other")])
18
+ Omnibus::Config.software_gems(["omnibus-software", "custom-omnibus-software"])
19
19
  end
20
20
 
21
21
  describe '#which' do
22
- it 'returns nil when the file does not exist' do
23
- stub_env('PATH', nil)
24
- expect(subject.which('not_a_real_executable')).to be nil
22
+ it "returns nil when the file does not exist" do
23
+ stub_env("PATH", nil)
24
+ expect(subject.which("not_a_real_executable")).to be nil
25
25
  end
26
26
 
27
- it 'returns the path when the file exists' do
27
+ it "returns the path when the file exists" do
28
28
 
29
- ruby_cmd = windows? ? 'ruby.exe' : 'ruby'
29
+ ruby_cmd = windows? ? "ruby.exe" : "ruby"
30
30
  ruby = Bundler.which(ruby_cmd)
31
31
  expect(subject.which(ruby)).to eq(ruby)
32
32
  expect(subject.which(ruby_cmd)).to eq(ruby)
@@ -36,50 +36,50 @@ describe Omnibus do
36
36
  describe '#project_path' do
37
37
  before do
38
38
  allow(Omnibus).to receive(:project_map)
39
- .and_return('chef' => '/projects/chef')
39
+ .and_return("chef" => "/projects/chef")
40
40
  end
41
41
 
42
- it 'accepts a string' do
43
- expect(subject.project_path('chef')).to eq('/projects/chef')
42
+ it "accepts a string" do
43
+ expect(subject.project_path("chef")).to eq("/projects/chef")
44
44
  end
45
45
 
46
- it 'accepts a symbol' do
47
- expect(subject.project_path(:chef)).to eq('/projects/chef')
46
+ it "accepts a symbol" do
47
+ expect(subject.project_path(:chef)).to eq("/projects/chef")
48
48
  end
49
49
 
50
- it 'returns nil when the project does not exist' do
51
- expect(subject.project_path('bacon')).to be nil
50
+ it "returns nil when the project does not exist" do
51
+ expect(subject.project_path("bacon")).to be nil
52
52
  end
53
53
  end
54
54
 
55
55
  describe '#software_path' do
56
56
  before do
57
57
  allow(Omnibus).to receive(:software_map)
58
- .and_return('chef' => '/software/chef')
58
+ .and_return("chef" => "/software/chef")
59
59
  end
60
60
 
61
- it 'accepts a string' do
62
- expect(subject.software_path('chef')).to eq('/software/chef')
61
+ it "accepts a string" do
62
+ expect(subject.software_path("chef")).to eq("/software/chef")
63
63
  end
64
64
 
65
- it 'accepts a symbol' do
66
- expect(subject.software_path(:chef)).to eq('/software/chef')
65
+ it "accepts a symbol" do
66
+ expect(subject.software_path(:chef)).to eq("/software/chef")
67
67
  end
68
68
 
69
- it 'returns nil when the project does not exist' do
70
- expect(subject.software_path('bacon')).to be nil
69
+ it "returns nil when the project does not exist" do
70
+ expect(subject.software_path("bacon")).to be nil
71
71
  end
72
72
  end
73
73
 
74
74
  describe '#possible_paths_for' do
75
- it 'searches all paths' do
76
- expect(subject.possible_paths_for('file')).to eq(%w(
75
+ it "searches all paths" do
76
+ expect(subject.possible_paths_for("file")).to eq(%w{
77
77
  /foo/bar/file
78
78
  /local/file
79
79
  /other/file
80
80
  /gem/omnibus-software/file
81
81
  /gem/custom-omnibus-software/file
82
- ).map { |path| File.join(tmp_path, path) })
82
+ }.map { |path| File.join(tmp_path, path) })
83
83
  end
84
84
  end
85
85
  end
@@ -1,68 +1,68 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Omnibus
4
4
  describe Package do
5
- let(:path) { windows? ? 'C:/path/to/files/thing.deb' : '/path/to/files/thing.deb' }
5
+ let(:path) { windows? ? "C:/path/to/files/thing.deb" : "/path/to/files/thing.deb" }
6
6
 
7
7
  subject { described_class.new(path) }
8
8
 
9
- describe '.initialize' do
10
- it 'sets the path' do
9
+ describe ".initialize" do
10
+ it "sets the path" do
11
11
  expect(subject.instance_variables).to include(:@path)
12
12
  end
13
13
  end
14
14
 
15
15
  describe '#name' do
16
- it 'returns the basename of the file' do
17
- expect(subject.name).to eq('thing.deb')
16
+ it "returns the basename of the file" do
17
+ expect(subject.name).to eq("thing.deb")
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#md5' do
22
- let(:md5) { 'abcdef123456' }
22
+ let(:md5) { "abcdef123456" }
23
23
 
24
24
  before { allow(subject).to receive(:digest).with(path, :md5).and_return(md5) }
25
25
 
26
- it 'returns the md5 of the package at the path' do
26
+ it "returns the md5 of the package at the path" do
27
27
  expect(subject.md5).to eq(md5)
28
28
  end
29
29
  end
30
30
 
31
31
  describe '#sha256' do
32
- let(:sha256) { 'abcdef123456' }
32
+ let(:sha256) { "abcdef123456" }
33
33
 
34
34
  before { allow(subject).to receive(:digest).with(path, :sha256).and_return(sha256) }
35
35
 
36
- it 'returns the sha256 of the package at the path' do
36
+ it "returns the sha256 of the package at the path" do
37
37
  expect(subject.sha256).to eq(sha256)
38
38
  end
39
39
  end
40
40
 
41
41
  describe '#sha512' do
42
- let(:sha512) { 'abcdef123456' }
42
+ let(:sha512) { "abcdef123456" }
43
43
 
44
44
  before { allow(subject).to receive(:digest).with(path, :sha512).and_return(sha512) }
45
45
 
46
- it 'returns the sha512 of the package at the path' do
46
+ it "returns the sha512 of the package at the path" do
47
47
  expect(subject.sha512).to eq(sha512)
48
48
  end
49
49
  end
50
50
 
51
51
  describe '#content' do
52
- context 'when the file exists' do
53
- let(:content) { 'BINARY' }
52
+ context "when the file exists" do
53
+ let(:content) { "BINARY" }
54
54
 
55
55
  before { allow(IO).to receive(:read).with(path).and_return(content) }
56
56
 
57
- it 'reads the file' do
57
+ it "reads the file" do
58
58
  expect(subject.content).to eq(content)
59
59
  end
60
60
  end
61
61
 
62
- context 'when the file does not exist' do
62
+ context "when the file does not exist" do
63
63
  before { allow(IO).to receive(:read).and_raise(Errno::ENOENT) }
64
64
 
65
- it 'raises an exception' do
65
+ it "raises an exception" do
66
66
  expect { subject.content }.to raise_error(NoPackageFile)
67
67
  end
68
68
  end
@@ -73,12 +73,12 @@ module Omnibus
73
73
 
74
74
  before { allow(IO).to receive(:read).and_return(content) }
75
75
 
76
- it 'returns a Metadata object' do
76
+ it "returns a Metadata object" do
77
77
  expect(subject.metadata).to be_a(Metadata)
78
78
  end
79
79
 
80
- it 'reads the information in the file' do
81
- expect(subject.metadata[:platform]).to eq('ubuntu')
80
+ it "reads the information in the file" do
81
+ expect(subject.metadata[:platform]).to eq("ubuntu")
82
82
  end
83
83
  end
84
84
  end
@@ -1,63 +1,69 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Omnibus
4
4
  describe Packager do
5
- describe '.for_current_system' do
6
- context 'on Mac OS X' do
7
- before { stub_ohai(platform: 'mac_os_x', version: '10.9.2') }
8
- it 'prefers PKG' do
9
- expect(described_class.for_current_system).to eq(Packager::PKG)
10
- end
5
+ describe ".for_current_system" do
6
+ context "on Mac OS X" do
7
+ before { stub_ohai(platform: "mac_os_x", version: "10.9.2") }
8
+ it "prefers PKG" do
9
+ expect(described_class.for_current_system).to eq([Packager::PKG])
10
+ end
11
11
  end
12
12
 
13
- context 'on Windows' do
14
- before { stub_ohai(platform: 'windows', version: '2012') }
15
- it 'prefers MSI' do
16
- expect(described_class.for_current_system).to eq(Packager::MSI)
17
- end
13
+ context "on Windows 2012" do
14
+ before { stub_ohai(platform: "windows", version: "2012") }
15
+ it "prefers MSI and APPX" do
16
+ expect(described_class.for_current_system).to eq([Packager::MSI, Packager::APPX])
17
+ end
18
18
  end
19
19
 
20
- context 'on Solaris 11' do
21
- before { stub_ohai(platform: 'solaris2', version: '5.11') }
22
- it 'prefers IPS' do
23
- expect(described_class.for_current_system).to eq(Packager::IPS)
24
- end
20
+ context "on Windows 2008 R2" do
21
+ before { stub_ohai(platform: "windows", version: "2008R2") }
22
+ it "prefers MSI only" do
23
+ expect(described_class.for_current_system).to eq([Packager::MSI])
24
+ end
25
25
  end
26
26
 
27
- context 'on Solaris 10' do
28
- before { stub_ohai(platform: 'solaris2', version: '5.10') }
29
- it 'prefers Solaris' do
30
- expect(described_class.for_current_system).to eq(Packager::Solaris)
31
- end
27
+ context "on Solaris 11" do
28
+ before { stub_ohai(platform: "solaris2", version: "5.11") }
29
+ it "prefers IPS" do
30
+ expect(described_class.for_current_system).to eq([Packager::IPS])
31
+ end
32
32
  end
33
33
 
34
+ context "on Solaris 10" do
35
+ before { stub_ohai(platform: "solaris2", version: "5.10") }
36
+ it "prefers Solaris" do
37
+ expect(described_class.for_current_system).to eq([Packager::Solaris])
38
+ end
39
+ end
34
40
 
35
- context 'on aix' do
36
- before { stub_ohai(platform: 'aix', version: '7.1') }
37
- it 'prefers BFF' do
38
- expect(described_class.for_current_system).to eq(Packager::BFF)
39
- end
41
+ context "on aix" do
42
+ before { stub_ohai(platform: "aix", version: "7.1") }
43
+ it "prefers BFF" do
44
+ expect(described_class.for_current_system).to eq([Packager::BFF])
45
+ end
40
46
  end
41
47
 
42
- context 'on fedora' do
43
- before { stub_ohai(platform: 'fedora', version: '20') }
44
- it 'prefers RPM' do
45
- expect(described_class.for_current_system).to eq(Packager::RPM)
46
- end
48
+ context "on fedora" do
49
+ before { stub_ohai(platform: "fedora", version: "20") }
50
+ it "prefers RPM" do
51
+ expect(described_class.for_current_system).to eq([Packager::RPM])
52
+ end
47
53
  end
48
54
 
49
- context 'on debian' do
50
- before { stub_ohai(platform: 'debian', version: '7.2') }
51
- it 'prefers RPM' do
52
- expect(described_class.for_current_system).to eq(Packager::DEB)
53
- end
55
+ context "on debian" do
56
+ before { stub_ohai(platform: "debian", version: "7.2") }
57
+ it "prefers RPM" do
58
+ expect(described_class.for_current_system).to eq([Packager::DEB])
59
+ end
54
60
  end
55
61
 
56
- context 'on suse' do
57
- before { stub_ohai(platform: 'suse', version: '12.0') }
58
- it 'prefers RPM' do
59
- expect(described_class.for_current_system).to eq(Packager::RPM)
60
- end
62
+ context "on suse" do
63
+ before { stub_ohai(platform: "suse", version: "12.0") }
64
+ it "prefers RPM" do
65
+ expect(described_class.for_current_system).to eq([Packager::RPM])
66
+ end
61
67
  end
62
68
  end
63
69
  end
@@ -0,0 +1,165 @@
1
+ require "spec_helper"
2
+
3
+ module Omnibus
4
+ describe Packager::APPX do
5
+ let(:project) do
6
+ Project.new.tap do |project|
7
+ project.name("project")
8
+ project.homepage("https://example.com")
9
+ project.install_dir(install_dir)
10
+ project.build_version("1.2.3")
11
+ project.build_iteration("2")
12
+ project.maintainer("Chef Software <maintainers@chef.io>")
13
+ end
14
+ end
15
+
16
+ subject { described_class.new(project) }
17
+
18
+ let(:project_root) { File.join(tmp_path, "project/root") }
19
+ let(:package_dir) { File.join(tmp_path, "package/dir") }
20
+ let(:staging_dir) { File.join(tmp_path, "staging/dir") }
21
+ let(:install_dir) { File.join(tmp_path, "install/dir") }
22
+
23
+ before do
24
+ Config.project_root(project_root)
25
+ Config.package_dir(package_dir)
26
+
27
+ allow(subject).to receive(:staging_dir).and_return(staging_dir)
28
+ create_directory(install_dir)
29
+ end
30
+
31
+ describe "DSL" do
32
+ it "exposes :signing_identity" do
33
+ expect(subject).to have_exposed_method(:signing_identity)
34
+ end
35
+ end
36
+
37
+ describe '#id' do
38
+ it "is :pkg" do
39
+ expect(subject.id).to eq(:appx)
40
+ end
41
+ end
42
+
43
+ describe '#package_name' do
44
+ it "includes the name, version, and build iteration" do
45
+ expect(subject.package_name).to eq("project-1.2.3-2.appx")
46
+ end
47
+ end
48
+
49
+ describe '#write_manifest_file' do
50
+ before do
51
+ allow(subject).to receive(:shellout!).and_return(double("output", stdout: "CN=Chef "))
52
+ allow(subject).to receive(:signing_identity).and_return({})
53
+ end
54
+
55
+ it "generates the file" do
56
+ subject.write_manifest_file
57
+ expect("#{install_dir}/AppxManifest.xml").to be_a_file
58
+ end
59
+
60
+ it "has the correct content" do
61
+ subject.write_manifest_file
62
+ contents = File.read("#{install_dir}/AppxManifest.xml")
63
+
64
+ expect(contents).to include('Name="project"')
65
+ expect(contents).to include('Version="1.2.3.2"')
66
+ expect(contents).to include('Publisher="CN=Chef"')
67
+ expect(contents).to include("<DisplayName>Project</DisplayName>")
68
+ expect(contents).to include(
69
+ '<PublisherDisplayName>"Chef Software &lt;maintainers@chef.io&gt;"</PublisherDisplayName>'
70
+ )
71
+ end
72
+ end
73
+
74
+ describe '#windows_package_version' do
75
+ context "when the project build_version semver" do
76
+ it "returns the right value" do
77
+ expect(subject.windows_package_version).to eq("1.2.3.2")
78
+ end
79
+ end
80
+
81
+ context "when the project build_version is git" do
82
+ before { project.build_version("1.2.3-alpha.1+20140501194641.git.94.561b564") }
83
+
84
+ it "returns the right value" do
85
+ expect(subject.windows_package_version).to eq("1.2.3.2")
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '#pack_command' do
91
+ it "returns a String" do
92
+ expect(subject.pack_command("foo")).to be_a(String)
93
+ end
94
+
95
+ it "packages install directory" do
96
+ expect(subject.pack_command("foo")).to(
97
+ include("/d \"#{subject.windows_safe_path(install_dir)}\"")
98
+ )
99
+ end
100
+
101
+ it "writes to the given appx file" do
102
+ expect(subject.pack_command("foo")).to include("/p foo")
103
+ end
104
+ end
105
+
106
+ context "when signing parameters are provided" do
107
+ let(:appx) { "someappx.appx" }
108
+
109
+ context "when invalid parameters" do
110
+ it "should raise an InvalidValue error when the certificate name is not a String" do
111
+ expect { subject.signing_identity(Object.new) }.to raise_error(InvalidValue)
112
+ end
113
+
114
+ it "should raise an InvalidValue error when params is not a Hash" do
115
+ expect { subject.signing_identity("foo", Object.new) }.to raise_error(InvalidValue)
116
+ end
117
+
118
+ it "should raise an InvalidValue error when params contains an invalid key" do
119
+ expect { subject.signing_identity("foo", bar: "baz") }.to raise_error(InvalidValue)
120
+ end
121
+ end
122
+
123
+ context "when valid parameters" do
124
+ before do
125
+ allow(subject).to receive(:shellout!)
126
+ end
127
+
128
+ describe '#timestamp_servers' do
129
+ it "defaults to using ['http://timestamp.digicert.com','http://timestamp.verisign.com/scripts/timestamp.dll']" do
130
+ subject.signing_identity("foo")
131
+ expect(subject).to receive(:try_sign).with(appx, "http://timestamp.digicert.com").and_return(false)
132
+ expect(subject).to receive(:try_sign).with(appx, "http://timestamp.verisign.com/scripts/timestamp.dll").and_return(true)
133
+ subject.sign_package(appx)
134
+ end
135
+
136
+ it 'uses the timestamp server if provided through the #timestamp_server dsl' do
137
+ subject.signing_identity("foo", timestamp_servers: "http://fooserver")
138
+ expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(true)
139
+ subject.sign_package(appx)
140
+ end
141
+
142
+ it 'tries all timestamp server if provided through the #timestamp_server dsl' do
143
+ subject.signing_identity("foo", timestamp_servers: ["http://fooserver", "http://barserver"])
144
+ expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(false)
145
+ expect(subject).to receive(:try_sign).with(appx, "http://barserver").and_return(true)
146
+ subject.sign_package(appx)
147
+ end
148
+
149
+ it 'tries all timestamp server if provided through the #timestamp_servers dsl and stops at the first available' do
150
+ subject.signing_identity("foo", timestamp_servers: ["http://fooserver", "http://barserver"])
151
+ expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(true)
152
+ expect(subject).not_to receive(:try_sign).with(appx, "http://barserver")
153
+ subject.sign_package(appx)
154
+ end
155
+
156
+ it "raises an exception if there are no available timestamp servers" do
157
+ subject.signing_identity("foo", timestamp_servers: "http://fooserver")
158
+ expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(false)
159
+ expect { subject.sign_package(appx) }.to raise_error(FailedToSignWindowsPackage)
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -1,60 +1,60 @@
1
- require 'stringio'
1
+ require "stringio"
2
2
 
3
3
  module Omnibus
4
4
  describe Packager::Base do
5
5
  let(:project) do
6
6
  Project.new.tap do |project|
7
- project.name('project')
8
- project.install_dir(File.join(tmp_path, 'opt/project'))
9
- project.homepage('https://example.com')
10
- project.build_version('1.2.3')
11
- project.build_iteration('2')
12
- project.maintainer('Chef Software')
7
+ project.name("project")
8
+ project.install_dir(File.join(tmp_path, "opt/project"))
9
+ project.homepage("https://example.com")
10
+ project.build_version("1.2.3")
11
+ project.build_iteration("2")
12
+ project.maintainer("Chef Software")
13
13
  end
14
14
  end
15
15
 
16
16
  before do
17
17
  # Force the Dir.mktmpdir call on staging_dir
18
- allow(Dir).to receive(:mktmpdir).and_return(File.join(tmp_path, 'tmp/dir'))
18
+ allow(Dir).to receive(:mktmpdir).and_return(File.join(tmp_path, "tmp/dir"))
19
19
 
20
20
  Config.package_dir(tmp_path)
21
21
  end
22
22
 
23
23
  subject { described_class.new(project) }
24
24
 
25
- it 'includes Cleanroom' do
25
+ it "includes Cleanroom" do
26
26
  expect(subject).to be_a(Cleanroom)
27
27
  end
28
28
 
29
- it 'includes Digestable' do
29
+ it "includes Digestable" do
30
30
  expect(subject).to be_a(Digestable)
31
31
  end
32
32
 
33
- it 'includes Logging' do
33
+ it "includes Logging" do
34
34
  expect(subject).to be_a(Logging)
35
35
  end
36
36
 
37
- it 'includes NullArgumentable' do
37
+ it "includes NullArgumentable" do
38
38
  expect(subject).to be_a(NullArgumentable)
39
39
  end
40
40
 
41
- it 'includes Templating' do
41
+ it "includes Templating" do
42
42
  expect(subject).to be_a(Templating)
43
43
  end
44
44
 
45
- it 'includes Util' do
45
+ it "includes Util" do
46
46
  expect(subject).to be_a(Util)
47
47
  end
48
48
 
49
- describe '.id' do
50
- it 'defines the id method on the instance' do
49
+ describe ".id" do
50
+ it "defines the id method on the instance" do
51
51
  described_class.id(:base)
52
52
  expect(subject.id).to eq(:base)
53
53
  end
54
54
  end
55
55
 
56
- describe '.setup' do
57
- it 'sets the value of the block' do
56
+ describe ".setup" do
57
+ it "sets the value of the block" do
58
58
  block = proc {}
59
59
  described_class.setup(&block)
60
60
 
@@ -62,8 +62,8 @@ module Omnibus
62
62
  end
63
63
  end
64
64
 
65
- describe '.build' do
66
- it 'sets the value of the block' do
65
+ describe ".build" do
66
+ it "sets the value of the block" do
67
67
  block = proc {}
68
68
  described_class.build(&block)
69
69
 
@@ -72,17 +72,17 @@ module Omnibus
72
72
  end
73
73
 
74
74
  describe '#install_dir' do
75
- it 'is a DSL method' do
75
+ it "is a DSL method" do
76
76
  expect(subject).to have_exposed_method(:install_dir)
77
77
  end
78
78
 
79
- it 'returns the project instances install_dir' do
79
+ it "returns the project instances install_dir" do
80
80
  expect(subject.install_dir).to eq(project.install_dir)
81
81
  end
82
82
  end
83
83
 
84
84
  describe '#windows_safe_path' do
85
- it 'is a DSL method' do
85
+ it "is a DSL method" do
86
86
  expect(subject).to have_exposed_method(:windows_safe_path)
87
87
  end
88
88
  end
@@ -95,10 +95,10 @@ module Omnibus
95
95
  allow(described_class).to receive(:setup).and_return(proc {})
96
96
  allow(described_class).to receive(:build).and_return(proc {})
97
97
 
98
- allow(subject).to receive(:package_name).and_return('foo')
98
+ allow(subject).to receive(:package_name).and_return("foo")
99
99
  end
100
100
 
101
- it 'calls the methods in order' do
101
+ it "calls the methods in order" do
102
102
  expect(described_class).to receive(:setup).ordered
103
103
  expect(described_class).to receive(:build).ordered
104
104
  subject.run!
@@ -106,7 +106,7 @@ module Omnibus
106
106
  end
107
107
 
108
108
  describe '#staging_dir' do
109
- it 'creates a temporary directory' do
109
+ it "creates a temporary directory" do
110
110
  expect(Dir).to receive(:mktmpdir)
111
111
  subject.send(:staging_dir)
112
112
  end
@@ -116,8 +116,8 @@ module Omnibus
116
116
  let(:id) { :base }
117
117
  before { allow(subject).to receive(:id).and_return(id) }
118
118
 
119
- context 'when a local resource exists' do
120
- let(:resources_path) { File.join(tmp_path, '/resources/path') }
119
+ context "when a local resource exists" do
120
+ let(:resources_path) { File.join(tmp_path, "/resources/path") }
121
121
 
122
122
  before do
123
123
  project.resources_path(resources_path)
@@ -127,18 +127,18 @@ module Omnibus
127
127
  .and_return(true)
128
128
  end
129
129
 
130
- it 'returns the local path' do
131
- expect(subject.resource_path('foo/bar.erb')).to eq("#{resources_path}/#{id}/foo/bar.erb")
130
+ it "returns the local path" do
131
+ expect(subject.resource_path("foo/bar.erb")).to eq("#{resources_path}/#{id}/foo/bar.erb")
132
132
  end
133
133
 
134
- it 'returns the path with the id' do
134
+ it "returns the path with the id" do
135
135
  expect(subject.resources_path).to eq("#{resources_path}/#{id}")
136
136
  end
137
137
  end
138
138
 
139
- context 'when a local resource does not exist' do
140
- it 'returns the remote path' do
141
- expect(subject.resource_path('foo/bar.erb')).to eq("#{Omnibus.source_root.join("resources/#{id}/foo/bar.erb")}")
139
+ context "when a local resource does not exist" do
140
+ it "returns the remote path" do
141
+ expect(subject.resource_path("foo/bar.erb")).to eq("#{Omnibus.source_root.join("resources/#{id}/foo/bar.erb")}")
142
142
  end
143
143
  end
144
144
  end