r10k 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.mkd +150 -0
- data/README.mkd +10 -1
- data/doc/dynamic-environments/configuration.mkd +31 -0
- data/doc/dynamic-environments/quickstart.mkd +33 -79
- data/doc/faq.mkd +67 -0
- data/doc/git/providers.mkd +37 -0
- data/doc/puppetfile.mkd +73 -0
- data/integration/lib/r10k_utils.rb +47 -2
- data/integration/pre-suite/01_git_config.rb +9 -8
- data/integration/pre-suite/02_pe_r10k.rb +5 -8
- data/integration/scripts/setup_r10k_env_centos5.sh +1 -1
- data/integration/scripts/setup_r10k_env_centos6.sh +1 -1
- data/integration/scripts/setup_r10k_env_rhel7.sh +1 -1
- data/integration/scripts/setup_r10k_env_sles11.sh +1 -1
- data/integration/scripts/setup_r10k_env_sles12.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1004.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1204.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +1 -1
- data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
- data/integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb +71 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +7 -2
- data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +3 -2
- data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +3 -2
- data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +56 -0
- data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
- data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
- data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +2 -1
- data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +2 -1
- data/integration/tests/command_line/deploy_env_without_mod_update.rb +3 -2
- data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +3 -2
- data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +2 -1
- data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +2 -1
- data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +3 -4
- data/integration/tests/git_source/git_source_git.rb +7 -2
- data/integration/tests/git_source/git_source_ssh.rb +3 -2
- data/integration/tests/git_source/git_source_submodule.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_broken_remote.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +3 -3
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +9 -5
- data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +7 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +3 -4
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +10 -4
- data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +7 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +3 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +3 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +4 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -2
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +4 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -2
- data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +3 -2
- data/lib/r10k/action/base.rb +31 -0
- data/lib/r10k/action/deploy/deploy_helpers.rb +34 -0
- data/lib/r10k/action/deploy/display.rb +57 -75
- data/lib/r10k/action/deploy/environment.rb +52 -15
- data/lib/r10k/action/deploy/module.rb +13 -18
- data/lib/r10k/action/puppetfile/check.rb +8 -18
- data/lib/r10k/action/puppetfile/install.rb +13 -27
- data/lib/r10k/action/puppetfile/purge.rb +8 -17
- data/lib/r10k/action/runner.rb +39 -3
- data/lib/r10k/cli.rb +1 -3
- data/lib/r10k/cli/deploy.rb +3 -1
- data/lib/r10k/cli/puppetfile.rb +2 -2
- data/lib/r10k/deployment.rb +8 -6
- data/lib/r10k/deployment/config.rb +18 -65
- data/lib/r10k/environment/base.rb +19 -0
- data/lib/r10k/environment/git.rb +9 -0
- data/lib/r10k/environment/svn.rb +9 -0
- data/lib/r10k/forge/module_release.rb +21 -14
- data/lib/r10k/git.rb +6 -0
- data/lib/r10k/git/alternates.rb +20 -6
- data/lib/r10k/git/cache.rb +1 -1
- data/lib/r10k/git/rugged/bare_repository.rb +5 -0
- data/lib/r10k/git/rugged/base_repository.rb +6 -20
- data/lib/r10k/git/rugged/credentials.rb +66 -0
- data/lib/r10k/git/rugged/thin_repository.rb +16 -11
- data/lib/r10k/git/rugged/working_repository.rb +15 -7
- data/lib/r10k/git/shellgit/bare_repository.rb +9 -4
- data/lib/r10k/git/shellgit/thin_repository.rb +8 -10
- data/lib/r10k/git/stateful_repository.rb +1 -1
- data/lib/r10k/initializers.rb +55 -0
- data/lib/r10k/module.rb +1 -0
- data/lib/r10k/module/base.rb +3 -2
- data/lib/r10k/module/forge.rb +14 -6
- data/lib/r10k/module/local.rb +36 -0
- data/lib/r10k/module/metadata_file.rb +2 -2
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/settings.rb +86 -0
- data/lib/r10k/settings/collection.rb +118 -0
- data/lib/r10k/settings/definition.rb +112 -0
- data/lib/r10k/settings/enum_definition.rb +22 -0
- data/lib/r10k/settings/loader.rb +96 -0
- data/lib/r10k/settings/uri_definition.rb +19 -0
- data/lib/r10k/util/subprocess/runner/windows.rb +4 -4
- data/lib/r10k/version.rb +1 -1
- data/r10k.gemspec +2 -3
- data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
- data/spec/fixtures/unit/util/subprocess/{posix/runner → runner}/no-execute.sh +0 -0
- data/spec/integration/git/rugged/thin_repository_spec.rb +2 -2
- data/spec/integration/git/rugged/working_repository_spec.rb +9 -0
- data/spec/integration/git/shellgit/thin_repository_spec.rb +2 -2
- data/spec/integration/git/stateful_repository_spec.rb +1 -1
- data/spec/r10k-mocks/mock_config.rb +10 -13
- data/spec/r10k-mocks/mock_env.rb +8 -0
- data/spec/shared-examples/deploy-actions.rb +69 -0
- data/spec/shared-examples/puppetfile-action.rb +17 -0
- data/spec/unit/action/cri_runner_spec.rb +3 -1
- data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
- data/spec/unit/action/deploy/display_spec.rb +31 -0
- data/spec/unit/action/deploy/environment_spec.rb +56 -0
- data/spec/unit/action/deploy/module_spec.rb +17 -0
- data/spec/unit/action/puppetfile/check_spec.rb +26 -0
- data/spec/unit/action/puppetfile/install_spec.rb +68 -0
- data/spec/unit/action/puppetfile/purge_spec.rb +19 -0
- data/spec/unit/action/runner_spec.rb +10 -9
- data/spec/unit/deployment/config_spec.rb +20 -44
- data/spec/unit/deployment_spec.rb +1 -1
- data/spec/unit/environment/git_spec.rb +20 -0
- data/spec/unit/environment/svn_spec.rb +20 -0
- data/spec/unit/forge/module_release_spec.rb +6 -3
- data/spec/unit/git/alternates_spec.rb +38 -12
- data/spec/unit/git/cache_spec.rb +4 -0
- data/spec/unit/git/rugged/credentials_spec.rb +74 -0
- data/spec/unit/initializers_spec.rb +68 -0
- data/spec/unit/module/base_spec.rb +2 -2
- data/spec/unit/module/forge_spec.rb +11 -3
- data/spec/unit/module/metadata_file_spec.rb +0 -1
- data/spec/unit/puppetfile_spec.rb +11 -0
- data/spec/unit/settings/collection_spec.rb +122 -0
- data/spec/unit/settings/definition_spec.rb +78 -0
- data/spec/unit/settings/enum_definition_spec.rb +20 -0
- data/spec/unit/{deployment/config → settings}/loader_spec.rb +50 -2
- data/spec/unit/settings/uri_definition_spec.rb +23 -0
- data/spec/unit/settings_spec.rb +151 -0
- data/spec/unit/util/subprocess/runner/posix_spec.rb +1 -1
- data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
- metadata +53 -90
- data/lib/r10k/deployment/config/loader.rb +0 -59
- data/lib/shared/puppet/module_tool/metadata.rb +0 -197
- data/lib/shared/puppet_forge/connection.rb +0 -64
- data/lib/shared/puppet_forge/connection/connection_failure.rb +0 -26
- data/lib/shared/puppet_forge/error.rb +0 -41
- data/lib/shared/puppet_forge/tar.rb +0 -10
- data/lib/shared/puppet_forge/tar/mini.rb +0 -81
- data/lib/shared/puppet_forge/unpacker.rb +0 -68
- data/lib/shared/puppet_forge/v3.rb +0 -13
- data/lib/shared/puppet_forge/v3/module.rb +0 -69
- data/lib/shared/puppet_forge/v3/module_release.rb +0 -85
- data/lib/shared/puppet_forge/version.rb +0 -3
- data/spec/unit/puppet/module_tool/metadata_spec.rb +0 -301
- data/spec/unit/puppet_forge/connection/connection_failure_spec.rb +0 -28
- data/spec/unit/puppet_forge/connection_spec.rb +0 -41
- data/spec/unit/puppet_forge/tar/mini_spec.rb +0 -87
- data/spec/unit/puppet_forge/tar_spec.rb +0 -9
- data/spec/unit/puppet_forge/unpacker_spec.rb +0 -59
- data/spec/unit/puppet_forge/v3/module_release_spec.rb +0 -83
- data/spec/unit/puppet_forge/v3/module_spec.rb +0 -75
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shared/puppet_forge/connection/connection_failure'
|
3
|
-
|
4
|
-
describe PuppetForge::Connection::ConnectionFailure do
|
5
|
-
|
6
|
-
subject do
|
7
|
-
Faraday.new('https://my-site.url/some-path') do |builder|
|
8
|
-
builder.use(:connection_failure)
|
9
|
-
|
10
|
-
builder.adapter :test do |stub|
|
11
|
-
stub.get('/connectfail') { raise Faraday::ConnectionFailed.new(SocketError.new("getaddrinfo: Name or service not known"), :hi) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "includes the base URL in the error message" do
|
17
|
-
expect {
|
18
|
-
subject.get('/connectfail')
|
19
|
-
}.to raise_error(Faraday::ConnectionFailed, "Unable to connect to https://my-site.url: getaddrinfo: Name or service not known")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "includes the proxy host in the error message when set" do
|
23
|
-
subject.proxy('https://some-unreachable.proxy:3128')
|
24
|
-
expect {
|
25
|
-
subject.get('/connectfail')
|
26
|
-
}.to raise_error(Faraday::ConnectionFailed, "Unable to connect to https://my-site.url (using proxy https://some-unreachable.proxy:3128): getaddrinfo: Name or service not known")
|
27
|
-
end
|
28
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'shared/puppet_forge/connection'
|
2
|
-
|
3
|
-
describe PuppetForge::Connection do
|
4
|
-
|
5
|
-
let(:extended) { Object.new.extend(described_class) }
|
6
|
-
|
7
|
-
describe 'creating a new connection' do
|
8
|
-
|
9
|
-
let(:faraday_stubs) { Faraday::Adapter::Test::Stubs.new }
|
10
|
-
|
11
|
-
subject { extended.make_connection('https://some.site/url', [:test, faraday_stubs]) }
|
12
|
-
|
13
|
-
it 'parses response bodies with a JSON content-type into a hash' do
|
14
|
-
faraday_stubs.get('/json') { [200, {'Content-Type' => 'application/json'}, '{"hello": "world"}'] }
|
15
|
-
expect(subject.get('/json').body).to eq('hello' => 'world')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns the response body as-is when the content-type is not JSON' do
|
19
|
-
faraday_stubs.get('/binary') { [200, {'Content-Type' => 'application/octet-stream'}, 'I am a big bucket of binary data'] }
|
20
|
-
expect(subject.get('/binary').body).to eq('I am a big bucket of binary data')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'raises errors when the request has an error status code' do
|
24
|
-
faraday_stubs.get('/error') { [503, {}, "The server caught fire and cannot service your request right now"] }
|
25
|
-
|
26
|
-
expect {
|
27
|
-
subject.get('/error')
|
28
|
-
}.to raise_error(Faraday::ClientError, "the server responded with status 503")
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'when an authorization value is provided' do
|
32
|
-
before(:each) do
|
33
|
-
allow(described_class).to receive(:authorization).and_return("auth-test value")
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'sets authorization header on requests' do
|
37
|
-
expect(subject.headers).to include(:authorization => "auth-test value")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'shared/puppet_forge/tar/mini'
|
2
|
-
require 'shared/puppet_forge/error'
|
3
|
-
|
4
|
-
|
5
|
-
describe PuppetForge::Tar::Mini do
|
6
|
-
let(:entry_class) do
|
7
|
-
Class.new do
|
8
|
-
attr_accessor :typeflag, :name
|
9
|
-
def initialize(name, typeflag)
|
10
|
-
@name = name
|
11
|
-
@typeflag = typeflag
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
let(:sourcefile) { '/the/module.tar.gz' }
|
16
|
-
let(:destdir) { File.expand_path '/the/dest/dir' }
|
17
|
-
let(:sourcedir) { '/the/src/dir' }
|
18
|
-
let(:destfile) { '/the/dest/file.tar.gz' }
|
19
|
-
let(:minitar) { described_class.new }
|
20
|
-
let(:tarfile_contents) { [entry_class.new('file', '0'), \
|
21
|
-
entry_class.new('symlink', '2'), \
|
22
|
-
entry_class.new('invalid', 'F')] }
|
23
|
-
|
24
|
-
it "unpacks a tar file" do
|
25
|
-
unpacks_the_entry(:file_start, 'thefile')
|
26
|
-
|
27
|
-
minitar.unpack(sourcefile, destdir)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "does not allow an absolute path" do
|
31
|
-
unpacks_the_entry(:file_start, '/thefile')
|
32
|
-
|
33
|
-
expect {
|
34
|
-
minitar.unpack(sourcefile, destdir)
|
35
|
-
}.to raise_error(PuppetForge::InvalidPathInPackageError,
|
36
|
-
"Attempt to install file into \"/thefile\" under \"#{destdir}\"")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "does not allow a file to be written outside the destination directory" do
|
40
|
-
unpacks_the_entry(:file_start, '../../thefile')
|
41
|
-
|
42
|
-
expect {
|
43
|
-
minitar.unpack(sourcefile, destdir)
|
44
|
-
}.to raise_error(PuppetForge::InvalidPathInPackageError,
|
45
|
-
"Attempt to install file into \"#{File.expand_path('/the/thefile')}\" under \"#{destdir}\"")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "does not allow a directory to be written outside the destination directory" do
|
49
|
-
unpacks_the_entry(:dir, '../../thedir')
|
50
|
-
|
51
|
-
expect {
|
52
|
-
minitar.unpack(sourcefile, destdir)
|
53
|
-
}.to raise_error(PuppetForge::InvalidPathInPackageError,
|
54
|
-
"Attempt to install file into \"#{File.expand_path('/the/thedir')}\" under \"#{destdir}\"")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "packs a tar file" do
|
58
|
-
writer = double('GzipWriter')
|
59
|
-
|
60
|
-
expect(Zlib::GzipWriter).to receive(:open).with(destfile).and_yield(writer)
|
61
|
-
expect(Archive::Tar::Minitar).to receive(:pack).with(sourcedir, writer)
|
62
|
-
|
63
|
-
minitar.pack(sourcedir, destfile)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns filenames in a tar separated into correct categories" do
|
67
|
-
reader = double('GzipReader')
|
68
|
-
|
69
|
-
expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
|
70
|
-
expect(Archive::Tar::Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
|
71
|
-
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, ['file']).and_yield(:file_start, 'thefile', nil)
|
72
|
-
|
73
|
-
file_lists = minitar.unpack(sourcefile, destdir)
|
74
|
-
|
75
|
-
expect(file_lists[:valid]).to eq(['file'])
|
76
|
-
expect(file_lists[:invalid]).to eq(['invalid'])
|
77
|
-
expect(file_lists[:symlinks]).to eq(['symlink'])
|
78
|
-
end
|
79
|
-
|
80
|
-
def unpacks_the_entry(type, name)
|
81
|
-
reader = double('GzipReader')
|
82
|
-
|
83
|
-
expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
|
84
|
-
expect(minitar).to receive(:validate_files).with(reader).and_return({:valid => [name]})
|
85
|
-
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name]).and_yield(type, name, nil)
|
86
|
-
end
|
87
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'shared/puppet_forge/unpacker'
|
4
|
-
|
5
|
-
describe PuppetForge::Unpacker do
|
6
|
-
|
7
|
-
let(:source) { Dir.mktmpdir("source") }
|
8
|
-
let(:target) { Dir.mktmpdir("unpacker") }
|
9
|
-
let(:module_name) { 'myusername-mytarball' }
|
10
|
-
let(:filename) { Dir.mktmpdir("module") + "/module.tar.gz" }
|
11
|
-
let(:working_dir) { Dir.mktmpdir("working_dir") }
|
12
|
-
let(:trash_dir) { Dir.mktmpdir("trash_dir") }
|
13
|
-
|
14
|
-
it "attempts to untar file to temporary location" do
|
15
|
-
|
16
|
-
minitar = double('PuppetForge::Tar::Mini')
|
17
|
-
|
18
|
-
expect(minitar).to receive(:unpack).with(filename, anything()) do |src, dest|
|
19
|
-
FileUtils.mkdir(File.join(dest, 'extractedmodule'))
|
20
|
-
File.open(File.join(dest, 'extractedmodule', 'metadata.json'), 'w+') do |file|
|
21
|
-
file.puts JSON.generate('name' => module_name, 'version' => '1.0.0')
|
22
|
-
end
|
23
|
-
true
|
24
|
-
end
|
25
|
-
|
26
|
-
expect(PuppetForge::Tar).to receive(:instance).and_return(minitar)
|
27
|
-
PuppetForge::Unpacker.unpack(filename, target, trash_dir)
|
28
|
-
expect(File).to be_directory(target)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns the appropriate categories of the contents of the tar file from the tar implementation" do
|
32
|
-
|
33
|
-
minitar = double('PuppetForge::Tar::Mini')
|
34
|
-
|
35
|
-
expect(minitar).to receive(:unpack).with(filename, anything()) do |src, dest|
|
36
|
-
FileUtils.mkdir(File.join(dest, 'extractedmodule'))
|
37
|
-
File.open(File.join(dest, 'extractedmodule', 'metadata.json'), 'w+') do |file|
|
38
|
-
file.puts JSON.generate('name' => module_name, 'version' => '1.0.0')
|
39
|
-
end
|
40
|
-
{ :valid => [File.join('extractedmodule', 'metadata.json')], :invalid => [], :symlinks => [] }
|
41
|
-
end
|
42
|
-
|
43
|
-
expect(PuppetForge::Tar).to receive(:instance).and_return(minitar)
|
44
|
-
file_lists = PuppetForge::Unpacker.unpack(filename, target, trash_dir)
|
45
|
-
expect(file_lists).to eq({:valid=>["extractedmodule/metadata.json"], :invalid=>[], :symlinks=>[]})
|
46
|
-
expect(File).to be_directory(target)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "attempts to set the ownership of a target dir to a source dir's owner" do
|
50
|
-
|
51
|
-
source_path = Pathname.new(source)
|
52
|
-
target_path = Pathname.new(target)
|
53
|
-
|
54
|
-
expect(FileUtils).to receive(:chown_R).with(source_path.stat.uid, source_path.stat.gid, target_path)
|
55
|
-
|
56
|
-
PuppetForge::Unpacker.harmonize_ownership(source_path, target_path)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'shared/puppet_forge/v3/module_release'
|
2
|
-
|
3
|
-
describe PuppetForge::V3::ModuleRelease do
|
4
|
-
|
5
|
-
subject { described_class.new('username-modulename', '3.1.4') }
|
6
|
-
|
7
|
-
let(:faraday_stubs) { Faraday::Adapter::Test::Stubs.new }
|
8
|
-
|
9
|
-
let(:conn) do
|
10
|
-
Faraday.new do |builder|
|
11
|
-
builder.response(:raise_error)
|
12
|
-
builder.adapter :test, faraday_stubs
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
before do
|
17
|
-
subject.conn = conn
|
18
|
-
end
|
19
|
-
|
20
|
-
it "creates a slug from the full_name and version" do
|
21
|
-
expect(subject.slug).to eq 'username-modulename-3.1.4'
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
describe '#data' do
|
26
|
-
it 'returns the body of the response' do
|
27
|
-
faraday_stubs.get('/v3/releases/username-modulename-3.1.4') { [200, {}, {'metadata' => 'yep'}] }
|
28
|
-
expect(subject.data).to eq('metadata' => 'yep')
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'raises an error if the module release does not exist' do
|
32
|
-
faraday_stubs.get('/v3/releases/username-modulename-3.1.4') { [404, {}, {'metadata' => 'yep'}] }
|
33
|
-
expect {
|
34
|
-
subject.data
|
35
|
-
}.to raise_error(PuppetForge::ModuleReleaseNotFound, /The module release username-modulename-3\.1\.4 does not exist/)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#download' do
|
40
|
-
it 'downloads the file to the provided path' do
|
41
|
-
faraday_stubs.get('/v3/files/username-modulename-3.1.4.tar.gz') { [200, {}, "I'm a file!"] }
|
42
|
-
|
43
|
-
path = Pathname.new('/some/path')
|
44
|
-
io = instance_double('IO')
|
45
|
-
|
46
|
-
expect(path).to receive(:open).with('wb').and_yield io
|
47
|
-
expect(io).to receive(:write).with("I'm a file!")
|
48
|
-
|
49
|
-
subject.download(path)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'raises an error if the module release does not exist' do
|
53
|
-
faraday_stubs.get('/v3/files/username-modulename-3.1.4.tar.gz') { [404, {}, 'not found'] }
|
54
|
-
expect {
|
55
|
-
subject.download(Pathname.new('/some/path'))
|
56
|
-
}.to raise_error(PuppetForge::ModuleReleaseNotFound, /The module release username-modulename-3\.1\.4 does not exist/)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#verify' do
|
61
|
-
let(:digest) { instance_double('Digest::MD5') }
|
62
|
-
|
63
|
-
let(:path) { Pathname.new('/some/path') }
|
64
|
-
|
65
|
-
it "returns without error when the checksum matches" do
|
66
|
-
expect(Digest::MD5).to receive(:file).with(path).and_return(digest)
|
67
|
-
expect(digest).to receive(:hexdigest).and_return('823fe0a11fc0ef23a5853e2791880c9b')
|
68
|
-
expect(subject).to receive(:data).and_return('file_md5' => '823fe0a11fc0ef23a5853e2791880c9b')
|
69
|
-
|
70
|
-
subject.verify(path)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "raises an error when the checksum doesn't match" do
|
74
|
-
expect(Digest::MD5).to receive(:file).with(path).and_return(digest)
|
75
|
-
expect(digest).to receive(:hexdigest).and_return('00000000000000000000000000000000')
|
76
|
-
expect(subject).to receive(:data).and_return('file_md5' => '823fe0a11fc0ef23a5853e2791880c9b')
|
77
|
-
|
78
|
-
expect {
|
79
|
-
subject.verify(path)
|
80
|
-
}.to raise_error(PuppetForge::V3::ModuleRelease::ChecksumMismatch, 'Expected /some/path checksum to be 823fe0a11fc0ef23a5853e2791880c9b, got 00000000000000000000000000000000')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'shared/puppet_forge/v3/module'
|
2
|
-
|
3
|
-
describe PuppetForge::V3::Module do
|
4
|
-
subject { described_class.new('authorname-modulename') }
|
5
|
-
|
6
|
-
let(:faraday_stubs) { Faraday::Adapter::Test::Stubs.new }
|
7
|
-
|
8
|
-
let(:conn) do
|
9
|
-
Faraday.new do |builder|
|
10
|
-
builder.response(:raise_error)
|
11
|
-
builder.adapter :test, faraday_stubs
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
before do
|
16
|
-
subject.conn = conn
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:releases_without_deletions) do
|
20
|
-
{"releases" => [
|
21
|
-
{"version" => "1.0.1"},
|
22
|
-
{"version" => "1.0.0"},
|
23
|
-
{"version" => "0.9.0"}
|
24
|
-
]
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:releases_with_deletions) do
|
29
|
-
{"releases" => [
|
30
|
-
{"version" => "0.4.0", "deleted_at" => "some point"},
|
31
|
-
{"version" => "0.3.0"}
|
32
|
-
]
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#release' do
|
37
|
-
it 'creates a release object for the module with the given version' do
|
38
|
-
release = subject.release('3.1.4')
|
39
|
-
expect(release.slug).to eq 'authorname-modulename-3.1.4'
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'passes along the module connection object' do
|
43
|
-
conn = Object.new
|
44
|
-
subject.conn = conn
|
45
|
-
release = subject.release('3.1.4')
|
46
|
-
expect(release.conn).to eq conn
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#versions' do
|
51
|
-
it "returns all module release versions" do
|
52
|
-
faraday_stubs.get('/v3/modules/authorname-modulename') { [200, {}, releases_without_deletions] }
|
53
|
-
expect(subject.versions).to eq ["0.9.0", "1.0.0", "1.0.1"]
|
54
|
-
end
|
55
|
-
|
56
|
-
it "ignores deleted releases" do
|
57
|
-
faraday_stubs.get('/v3/modules/authorname-modulename') { [200, {}, releases_with_deletions] }
|
58
|
-
expect(subject.versions).to eq ["0.3.0"]
|
59
|
-
end
|
60
|
-
|
61
|
-
it "raises an error when the module does not exist" do
|
62
|
-
faraday_stubs.get('/v3/modules/authorname-modulename') { [404, {}, ''] }
|
63
|
-
expect {
|
64
|
-
subject.versions
|
65
|
-
}.to raise_error(PuppetForge::ModuleNotFound, /The module authorname-modulename does not exist/)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#latest_version' do
|
70
|
-
it "returns the most recent version" do
|
71
|
-
faraday_stubs.get('/v3/modules/authorname-modulename') { [200, {}, releases_without_deletions] }
|
72
|
-
expect(subject.latest_version).to eq '1.0.1'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|