puppet 6.23.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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +5 -5
  3. data/Gemfile.lock +8 -8
  4. data/README.md +4 -4
  5. data/ext/project_data.yaml +1 -0
  6. data/lib/puppet.rb +3 -3
  7. data/lib/puppet/application/filebucket.rb +1 -0
  8. data/lib/puppet/application/resource.rb +15 -2
  9. data/lib/puppet/application/ssl.rb +1 -0
  10. data/lib/puppet/environments.rb +10 -0
  11. data/lib/puppet/face/help/action.erb +1 -0
  12. data/lib/puppet/face/help/face.erb +1 -0
  13. data/lib/puppet/face/node/clean.rb +11 -0
  14. data/lib/puppet/file_system/file_impl.rb +1 -1
  15. data/lib/puppet/file_system/windows.rb +2 -2
  16. data/lib/puppet/forge.rb +3 -3
  17. data/lib/puppet/functions/empty.rb +8 -0
  18. data/lib/puppet/functions/strftime.rb +1 -0
  19. data/lib/puppet/functions/unwrap.rb +17 -2
  20. data/lib/puppet/indirector/resource/ral.rb +6 -1
  21. data/lib/puppet/interface/documentation.rb +1 -0
  22. data/lib/puppet/module_tool/applications/installer.rb +4 -0
  23. data/lib/puppet/module_tool/errors/shared.rb +17 -0
  24. data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
  25. data/lib/puppet/provider/exec/posix.rb +16 -4
  26. data/lib/puppet/provider/package/pip.rb +15 -3
  27. data/lib/puppet/provider/parsedfile.rb +3 -0
  28. data/lib/puppet/settings.rb +30 -7
  29. data/lib/puppet/type/exec.rb +16 -3
  30. data/lib/puppet/type/file/mode.rb +6 -0
  31. data/lib/puppet/type/tidy.rb +1 -1
  32. data/lib/puppet/util/symbolic_file_mode.rb +29 -17
  33. data/lib/puppet/util/windows/sid.rb +3 -1
  34. data/lib/puppet/version.rb +1 -1
  35. data/locales/puppet.pot +154 -134
  36. data/man/man5/puppet.conf.5 +2 -2
  37. data/man/man8/puppet-agent.8 +1 -1
  38. data/man/man8/puppet-apply.8 +1 -1
  39. data/man/man8/puppet-catalog.8 +9 -9
  40. data/man/man8/puppet-config.8 +1 -1
  41. data/man/man8/puppet-describe.8 +1 -1
  42. data/man/man8/puppet-device.8 +1 -1
  43. data/man/man8/puppet-doc.8 +1 -1
  44. data/man/man8/puppet-epp.8 +1 -1
  45. data/man/man8/puppet-facts.8 +8 -8
  46. data/man/man8/puppet-filebucket.8 +1 -1
  47. data/man/man8/puppet-generate.8 +1 -1
  48. data/man/man8/puppet-help.8 +1 -1
  49. data/man/man8/puppet-key.8 +7 -7
  50. data/man/man8/puppet-lookup.8 +1 -1
  51. data/man/man8/puppet-man.8 +1 -1
  52. data/man/man8/puppet-module.8 +1 -1
  53. data/man/man8/puppet-node.8 +5 -5
  54. data/man/man8/puppet-parser.8 +1 -1
  55. data/man/man8/puppet-plugin.8 +1 -1
  56. data/man/man8/puppet-report.8 +5 -5
  57. data/man/man8/puppet-resource.8 +1 -1
  58. data/man/man8/puppet-script.8 +1 -1
  59. data/man/man8/puppet-ssl.8 +1 -1
  60. data/man/man8/puppet-status.8 +4 -4
  61. data/man/man8/puppet.8 +2 -2
  62. data/spec/fixtures/ssl/127.0.0.1-key.pem +106 -106
  63. data/spec/fixtures/ssl/127.0.0.1.pem +48 -48
  64. data/spec/fixtures/ssl/bad-basic-constraints.pem +54 -54
  65. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +51 -51
  66. data/spec/fixtures/ssl/ca.pem +52 -52
  67. data/spec/fixtures/ssl/crl.pem +25 -25
  68. data/spec/fixtures/ssl/ec-key.pem +11 -11
  69. data/spec/fixtures/ssl/ec.pem +32 -32
  70. data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
  71. data/spec/fixtures/ssl/encrypted-key.pem +107 -107
  72. data/spec/fixtures/ssl/intermediate-agent-crl.pem +25 -25
  73. data/spec/fixtures/ssl/intermediate-agent.pem +54 -54
  74. data/spec/fixtures/ssl/intermediate-crl.pem +28 -28
  75. data/spec/fixtures/ssl/intermediate.pem +51 -51
  76. data/spec/fixtures/ssl/oid-key.pem +117 -0
  77. data/spec/fixtures/ssl/oid.pem +69 -0
  78. data/spec/fixtures/ssl/pluto-key.pem +106 -106
  79. data/spec/fixtures/ssl/pluto.pem +50 -50
  80. data/spec/fixtures/ssl/request-key.pem +106 -106
  81. data/spec/fixtures/ssl/request.pem +45 -45
  82. data/spec/fixtures/ssl/revoked-key.pem +106 -106
  83. data/spec/fixtures/ssl/revoked.pem +49 -49
  84. data/spec/fixtures/ssl/signed-key.pem +106 -106
  85. data/spec/fixtures/ssl/signed.pem +47 -47
  86. data/spec/fixtures/ssl/tampered-cert.pem +49 -49
  87. data/spec/fixtures/ssl/tampered-csr.pem +45 -45
  88. data/spec/fixtures/ssl/trusted_oid_mapping.yaml +5 -0
  89. data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +106 -106
  90. data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -48
  91. data/spec/fixtures/ssl/unknown-ca-key.pem +106 -106
  92. data/spec/fixtures/ssl/unknown-ca.pem +52 -52
  93. data/spec/integration/application/filebucket_spec.rb +11 -0
  94. data/spec/integration/application/module_spec.rb +21 -0
  95. data/spec/integration/application/resource_spec.rb +35 -1
  96. data/spec/integration/application/ssl_spec.rb +20 -0
  97. data/spec/integration/environments/settings_interpolation_spec.rb +0 -4
  98. data/spec/integration/indirector/facts/facter_spec.rb +90 -36
  99. data/spec/integration/type/exec_spec.rb +70 -45
  100. data/spec/lib/puppet/test_ca.rb +5 -0
  101. data/spec/lib/puppet_spec/settings.rb +1 -0
  102. data/spec/unit/environments_spec.rb +35 -0
  103. data/spec/unit/file_system_spec.rb +6 -0
  104. data/spec/unit/functions/assert_type_spec.rb +1 -1
  105. data/spec/unit/functions/empty_spec.rb +10 -0
  106. data/spec/unit/functions/unwrap_spec.rb +8 -0
  107. data/spec/unit/functions4_spec.rb +2 -2
  108. data/spec/unit/indirector/resource/ral_spec.rb +40 -75
  109. data/spec/unit/module_tool/applications/installer_spec.rb +12 -0
  110. data/spec/unit/parser/templatewrapper_spec.rb +12 -2
  111. data/spec/unit/provider/package/pip_spec.rb +37 -0
  112. data/spec/unit/provider/parsedfile_spec.rb +10 -0
  113. data/spec/unit/settings_spec.rb +97 -56
  114. data/spec/unit/type/exec_spec.rb +76 -29
  115. data/spec/unit/type/file/source_spec.rb +4 -4
  116. data/spec/unit/type/tidy_spec.rb +7 -0
  117. data/spec/unit/util/windows/sid_spec.rb +39 -4
  118. data/tasks/generate_cert_fixtures.rake +10 -1
  119. metadata +12 -3
@@ -6,30 +6,30 @@ Certificate:
6
6
  Issuer: CN=Unknown CA
7
7
  Validity
8
8
  Not Before: Jan 1 00:00:00 1970 GMT
9
- Not After : Apr 18 18:46:23 2031 GMT
9
+ Not After : Jun 15 01:19:37 2031 GMT
10
10
  Subject: CN=Unknown CA
11
11
  Subject Public Key Info:
12
12
  Public Key Algorithm: rsaEncryption
13
13
  RSA Public-Key: (2048 bit)
14
14
  Modulus:
15
- 00:ea:16:4c:26:71:56:ac:35:bb:2b:f6:1b:18:58:
16
- 16:0f:1c:39:3f:4d:02:e4:b2:a7:8b:bd:fe:99:57:
17
- f2:a5:a8:15:01:79:0d:1d:f6:d9:12:db:d5:26:a2:
18
- f6:58:af:4b:2c:aa:46:7a:53:63:9f:1f:1a:9e:1c:
19
- fc:9a:8e:20:c8:c8:c8:db:4d:50:8d:4e:19:83:a1:
20
- 9d:54:49:26:7b:3a:e0:77:1d:7d:88:01:80:46:32:
21
- 70:47:16:08:71:de:12:94:67:fd:71:1f:41:56:93:
22
- 15:91:68:bd:05:3b:67:96:1f:7a:4d:d5:1e:b6:ac:
23
- 41:1f:f0:ce:d3:2d:96:d9:7c:ad:cd:be:b3:32:66:
24
- 18:03:2c:83:98:f1:e8:96:6f:85:0f:e1:1f:93:d0:
25
- f9:09:43:8c:b1:ea:43:26:32:a5:c6:d2:32:75:2d:
26
- ed:72:9d:bf:3a:bb:f3:4e:d0:0c:ac:ba:6b:fd:7f:
27
- 66:d8:12:40:4e:49:e7:d4:ec:70:03:71:37:cb:5e:
28
- cc:d3:4f:f3:d2:cc:e2:39:eb:79:6c:71:e5:d1:0e:
29
- 45:4c:7a:3d:6f:39:e8:16:e7:de:60:eb:01:e7:80:
30
- 4e:42:1d:1c:33:0a:eb:f9:10:2c:5c:ed:0c:58:0b:
31
- 8c:fd:6d:f4:19:49:8a:a2:81:ab:04:b0:cb:7a:61:
32
- 1f:d3
15
+ 00:b4:79:b0:16:e7:9b:22:20:17:4b:36:87:eb:38:
16
+ 03:1f:df:88:00:1b:37:40:5e:1f:1d:89:1f:3e:f4:
17
+ fa:69:90:9c:d8:68:df:c8:71:07:07:4e:01:1d:f0:
18
+ a8:9a:67:94:af:47:f2:b8:60:f5:ca:fb:bb:ac:7c:
19
+ 23:58:59:bc:95:b0:ad:b2:c7:a0:28:e1:4f:1e:c4:
20
+ ef:5f:2b:a3:4e:f2:6a:95:c8:4f:f5:af:bc:fa:36:
21
+ 10:f9:a9:62:7a:04:d5:01:cd:9b:ba:97:32:4c:99:
22
+ e5:88:fc:05:84:34:f5:4a:f2:f1:ec:04:c7:c7:63:
23
+ 28:eb:9e:ee:91:cd:95:8b:60:9e:5f:51:a1:2b:5a:
24
+ cd:02:b2:a7:52:6c:d1:8a:ab:b1:c4:52:cd:10:ce:
25
+ 9e:56:24:6c:63:84:2c:15:6c:c0:62:ea:c2:d9:04:
26
+ 88:e2:e2:0f:ff:ce:87:51:eb:77:50:83:33:1c:c7:
27
+ 88:5b:08:d4:3a:22:2f:13:a6:89:f7:4b:a0:2e:30:
28
+ c1:12:7a:bb:37:1f:aa:87:56:44:2f:5a:63:4b:b2:
29
+ 36:f6:29:5e:b8:67:52:6f:63:2a:ad:3d:c3:a5:45:
30
+ af:97:e9:85:9e:76:1e:51:9c:68:36:58:32:ad:cf:
31
+ 3e:4d:f0:92:e2:ad:d6:f0:e1:5d:af:08:ca:2a:82:
32
+ 0e:a3
33
33
  Exponent: 65537 (0x10001)
34
34
  X509v3 extensions:
35
35
  X509v3 Basic Constraints: critical
@@ -37,45 +37,45 @@ Certificate:
37
37
  X509v3 Key Usage: critical
38
38
  Certificate Sign, CRL Sign
39
39
  X509v3 Subject Key Identifier:
40
- 16:C5:98:B8:84:0B:0A:43:CB:5A:D2:E0:55:C0:64:AB:89:F8:50:FD
40
+ D0:CD:40:49:88:F6:74:BB:B4:D7:05:37:74:33:B1:C2:27:73:81:CB
41
41
  Netscape Comment:
42
42
  Puppet Server Internal Certificate
43
43
  X509v3 Authority Key Identifier:
44
- keyid:16:C5:98:B8:84:0B:0A:43:CB:5A:D2:E0:55:C0:64:AB:89:F8:50:FD
44
+ keyid:D0:CD:40:49:88:F6:74:BB:B4:D7:05:37:74:33:B1:C2:27:73:81:CB
45
45
 
46
46
  Signature Algorithm: sha256WithRSAEncryption
47
- 7d:0b:a0:2e:d4:fb:6b:29:04:d6:86:4e:89:94:4c:b5:d4:f7:
48
- 79:5a:38:95:51:9a:80:03:82:93:c8:a7:4e:93:4a:4b:41:1a:
49
- 85:f3:46:57:e1:70:50:ad:bb:4e:b9:d6:0c:00:e5:9e:4c:f7:
50
- 26:3b:88:61:27:ad:fa:39:a7:36:e1:62:87:7a:dc:7d:f9:f6:
51
- c1:ee:bc:db:f7:65:a1:b0:2a:06:ae:4b:cb:99:82:f5:8e:38:
52
- 51:ac:c9:92:33:b9:7b:50:8b:c6:72:36:d3:f2:73:7d:58:13:
53
- 00:21:4d:c6:70:9d:eb:70:58:bf:dc:34:94:7e:bc:ef:17:2d:
54
- 9d:00:bd:55:f9:48:11:c0:8f:88:ea:a8:7c:5d:fb:88:fd:8c:
55
- b4:00:1d:61:a7:4b:2a:90:ef:96:c1:28:2a:a0:95:ad:bb:b3:
56
- af:3a:d5:93:1c:54:d7:c5:5b:26:a3:24:87:df:bd:68:74:fa:
57
- e6:07:4e:13:b9:5f:54:19:ae:da:00:8c:ca:d6:ff:b7:94:6b:
58
- 4f:ff:71:ca:2b:7d:ee:7e:32:ff:03:3e:60:a4:30:d4:7d:9c:
59
- ab:97:0e:f7:80:ee:69:c0:28:a8:ec:6b:89:05:38:64:34:e8:
60
- b2:e9:f3:a1:85:e7:3d:e1:64:3c:86:e4:fd:44:4f:3b:2a:f8:
61
- d2:b4:93:22
47
+ 51:79:86:29:27:07:e5:fc:59:83:2d:15:ae:5f:c4:bc:0a:71:
48
+ 2c:71:74:20:14:ce:47:8f:cf:79:03:76:bd:df:c9:e9:7f:12:
49
+ b2:4e:5a:c5:4f:e1:0b:c3:17:44:92:37:af:10:08:75:9a:d9:
50
+ c5:0d:66:e9:24:2b:ec:00:aa:de:2f:ce:df:04:fa:49:d9:bd:
51
+ bd:5e:7b:e4:e7:1e:9e:20:d3:85:70:b4:95:b5:1d:2e:fa:0c:
52
+ b4:47:5a:38:ec:b0:bd:7e:34:5f:4d:9d:1f:81:81:8a:6c:a6:
53
+ 94:fb:f8:41:d6:a3:e4:64:3a:b7:12:4f:9e:4e:60:4a:12:a9:
54
+ d1:87:a5:a8:31:91:16:96:50:73:87:64:46:f1:f2:f9:99:80:
55
+ a2:89:e9:99:57:48:8a:56:08:d7:8d:a9:1d:69:7c:8f:73:e5:
56
+ 53:2d:28:ee:70:d7:f8:fe:41:25:3e:4c:6c:de:31:3f:9e:7d:
57
+ c4:f0:67:e9:fc:a3:02:c7:39:19:f5:6f:59:6a:ca:bb:8c:c8:
58
+ e6:01:43:ad:95:67:3f:c0:d6:35:18:b1:6e:9f:e1:ce:c7:be:
59
+ 35:f0:7b:65:e7:79:82:c3:b6:f7:48:28:98:d0:5c:3c:97:f3:
60
+ 69:b3:5e:c3:a0:c5:82:02:6f:20:d0:1b:cd:43:b0:85:7e:4f:
61
+ 71:b9:f3:8f
62
62
  -----BEGIN CERTIFICATE-----
63
63
  MIIDPTCCAiWgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDDApVbmtu
64
- b3duIENBMB4XDTcwMDEwMT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G5848=
81
81
  -----END CERTIFICATE-----
@@ -126,6 +126,17 @@ describe "puppet filebucket", unless: Puppet::Util::Platform.jruby? do
126
126
  end
127
127
  end
128
128
 
129
+ it "lists the local filebucket even if the environment doesn't exist locally" do
130
+ Puppet[:environment] = 'doesnotexist'
131
+ Puppet::FileSystem.mkpath(Puppet[:clientbucketdir])
132
+
133
+ filebucket.command_line.args = ['backup', '--local', backup_file]
134
+ expect {
135
+ result = filebucket.run
136
+ expect(result).to eq([backup_file])
137
+ }.to output(/Computing checksum on file/).to_stdout
138
+ end
139
+
129
140
  context 'diff', unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
130
141
  context 'using a remote bucket' do
131
142
  it 'outputs a diff between a local and remote file' do
@@ -65,4 +65,25 @@ describe 'puppet module', unless: Puppet::Util::Platform.jruby? do
65
65
  .and output(%r{Unable to verify the SSL certificate}).to_stderr
66
66
  end
67
67
  end
68
+
69
+ it 'prints the complete URL it tried to connect to' do
70
+ response_proc = -> (req, res) { res.status = 404 }
71
+
72
+ # create a temp cacert bundle
73
+ ssl_file = tmpfile('systemstore')
74
+ File.write(ssl_file, server.ca_cert)
75
+
76
+ Puppet::Util.withenv("SSL_CERT_FILE" => ssl_file) do
77
+ server.start_server(response_proc: response_proc) do |port|
78
+ Puppet[:module_repository] = "https://127.0.0.1:#{port}/bogus_test/puppet"
79
+
80
+ expect {
81
+ app.command_line.args = ['install', 'puppetlabs-bacula']
82
+ app.run
83
+ }.to exit_with(1)
84
+ .and output(%r{Notice: Downloading from https://127.0.0.1:#{port}}).to_stdout
85
+ .and output(%r{https://127.0.0.1:#{port}/bogus_test/puppet/v3/releases}).to_stderr
86
+ end
87
+ end
88
+ end
68
89
  end
@@ -6,7 +6,41 @@ describe "puppet resource", unless: Puppet::Util::Platform.jruby? do
6
6
 
7
7
  let(:resource) { Puppet::Application[:resource] }
8
8
 
9
- describe "when handling file and tidy types" do
9
+ context 'when given an invalid environment' do
10
+ before { Puppet[:environment] = 'badenv' }
11
+
12
+ it 'falls back to the default environment' do
13
+ Puppet[:log_level] = 'debug'
14
+
15
+ expect {
16
+ resource.run
17
+ }.to exit_with(1)
18
+ .and output(/Debug: Specified environment 'badenv' does not exist on the filesystem, defaulting to 'production'/).to_stdout
19
+ .and output(/Error: Could not run: You must specify the type to display/).to_stderr
20
+ end
21
+
22
+ it 'lists resources' do
23
+ resource.command_line.args = ['file', Puppet[:confdir]]
24
+
25
+ expect {
26
+ resource.run
27
+ }.to output(/file { '#{Puppet[:confdir]}':/).to_stdout
28
+ end
29
+
30
+ it 'lists types from the default environment' do
31
+ modulepath = File.join(Puppet[:codedir], 'modules', 'test', 'lib', 'puppet', 'type')
32
+ FileUtils.mkdir_p(modulepath)
33
+ File.write(File.join(modulepath, 'test.rb'), 'Puppet::Type.newtype(:test)')
34
+ resource.command_line.args = ['--types']
35
+
36
+ expect {
37
+ resource.run
38
+ }.to exit_with(0).and output(/test/).to_stdout
39
+ end
40
+ end
41
+
42
+
43
+ context 'when handling file and tidy types' do
10
44
  let!(:dir) { dir_containing('testdir', 'testfile' => 'contents') }
11
45
 
12
46
  it 'does not raise when generating file resources' do
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "puppet ssl", unless: Puppet::Util::Platform.jruby? do
4
+ context "print" do
5
+ it 'translates custom oids to their long name' do
6
+ basedir = File.expand_path("#{__FILE__}/../../../fixtures/ssl")
7
+ # registering custom oids changes global state, so shell out
8
+ output =
9
+ %x{puppet ssl show \
10
+ --certname oid \
11
+ --localcacert #{basedir}/ca.pem \
12
+ --hostcrl #{basedir}/crl.pem \
13
+ --hostprivkey #{basedir}/oid-key.pem \
14
+ --hostcert #{basedir}/oid.pem \
15
+ --trusted_oid_mapping_file #{basedir}/trusted_oid_mapping.yaml 2>&1
16
+ }
17
+ expect(output).to match(/Long name:/)
18
+ end
19
+ end
20
+ end
@@ -9,10 +9,6 @@ describe "interpolating $environment" do
9
9
  let(:confdir) { Puppet[:confdir] }
10
10
  let(:cmdline_args) { ['--confdir', confdir, '--vardir', Puppet[:vardir], '--hiera_config', Puppet[:hiera_config]] }
11
11
 
12
- before(:each) do
13
- FileUtils.mkdir_p(confdir)
14
- end
15
-
16
12
  shared_examples_for "a setting that does not interpolate $environment" do
17
13
 
18
14
  before(:each) do
@@ -6,6 +6,7 @@ require 'puppet/indirector/facts/facter'
6
6
  describe Puppet::Node::Facts::Facter do
7
7
  include PuppetSpec::Files
8
8
  include PuppetSpec::Compiler
9
+ include PuppetSpec::Settings
9
10
 
10
11
  before :each do
11
12
  Puppet::Node::Facts.indirection.terminus_class = :facter
@@ -66,49 +67,102 @@ describe Puppet::Node::Facts::Facter do
66
67
  end
67
68
  end
68
69
 
69
- it "adds the puppetversion fact" do
70
- allow(Facter).to receive(:reset)
71
-
72
- cat = compile_to_catalog('notify { $::puppetversion: }',
73
- Puppet::Node.indirection.find('foo'))
74
- expect(cat.resource("Notify[#{Puppet.version.to_s}]")).to be
75
- end
70
+ context "adding facts" do
71
+ it "adds the puppetversion fact" do
72
+ allow(Facter).to receive(:reset)
76
73
 
77
- it "the agent_specified_environment fact is nil when not set" do
78
- expect do
79
- compile_to_catalog('notify { $::agent_specified_environment: }',
80
- Puppet::Node.indirection.find('foo'))
81
- end.to raise_error(Puppet::PreformattedError)
82
- end
83
-
84
- it "adds the agent_specified_environment fact when set in puppet.conf" do
85
- FileUtils.mkdir_p(Puppet[:confdir])
86
- File.open(File.join(Puppet[:confdir], 'puppet.conf'), 'w') do |f|
87
- f.puts("environment=bar")
74
+ cat = compile_to_catalog('notify { $::puppetversion: }',
75
+ Puppet::Node.indirection.find('foo'))
76
+ expect(cat.resource("Notify[#{Puppet.version.to_s}]")).to be
88
77
  end
89
78
 
90
- Puppet.initialize_settings
91
- cat = compile_to_catalog('notify { $::agent_specified_environment: }',
79
+ context "when adding the agent_specified_environment fact" do
80
+ it "does not add the fact if the agent environment is not set" do
81
+ expect do
82
+ compile_to_catalog('notify { $::agent_specified_environment: }',
92
83
  Puppet::Node.indirection.find('foo'))
93
- expect(cat.resource("Notify[bar]")).to be
94
- end
84
+ end.to raise_error(Puppet::PreformattedError)
85
+ end
95
86
 
96
- it "adds the agent_specified_environment fact when set via command-line" do
97
- Puppet.initialize_settings(['--environment', 'bar'])
98
- cat = compile_to_catalog('notify { $::agent_specified_environment: }',
87
+ it "does not add the fact if the agent environment is set in sections other than agent or main" do
88
+ set_puppet_conf(Puppet[:confdir], <<~CONF)
89
+ [user]
90
+ environment=bar
91
+ CONF
92
+
93
+ Puppet.initialize_settings
94
+ expect do
95
+ compile_to_catalog('notify { $::agent_specified_environment: }',
99
96
  Puppet::Node.indirection.find('foo'))
100
- expect(cat.resource("Notify[bar]")).to be
101
- end
97
+ end.to raise_error(Puppet::PreformattedError)
98
+ end
102
99
 
103
- it "adds the agent_specified_environment fact, preferring cli, when set in puppet.conf and via command-line" do
104
- FileUtils.mkdir_p(Puppet[:confdir])
105
- File.open(File.join(Puppet[:confdir], 'puppet.conf'), 'w') do |f|
106
- f.puts("environment=bar")
107
- end
100
+ it "adds the agent_specified_environment fact when set in the agent section in puppet.conf" do
101
+ set_puppet_conf(Puppet[:confdir], <<~CONF)
102
+ [agent]
103
+ environment=bar
104
+ CONF
108
105
 
109
- Puppet.initialize_settings(['--environment', 'baz'])
110
- cat = compile_to_catalog('notify { $::agent_specified_environment: }',
111
- Puppet::Node.indirection.find('foo'))
112
- expect(cat.resource("Notify[baz]")).to be
106
+ Puppet.initialize_settings
107
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
108
+ Puppet::Node.indirection.find('foo'))
109
+ expect(cat.resource("Notify[bar]")).to be
110
+ end
111
+
112
+ it "prefers agent_specified_environment from main if set in section other than agent" do
113
+ set_puppet_conf(Puppet[:confdir], <<~CONF)
114
+ [main]
115
+ environment=baz
116
+
117
+ [user]
118
+ environment=bar
119
+ CONF
120
+
121
+ Puppet.initialize_settings
122
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
123
+ Puppet::Node.indirection.find('foo'))
124
+ expect(cat.resource("Notify[baz]")).to be
125
+ end
126
+
127
+ it "prefers agent_specified_environment from agent if set in multiple sections" do
128
+ set_puppet_conf(Puppet[:confdir], <<~CONF)
129
+ [main]
130
+ environment=baz
131
+
132
+ [agent]
133
+ environment=bar
134
+ CONF
135
+
136
+ Puppet.initialize_settings
137
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
138
+ Puppet::Node.indirection.find('foo'))
139
+ expect(cat.resource("Notify[bar]")).to be
140
+ end
141
+
142
+ it "adds the agent_specified_environment fact when set in puppet.conf" do
143
+ set_puppet_conf(Puppet[:confdir], 'environment=bar')
144
+
145
+ Puppet.initialize_settings
146
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
147
+ Puppet::Node.indirection.find('foo'))
148
+ expect(cat.resource("Notify[bar]")).to be
149
+ end
150
+
151
+ it "adds the agent_specified_environment fact when set via command-line" do
152
+ Puppet.initialize_settings(['--environment', 'bar'])
153
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
154
+ Puppet::Node.indirection.find('foo'))
155
+ expect(cat.resource("Notify[bar]")).to be
156
+ end
157
+
158
+ it "adds the agent_specified_environment fact, preferring cli, when set in puppet.conf and via command-line" do
159
+ set_puppet_conf(Puppet[:confdir], 'environment=bar')
160
+
161
+ Puppet.initialize_settings(['--environment', 'baz'])
162
+ cat = compile_to_catalog('notify { $::agent_specified_environment: }',
163
+ Puppet::Node.indirection.find('foo'))
164
+ expect(cat.resource("Notify[baz]")).to be
165
+ end
166
+ end
113
167
  end
114
168
  end
@@ -7,70 +7,95 @@ describe Puppet::Type.type(:exec), unless: Puppet::Util::Platform.jruby? do
7
7
 
8
8
  let(:catalog) { Puppet::Resource::Catalog.new }
9
9
  let(:path) { tmpfile('exec_provider') }
10
- let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
11
10
 
12
11
  before :each do
13
12
  catalog.host_config = false
14
13
  end
15
14
 
16
- it "should execute the command" do
17
- exec = described_class.new :command => command, :path => ENV['PATH']
15
+ shared_examples_for 'a valid exec resource' do
16
+ it "should execute the command" do
17
+ exec = described_class.new :command => command, :path => ENV['PATH']
18
18
 
19
- catalog.add_resource exec
20
- catalog.apply
19
+ catalog.add_resource exec
20
+ catalog.apply
21
21
 
22
- expect(File.read(path)).to eq('foo')
23
- end
22
+ expect(File.read(path)).to eq('foo')
23
+ end
24
24
 
25
- it "should not execute the command if onlyif returns non-zero" do
26
- exec = described_class.new(
27
- :command => command,
28
- :onlyif => "ruby -e 'exit 44'",
29
- :path => ENV['PATH']
30
- )
25
+ it "should not execute the command if onlyif returns non-zero" do
26
+ exec = described_class.new(
27
+ :command => command,
28
+ :onlyif => "ruby -e 'exit 44'",
29
+ :path => ENV['PATH']
30
+ )
31
31
 
32
- catalog.add_resource exec
33
- catalog.apply
32
+ catalog.add_resource exec
33
+ catalog.apply
34
34
 
35
- expect(Puppet::FileSystem.exist?(path)).to be_falsey
36
- end
35
+ expect(Puppet::FileSystem.exist?(path)).to be_falsey
36
+ end
37
37
 
38
- it "should execute the command if onlyif returns zero" do
39
- exec = described_class.new(
40
- :command => command,
41
- :onlyif => "ruby -e 'exit 0'",
42
- :path => ENV['PATH']
43
- )
38
+ it "should execute the command if onlyif returns zero" do
39
+ exec = described_class.new(
40
+ :command => command,
41
+ :onlyif => "ruby -e 'exit 0'",
42
+ :path => ENV['PATH']
43
+ )
44
44
 
45
- catalog.add_resource exec
46
- catalog.apply
45
+ catalog.add_resource exec
46
+ catalog.apply
47
47
 
48
- expect(File.read(path)).to eq('foo')
49
- end
48
+ expect(File.read(path)).to eq('foo')
49
+ end
50
+
51
+ it "should execute the command if unless returns non-zero" do
52
+ exec = described_class.new(
53
+ :command => command,
54
+ :unless => "ruby -e 'exit 45'",
55
+ :path => ENV['PATH']
56
+ )
57
+
58
+ catalog.add_resource exec
59
+ catalog.apply
60
+
61
+ expect(File.read(path)).to eq('foo')
62
+ end
50
63
 
51
- it "should execute the command if unless returns non-zero" do
52
- exec = described_class.new(
53
- :command => command,
54
- :unless => "ruby -e 'exit 45'",
55
- :path => ENV['PATH']
56
- )
64
+ it "should not execute the command if unless returns zero" do
65
+ exec = described_class.new(
66
+ :command => command,
67
+ :unless => "ruby -e 'exit 0'",
68
+ :path => ENV['PATH']
69
+ )
57
70
 
58
- catalog.add_resource exec
59
- catalog.apply
71
+ catalog.add_resource exec
72
+ catalog.apply
60
73
 
61
- expect(File.read(path)).to eq('foo')
74
+ expect(Puppet::FileSystem.exist?(path)).to be_falsey
75
+ end
62
76
  end
63
77
 
64
- it "should not execute the command if unless returns zero" do
65
- exec = described_class.new(
66
- :command => command,
67
- :unless => "ruby -e 'exit 0'",
68
- :path => ENV['PATH']
69
- )
78
+ context 'when command is a string' do
79
+ let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
80
+
81
+ it_behaves_like 'a valid exec resource'
82
+ end
83
+
84
+ context 'when command is an array' do
85
+ let(:command) { ['ruby', '-e', "File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }"] }
86
+
87
+ it_behaves_like 'a valid exec resource'
88
+
89
+ context 'when is invalid' do
90
+ let(:command) { [ "ruby -e 'puts 1'" ] }
70
91
 
71
- catalog.add_resource exec
72
- catalog.apply
92
+ it 'logs error' do
93
+ exec = described_class.new :command => command, :path => ENV['PATH']
94
+ catalog.add_resource exec
95
+ logs = catalog.apply.report.logs
73
96
 
74
- expect(Puppet::FileSystem.exist?(path)).to be_falsey
97
+ expect(logs[0].message).to eql("Could not find command 'ruby -e 'puts 1''")
98
+ end
99
+ end
75
100
  end
76
101
  end