puppet 6.21.0-x86-mingw32 → 6.24.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +1 -1
- data/Gemfile.lock +29 -23
- data/README.md +4 -4
- data/ext/osx/puppet.plist +2 -0
- data/ext/project_data.yaml +3 -2
- data/lib/puppet.rb +3 -3
- data/lib/puppet/application/agent.rb +12 -5
- data/lib/puppet/application/apply.rb +2 -1
- data/lib/puppet/application/device.rb +2 -1
- data/lib/puppet/application/filebucket.rb +1 -0
- data/lib/puppet/application/resource.rb +17 -3
- data/lib/puppet/application/script.rb +2 -1
- data/lib/puppet/application/ssl.rb +12 -0
- data/lib/puppet/configurer/downloader.rb +2 -1
- data/lib/puppet/defaults.rb +27 -5
- data/lib/puppet/environments.rb +26 -1
- data/lib/puppet/face/facts.rb +128 -30
- data/lib/puppet/face/help/action.erb +1 -0
- data/lib/puppet/face/help/face.erb +1 -0
- data/lib/puppet/face/node/clean.rb +11 -0
- data/lib/puppet/file_serving/fileset.rb +14 -2
- data/lib/puppet/file_system/file_impl.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +8 -1
- data/lib/puppet/file_system/windows.rb +4 -2
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/functions/all.rb +1 -1
- data/lib/puppet/functions/camelcase.rb +1 -1
- data/lib/puppet/functions/capitalize.rb +2 -2
- data/lib/puppet/functions/downcase.rb +2 -2
- data/lib/puppet/functions/empty.rb +8 -0
- data/lib/puppet/functions/get.rb +5 -5
- data/lib/puppet/functions/group_by.rb +13 -5
- data/lib/puppet/functions/lest.rb +1 -1
- data/lib/puppet/functions/new.rb +100 -100
- data/lib/puppet/functions/partition.rb +12 -4
- data/lib/puppet/functions/require.rb +5 -5
- data/lib/puppet/functions/sort.rb +3 -3
- data/lib/puppet/functions/strftime.rb +1 -0
- data/lib/puppet/functions/tree_each.rb +7 -9
- data/lib/puppet/functions/type.rb +4 -4
- data/lib/puppet/functions/unwrap.rb +17 -2
- data/lib/puppet/functions/upcase.rb +2 -2
- data/lib/puppet/http/resolver/server_list.rb +15 -4
- data/lib/puppet/http/service/compiler.rb +69 -0
- data/lib/puppet/http/service/file_server.rb +2 -1
- data/lib/puppet/indirector/catalog/compiler.rb +1 -0
- data/lib/puppet/indirector/facts/facter.rb +24 -3
- data/lib/puppet/indirector/file_metadata/rest.rb +1 -0
- data/lib/puppet/indirector/resource/ral.rb +6 -1
- data/lib/puppet/interface/documentation.rb +1 -0
- data/lib/puppet/module_tool/applications/installer.rb +4 -0
- data/lib/puppet/module_tool/errors/shared.rb +17 -0
- data/lib/puppet/network/formats.rb +67 -0
- data/lib/puppet/network/http/factory.rb +4 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +14 -6
- data/lib/puppet/pops/types/p_sem_ver_type.rb +8 -2
- data/lib/puppet/pops/types/p_sensitive_type.rb +10 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
- data/lib/puppet/provider/exec/posix.rb +16 -4
- data/lib/puppet/provider/package/dnfmodule.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +11 -6
- data/lib/puppet/provider/package/pip.rb +15 -3
- data/lib/puppet/provider/parsedfile.rb +3 -0
- data/lib/puppet/provider/service/systemd.rb +14 -4
- data/lib/puppet/provider/service/windows.rb +38 -0
- data/lib/puppet/provider/user/directoryservice.rb +25 -12
- data/lib/puppet/provider/user/useradd.rb +9 -2
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/settings.rb +30 -7
- data/lib/puppet/settings/environment_conf.rb +1 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
- data/lib/puppet/type/exec.rb +16 -3
- data/lib/puppet/type/file.rb +19 -1
- data/lib/puppet/type/file/mode.rb +6 -0
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/service.rb +18 -38
- data/lib/puppet/type/tidy.rb +22 -3
- data/lib/puppet/type/user.rb +38 -20
- data/lib/puppet/util/fact_dif.rb +36 -17
- data/lib/puppet/util/monkey_patches.rb +7 -0
- data/lib/puppet/util/selinux.rb +30 -4
- data/lib/puppet/util/symbolic_file_mode.rb +29 -17
- data/lib/puppet/util/windows/adsi.rb +46 -0
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/principal.rb +9 -2
- data/lib/puppet/util/windows/sid.rb +6 -2
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +360 -280
- data/man/man5/puppet.conf.5 +279 -251
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +9 -9
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +65 -7
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +7 -7
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +5 -5
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +5 -5
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +5 -1
- data/man/man8/puppet-status.8 +4 -4
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/ssl/127.0.0.1-key.pem +107 -57
- data/spec/fixtures/ssl/127.0.0.1.pem +52 -31
- data/spec/fixtures/ssl/bad-basic-constraints.pem +57 -35
- data/spec/fixtures/ssl/bad-int-basic-constraints.pem +57 -35
- data/spec/fixtures/ssl/ca.pem +57 -35
- data/spec/fixtures/ssl/crl.pem +28 -18
- data/spec/fixtures/ssl/ec-key.pem +11 -11
- data/spec/fixtures/ssl/ec.pem +33 -24
- data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
- data/spec/fixtures/ssl/encrypted-key.pem +108 -58
- data/spec/fixtures/ssl/intermediate-agent-crl.pem +28 -19
- data/spec/fixtures/ssl/intermediate-agent.pem +57 -36
- data/spec/fixtures/ssl/intermediate-crl.pem +31 -21
- data/spec/fixtures/ssl/intermediate.pem +57 -36
- data/spec/fixtures/ssl/oid-key.pem +117 -0
- data/spec/fixtures/ssl/oid.pem +69 -0
- data/spec/fixtures/ssl/pluto-key.pem +107 -57
- data/spec/fixtures/ssl/pluto.pem +52 -30
- data/spec/fixtures/ssl/request-key.pem +107 -57
- data/spec/fixtures/ssl/request.pem +47 -26
- data/spec/fixtures/ssl/revoked-key.pem +107 -57
- data/spec/fixtures/ssl/revoked.pem +52 -30
- data/spec/fixtures/ssl/signed-key.pem +107 -57
- data/spec/fixtures/ssl/signed.pem +52 -30
- data/spec/fixtures/ssl/tampered-cert.pem +52 -30
- data/spec/fixtures/ssl/tampered-csr.pem +47 -26
- data/spec/fixtures/ssl/trusted_oid_mapping.yaml +5 -0
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +107 -57
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +50 -29
- data/spec/fixtures/ssl/unknown-ca-key.pem +107 -57
- data/spec/fixtures/ssl/unknown-ca.pem +55 -33
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
- data/spec/integration/application/filebucket_spec.rb +11 -0
- data/spec/integration/application/module_spec.rb +21 -0
- data/spec/integration/application/plugin_spec.rb +1 -1
- data/spec/integration/application/resource_spec.rb +64 -0
- data/spec/integration/application/ssl_spec.rb +20 -0
- data/spec/integration/environments/settings_interpolation_spec.rb +0 -4
- data/spec/integration/http/client_spec.rb +12 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
- data/spec/integration/indirector/facts/facter_spec.rb +90 -36
- data/spec/integration/type/exec_spec.rb +70 -45
- data/spec/integration/util/windows/adsi_spec.rb +18 -0
- data/spec/integration/util/windows/principal_spec.rb +21 -0
- data/spec/integration/util/windows/registry_spec.rb +6 -0
- data/spec/lib/puppet/test_ca.rb +7 -2
- data/spec/lib/puppet_spec/settings.rb +1 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/unit/application/agent_spec.rb +7 -2
- data/spec/unit/application/facts_spec.rb +482 -3
- data/spec/unit/application/ssl_spec.rb +23 -0
- data/spec/unit/configurer/downloader_spec.rb +6 -0
- data/spec/unit/configurer_spec.rb +23 -0
- data/spec/unit/defaults_spec.rb +16 -0
- data/spec/unit/environments_spec.rb +199 -88
- data/spec/unit/face/facts_spec.rb +4 -0
- data/spec/unit/file_serving/fileset_spec.rb +60 -0
- data/spec/unit/file_system_spec.rb +15 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/empty_spec.rb +10 -0
- data/spec/unit/functions/unwrap_spec.rb +8 -0
- data/spec/unit/functions4_spec.rb +2 -2
- data/spec/unit/gettext/config_spec.rb +12 -0
- data/spec/unit/http/service/compiler_spec.rb +123 -0
- data/spec/unit/indirector/catalog/compiler_spec.rb +14 -10
- data/spec/unit/indirector/facts/facter_spec.rb +95 -0
- data/spec/unit/indirector/resource/ral_spec.rb +40 -75
- data/spec/unit/module_tool/applications/installer_spec.rb +12 -0
- data/spec/unit/network/formats_spec.rb +41 -0
- data/spec/unit/network/http/factory_spec.rb +19 -0
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +15 -1
- data/spec/unit/parser/templatewrapper_spec.rb +12 -2
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +18 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +18 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
- data/spec/unit/provider/package/nim_spec.rb +42 -0
- data/spec/unit/provider/package/pip_spec.rb +37 -0
- data/spec/unit/provider/parsedfile_spec.rb +10 -0
- data/spec/unit/provider/service/init_spec.rb +1 -0
- data/spec/unit/provider/service/openwrt_spec.rb +3 -1
- data/spec/unit/provider/service/systemd_spec.rb +53 -8
- data/spec/unit/provider/service/windows_spec.rb +202 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +67 -35
- data/spec/unit/provider/user/useradd_spec.rb +21 -6
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/settings_spec.rb +97 -56
- data/spec/unit/ssl/state_machine_spec.rb +19 -5
- data/spec/unit/transaction/additional_resource_generator_spec.rb +0 -2
- data/spec/unit/transaction_spec.rb +18 -20
- data/spec/unit/type/exec_spec.rb +76 -29
- data/spec/unit/type/file/selinux_spec.rb +3 -3
- data/spec/unit/type/file/source_spec.rb +4 -4
- data/spec/unit/type/service_spec.rb +59 -188
- data/spec/unit/type/tidy_spec.rb +24 -7
- data/spec/unit/type/user_spec.rb +45 -0
- data/spec/unit/util/selinux_spec.rb +87 -16
- data/spec/unit/util/windows/sid_spec.rb +41 -0
- data/tasks/generate_cert_fixtures.rake +12 -3
- metadata +24 -9
- data/spec/lib/matchers/include.rb +0 -27
- data/spec/lib/matchers/include_spec.rb +0 -32
@@ -1,120 +1,85 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet/indirector/resource/ral'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe Puppet::Resource::Ral do
|
5
|
+
let(:my_instance) { Puppet::Type.type(:user).new(:name => "root") }
|
6
|
+
let(:wrong_instance) { Puppet::Type.type(:user).new(:name => "bob")}
|
7
|
+
|
8
|
+
def stub_retrieve(*instances)
|
9
|
+
instances.each do |i|
|
10
|
+
allow(i).to receive(:retrieve).and_return(Puppet::Resource.new(i, nil))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
described_class.indirection.terminus_class = :ral
|
16
|
+
|
17
|
+
# make sure we don't try to retrieve current state
|
18
|
+
allow_any_instance_of(Puppet::Type.type(:user)).to receive(:retrieve).never
|
19
|
+
stub_retrieve(my_instance, wrong_instance)
|
20
|
+
end
|
21
|
+
|
5
22
|
it "disallows remote requests" do
|
6
23
|
expect(Puppet::Resource::Ral.new.allow_remote_requests?).to eq(false)
|
7
24
|
end
|
8
25
|
|
9
26
|
describe "find" do
|
10
|
-
before do
|
11
|
-
@request = double('request', :key => "user/root")
|
12
|
-
end
|
13
|
-
|
14
27
|
it "should find an existing instance" do
|
15
|
-
|
28
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([ wrong_instance, my_instance, wrong_instance ])
|
16
29
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
expect(Puppet::Type.type(:user)).to receive(:instances).and_return([ wrong_instance, my_instance, wrong_instance ])
|
21
|
-
expect(Puppet::Resource::Ral.new.find(@request)).to eq(my_resource)
|
30
|
+
actual_resource = described_class.indirection.find('user/root')
|
31
|
+
expect(actual_resource.name).to eq('User/root')
|
22
32
|
end
|
23
33
|
|
24
34
|
it "should produce Puppet::Error instead of ArgumentError" do
|
25
|
-
|
26
|
-
expect{Puppet::Resource::Ral.new.find(@bad_request)}.to raise_error(Puppet::Error)
|
35
|
+
expect{described_class.indirection.find('thiswill/causeanerror')}.to raise_error(Puppet::Error)
|
27
36
|
end
|
28
37
|
|
29
38
|
it "if there is no instance, it should create one" do
|
30
|
-
|
31
|
-
root = double("Root User")
|
32
|
-
root_resource = double("Root Resource")
|
33
|
-
|
34
|
-
expect(Puppet::Type.type(:user)).to receive(:instances).and_return([ wrong_instance, wrong_instance ])
|
35
|
-
expect(Puppet::Type.type(:user)).to receive(:new).with(hash_including(name: "root")).and_return(root)
|
36
|
-
expect(root).to receive(:to_resource).and_return(root_resource)
|
37
|
-
|
38
|
-
result = Puppet::Resource::Ral.new.find(@request)
|
39
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([wrong_instance])
|
39
40
|
|
40
|
-
expect(
|
41
|
+
expect(Puppet::Type.type(:user)).to receive(:new).with(hash_including(name: "root")).and_return(my_instance)
|
42
|
+
expect(described_class.indirection.find('user/root')).to be
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
describe "search" do
|
45
|
-
before do
|
46
|
-
@request = double('request', :key => "user/", :options => {})
|
47
|
-
end
|
48
|
-
|
49
47
|
it "should convert ral resources into regular resources" do
|
50
|
-
|
51
|
-
my_instance = double("my user", :name => "root", :to_resource => my_resource)
|
48
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([ my_instance ])
|
52
49
|
|
53
|
-
|
54
|
-
expect(
|
50
|
+
actual = described_class.indirection.search('user')
|
51
|
+
expect(actual).to contain_exactly(an_instance_of(Puppet::Resource))
|
55
52
|
end
|
56
53
|
|
57
54
|
it "should filter results by name if there's a name in the key" do
|
58
|
-
|
59
|
-
allow(my_resource).to receive(:to_resource).and_return(my_resource)
|
60
|
-
allow(my_resource).to receive(:[]).with(:name).and_return("root")
|
61
|
-
|
62
|
-
wrong_resource = double("wrong resource")
|
63
|
-
allow(wrong_resource).to receive(:to_resource).and_return(wrong_resource)
|
64
|
-
allow(wrong_resource).to receive(:[]).with(:name).and_return("bad")
|
55
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([ my_instance, wrong_instance ])
|
65
56
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@request = double('request', :key => "user/root", :options => {})
|
70
|
-
|
71
|
-
expect(Puppet::Type.type(:user)).to receive(:instances).and_return([ my_instance, wrong_instance ])
|
72
|
-
expect(Puppet::Resource::Ral.new.search(@request)).to eq([my_resource])
|
57
|
+
actual = described_class.indirection.search('user/root')
|
58
|
+
expect(actual).to contain_exactly(an_object_having_attributes(name: 'User/root'))
|
73
59
|
end
|
74
60
|
|
75
61
|
it "should filter results by query parameters" do
|
76
|
-
|
77
|
-
allow(wrong_resource).to receive(:to_resource).and_return(wrong_resource)
|
78
|
-
allow(wrong_resource).to receive(:[]).with(:name).and_return("root")
|
79
|
-
|
80
|
-
my_resource = double("wrong resource", title: "wrong resource")
|
81
|
-
allow(my_resource).to receive(:to_resource).and_return(my_resource)
|
82
|
-
allow(my_resource).to receive(:[]).with(:name).and_return("bob")
|
62
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([ my_instance, wrong_instance ])
|
83
63
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
@request = double('request', :key => "user/", :options => {:name => "bob"})
|
88
|
-
|
89
|
-
expect(Puppet::Type.type(:user)).to receive(:instances).and_return([ my_instance, wrong_instance ])
|
90
|
-
expect(Puppet::Resource::Ral.new.search(@request)).to eq([my_resource])
|
64
|
+
actual = described_class.indirection.search('user', name: 'bob')
|
65
|
+
expect(actual).to contain_exactly(an_object_having_attributes(name: 'User/bob'))
|
91
66
|
end
|
92
67
|
|
93
68
|
it "should return sorted results" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
b_resource = double("bob resource")
|
99
|
-
allow(b_resource).to receive(:to_resource).and_return(b_resource)
|
100
|
-
allow(b_resource).to receive(:title).and_return("bob")
|
101
|
-
|
102
|
-
a_instance = double("alice user", :to_resource => a_resource)
|
103
|
-
b_instance = double("bob user", :to_resource => b_resource)
|
104
|
-
|
105
|
-
@request = double('request', :key => "user/", :options => {})
|
69
|
+
a_instance = Puppet::Type.type(:user).new(:name => "alice")
|
70
|
+
b_instance = Puppet::Type.type(:user).new(:name => "bob")
|
71
|
+
stub_retrieve(a_instance, b_instance)
|
72
|
+
allow(Puppet::Type.type(:user)).to receive(:instances).and_return([ b_instance, a_instance ])
|
106
73
|
|
107
|
-
expect(
|
108
|
-
expect(Puppet::Resource::Ral.new.search(@request)).to eq([a_resource, b_resource])
|
74
|
+
expect(described_class.indirection.search('user').map(&:title)).to eq(['alice', 'bob'])
|
109
75
|
end
|
110
76
|
end
|
111
77
|
|
112
78
|
describe "save" do
|
113
79
|
it "returns a report covering the application of the given resource to the system" do
|
114
80
|
resource = Puppet::Resource.new(:notify, "the title")
|
115
|
-
ral = Puppet::Resource::Ral.new
|
116
81
|
|
117
|
-
applied_resource, report =
|
82
|
+
applied_resource, report = described_class.indirection.save(resource, nil, environment: Puppet::Node::Environment.remote(:testing))
|
118
83
|
|
119
84
|
expect(applied_resource.title).to eq("the title")
|
120
85
|
expect(report.environment).to eq("testing")
|
@@ -66,6 +66,18 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
|
|
66
66
|
graph_should_include 'pmtacceptance-stdlib', nil => v('4.1.0')
|
67
67
|
end
|
68
68
|
|
69
|
+
it 'reports a meaningful error if the name is invalid' do
|
70
|
+
app = installer('ntp', install_dir, options)
|
71
|
+
results = app.run
|
72
|
+
expect(results).to include :result => :failure
|
73
|
+
expect(results[:error][:oneline]).to eq("Could not install 'ntp', did you mean 'puppetlabs-ntp'?")
|
74
|
+
expect(results[:error][:multiline]).to eq(<<~END.chomp)
|
75
|
+
Could not install module 'ntp'
|
76
|
+
The name 'ntp' is invalid
|
77
|
+
Did you mean `puppet module install puppetlabs-ntp`?
|
78
|
+
END
|
79
|
+
end
|
80
|
+
|
69
81
|
context 'with a tarball file' do
|
70
82
|
let(:module) { fixtures('stdlib.tgz') }
|
71
83
|
|
@@ -534,4 +534,45 @@ EOT
|
|
534
534
|
end
|
535
535
|
end
|
536
536
|
end
|
537
|
+
|
538
|
+
describe ":flat format" do
|
539
|
+
let(:flat) { Puppet::Network::FormatHandler.format(:flat) }
|
540
|
+
|
541
|
+
it "should include a flat format" do
|
542
|
+
expect(flat).to be_an_instance_of Puppet::Network::Format
|
543
|
+
end
|
544
|
+
|
545
|
+
[:intern, :intern_multiple].each do |method|
|
546
|
+
it "should not implement #{method}" do
|
547
|
+
expect { flat.send(method, String, 'blah') }.to raise_error NotImplementedError
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
context "when rendering arrays" do
|
552
|
+
{
|
553
|
+
[] => "",
|
554
|
+
[1, 2] => "0=1\n1=2\n",
|
555
|
+
["one"] => "0=one\n",
|
556
|
+
[{"one" => 1}, {"two" => 2}] => "0.one=1\n1.two=2\n",
|
557
|
+
[['something', 'for'], ['the', 'test']] => "0=[\"something\", \"for\"]\n1=[\"the\", \"test\"]\n"
|
558
|
+
}.each_pair do |input, output|
|
559
|
+
it "should render #{input.inspect} as one item per line" do
|
560
|
+
expect(flat.render(input)).to eq(output)
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
context "when rendering hashes" do
|
566
|
+
{
|
567
|
+
{} => "",
|
568
|
+
{1 => 2} => "1=2\n",
|
569
|
+
{"one" => "two"} => "one=two\n",
|
570
|
+
{[1,2] => 3, [2,3] => 5, [3,4] => 7} => "[1, 2]=3\n[2, 3]=5\n[3, 4]=7\n",
|
571
|
+
}.each_pair do |input, output|
|
572
|
+
it "should render #{input.inspect}" do
|
573
|
+
expect(flat.render(input)).to eq(output)
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
end
|
537
578
|
end
|
@@ -144,4 +144,23 @@ describe Puppet::Network::HTTP::Factory do
|
|
144
144
|
expect(conn.local_host).to eq('127.0.0.1')
|
145
145
|
end
|
146
146
|
end
|
147
|
+
|
148
|
+
context 'tls' do
|
149
|
+
it "sets the minimum version to TLS 1.0", if: RUBY_VERSION.to_f >= 2.5 do
|
150
|
+
conn = create_connection(site)
|
151
|
+
expect(conn.min_version).to eq(OpenSSL::SSL::TLS1_VERSION)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "defaults to ciphersuites providing 128 bits of security or greater" do
|
155
|
+
conn = create_connection(site)
|
156
|
+
expect(conn.ciphers).to eq("ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "can be restricted to TLSv1.3 ciphers" do
|
160
|
+
tls13_ciphers = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"
|
161
|
+
Puppet[:ciphers] = tls13_ciphers
|
162
|
+
conn = create_connection(site)
|
163
|
+
expect(conn.ciphers).to eq(tls13_ciphers)
|
164
|
+
end
|
165
|
+
end
|
147
166
|
end
|
@@ -61,12 +61,26 @@ describe "the fqdn_rand function" do
|
|
61
61
|
expect(fqdn_rand(5000, :extra_identifier => ['expensive job 33'])).to eql(2389)
|
62
62
|
end
|
63
63
|
|
64
|
+
it "returns the same value if only host differs by case" do
|
65
|
+
val1 = fqdn_rand(1000000000, :host => "host.example.com", :extra_identifier => [nil, true])
|
66
|
+
val2 = fqdn_rand(1000000000, :host => "HOST.example.com", :extra_identifier => [nil, true])
|
67
|
+
|
68
|
+
expect(val1).to eql(val2)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns the same value if only host differs by case and an initial seed is given" do
|
72
|
+
val1 = fqdn_rand(1000000000, :host => "host.example.com", :extra_identifier => ['a seed', true])
|
73
|
+
val2 = fqdn_rand(1000000000, :host => "HOST.example.com", :extra_identifier => ['a seed', true])
|
74
|
+
|
75
|
+
expect(val1).to eql(val2)
|
76
|
+
end
|
77
|
+
|
64
78
|
def fqdn_rand(max, args = {})
|
65
79
|
host = args[:host] || '127.0.0.1'
|
66
80
|
extra = args[:extra_identifier] || []
|
67
81
|
|
68
82
|
scope = create_test_scope_for_node('localhost')
|
69
|
-
|
83
|
+
scope.compiler.topscope['fqdn'] = host.freeze
|
70
84
|
|
71
85
|
scope.function_fqdn_rand([max] + extra)
|
72
86
|
end
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
require 'puppet/parser/templatewrapper'
|
3
3
|
|
4
4
|
describe Puppet::Parser::TemplateWrapper do
|
5
|
+
include PuppetSpec::Files
|
6
|
+
|
5
7
|
let(:known_resource_types) { Puppet::Resource::TypeCollection.new("env") }
|
6
8
|
let(:scope) do
|
7
9
|
compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
|
@@ -41,6 +43,13 @@ describe Puppet::Parser::TemplateWrapper do
|
|
41
43
|
expect(tw.result).to eq(full_file_name)
|
42
44
|
end
|
43
45
|
|
46
|
+
it "ignores a leading BOM" do
|
47
|
+
full_file_name = given_a_template_file("bom_template", "\uFEFF<%= file %>")
|
48
|
+
|
49
|
+
tw.file = "bom_template"
|
50
|
+
expect(tw.result).to eq(full_file_name)
|
51
|
+
end
|
52
|
+
|
44
53
|
it "evaluates a given string as a template" do
|
45
54
|
expect(tw.result("template contents")).to eql("template contents")
|
46
55
|
end
|
@@ -90,11 +99,12 @@ describe Puppet::Parser::TemplateWrapper do
|
|
90
99
|
end
|
91
100
|
|
92
101
|
def given_a_template_file(name, contents)
|
93
|
-
full_name = "
|
102
|
+
full_name = tmpfile("template_#{name}")
|
103
|
+
File.binwrite(full_name, contents)
|
104
|
+
|
94
105
|
allow(Puppet::Parser::Files).to receive(:find_template).
|
95
106
|
with(name, anything()).
|
96
107
|
and_return(full_name)
|
97
|
-
allow(Puppet::FileSystem).to receive(:read_preserve_line_endings).with(full_name).and_return(contents)
|
98
108
|
|
99
109
|
full_name
|
100
110
|
end
|
@@ -125,6 +125,24 @@ describe 'Semantic Versions' do
|
|
125
125
|
expect(eval_and_collect_notices(code)).to eql(['true', 'false'])
|
126
126
|
end
|
127
127
|
|
128
|
+
it 'can be compared to another instance created from arguments' do
|
129
|
+
code = <<-CODE
|
130
|
+
$x = SemVer('1.2.3-rc4+5')
|
131
|
+
$y = SemVer(1, 2, 3, 'rc4', '5')
|
132
|
+
notice($x == $y)
|
133
|
+
CODE
|
134
|
+
expect(eval_and_collect_notices(code)).to eql(['true'])
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'can be compared to another instance created from a hash' do
|
138
|
+
code = <<-CODE
|
139
|
+
$x = SemVer('1.2.3-rc4+5')
|
140
|
+
$y = SemVer(major => 1, minor => 2, patch => 3, prerelease => 'rc4', build => '5')
|
141
|
+
notice($x == $y)
|
142
|
+
CODE
|
143
|
+
expect(eval_and_collect_notices(code)).to eql(['true'])
|
144
|
+
end
|
145
|
+
|
128
146
|
it 'can be compared to another instance for magnitude' do
|
129
147
|
code = <<-CODE
|
130
148
|
$x = SemVer('1.1.1')
|
@@ -113,6 +113,24 @@ describe 'Sensitive Type' do
|
|
113
113
|
expect(eval_and_collect_notices(code)).to eq(['Sensitive[Integer] != Sensitive[String]'])
|
114
114
|
end
|
115
115
|
|
116
|
+
it 'equals another instance with the same value' do
|
117
|
+
code =<<-CODE
|
118
|
+
$i = Sensitive('secret')
|
119
|
+
$o = Sensitive('secret')
|
120
|
+
notice($i == $o)
|
121
|
+
CODE
|
122
|
+
expect(eval_and_collect_notices(code)).to eq(['true'])
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'has equal hash keys for same values' do
|
126
|
+
code =<<-CODE
|
127
|
+
$i = Sensitive('secret')
|
128
|
+
$o = Sensitive('secret')
|
129
|
+
notice({$i => 1} == {$o => 1})
|
130
|
+
CODE
|
131
|
+
expect(eval_and_collect_notices(code)).to eq(['true'])
|
132
|
+
end
|
133
|
+
|
116
134
|
it 'can be created from another sensitive instance ' do
|
117
135
|
code =<<-CODE
|
118
136
|
$o = Sensitive("hunter2")
|
@@ -123,7 +123,7 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
|
|
123
123
|
provider.install
|
124
124
|
end
|
125
125
|
|
126
|
-
it "should just enable the module if it has no default profile" do
|
126
|
+
it "should just enable the module if it has no default profile(missing groups or modules)" do
|
127
127
|
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
|
128
128
|
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
|
129
129
|
resource[:ensure] = :present
|
@@ -132,6 +132,15 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
|
|
132
132
|
provider.install
|
133
133
|
end
|
134
134
|
|
135
|
+
it "should just enable the module if it has no default profile(broken groups or modules)" do
|
136
|
+
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}")
|
137
|
+
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
|
138
|
+
resource[:ensure] = :present
|
139
|
+
expect(provider).to receive(:execute).with(array_including('install')).ordered
|
140
|
+
expect(provider).to receive(:execute).with(array_including('enable')).ordered
|
141
|
+
provider.install
|
142
|
+
end
|
143
|
+
|
135
144
|
it "should just enable the module if enable_only = true" do
|
136
145
|
resource[:ensure] = :present
|
137
146
|
resource[:enable_only] = true
|
@@ -191,6 +191,27 @@ OUTPUT
|
|
191
191
|
expect(versions[version]).to eq(:rpm)
|
192
192
|
end
|
193
193
|
end
|
194
|
+
|
195
|
+
it "should be able to parse RPM package listings with letters in version" do
|
196
|
+
showres_output = <<END
|
197
|
+
cairo ALL @@R:cairo _all_filesets
|
198
|
+
@@R:cairo-1.14.6-2waixX11 1.14.6-2waixX11
|
199
|
+
END
|
200
|
+
packages = subject.send(:parse_showres_output, showres_output)
|
201
|
+
expect(Set.new(packages.keys)).to eq(Set.new(['cairo']))
|
202
|
+
versions = packages['cairo']
|
203
|
+
expect(versions.has_key?('1.14.6-2waixX11')).to eq(true)
|
204
|
+
expect(versions['1.14.6-2waixX11']).to eq(:rpm)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should raise error when parsing invalid RPM package listings" do
|
208
|
+
showres_output = <<END
|
209
|
+
cairo ALL @@R:cairo _all_filesets
|
210
|
+
@@R:cairo-invalid_version invalid_version
|
211
|
+
END
|
212
|
+
expect{ subject.send(:parse_showres_output, showres_output) }.to raise_error(Puppet::Error,
|
213
|
+
/Unable to parse output from nimclient showres: package string does not match expected rpm package string format/)
|
214
|
+
end
|
194
215
|
end
|
195
216
|
|
196
217
|
context "#determine_latest_version" do
|
@@ -220,6 +241,27 @@ END
|
|
220
241
|
it "should return :installp for installp/bff packages" do
|
221
242
|
expect(subject.send(:determine_package_type, bff_showres_output, 'mypackage.foo', '1.2.3.4')).to eq(:installp)
|
222
243
|
end
|
244
|
+
|
245
|
+
it "should return :installp for security updates" do
|
246
|
+
nimclient_showres_output = <<END
|
247
|
+
bos.net ALL @@S:bos.net _all_filesets
|
248
|
+
+ 7.2.0.1 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.1
|
249
|
+
+ 7.2.0.2 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.2
|
250
|
+
|
251
|
+
END
|
252
|
+
expect(subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2')).to eq(:installp)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should raise error when invalid header format is given" do
|
256
|
+
nimclient_showres_output = <<END
|
257
|
+
bos.net ALL @@INVALID_TYPE:bos.net _all_filesets
|
258
|
+
+ 7.2.0.1 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.1
|
259
|
+
+ 7.2.0.2 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.2
|
260
|
+
|
261
|
+
END
|
262
|
+
expect{ subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2') }.to raise_error(
|
263
|
+
Puppet::Error, /Unable to parse output from nimclient showres: line does not match expected package header format/)
|
264
|
+
end
|
223
265
|
end
|
224
266
|
end
|
225
267
|
end
|