puppet 4.9.2 → 4.9.3

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.

@@ -14,42 +14,51 @@ describe "The lookup function" do
14
14
  let(:code_dir_files) { {} }
15
15
  let(:code_dir) { tmpdir('code') }
16
16
  let(:ruby_dir) { tmpdir('ruby') }
17
- let(:environment_files) do
17
+ let(:env_modules) { {} }
18
+ let(:env_hiera_yaml) do
19
+ <<-YAML.unindent
20
+ ---
21
+ version: 5
22
+ hierarchy:
23
+ - name: "Common"
24
+ data_hash: yaml_data
25
+ path: "common.yaml"
26
+ YAML
27
+ end
28
+
29
+ let(:env_data) do
18
30
  {
19
- env_name => {
20
- 'modules' => {},
21
- 'hiera.yaml' => <<-YAML.unindent,
31
+ 'common.yaml' => <<-YAML.unindent
22
32
  ---
23
- version: 5
24
- hierarchy:
25
- - name: "Common"
26
- data_hash: yaml_data
27
- path: "common.yaml"
28
- YAML
29
- 'data' => {
30
- 'common.yaml' => <<-YAML.unindent
31
- ---
32
- a: value a (from environment)
33
- c:
34
- c_b: value c_b (from environment)
35
- mod_a::a: value mod_a::a (from environment)
36
- mod_a::hash_a:
37
- a: value mod_a::hash_a.a (from environment)
33
+ a: value a (from environment)
34
+ c:
35
+ c_b: value c_b (from environment)
36
+ mod_a::a: value mod_a::a (from environment)
37
+ mod_a::hash_a:
38
+ a: value mod_a::hash_a.a (from environment)
39
+ mod_a::hash_b:
40
+ a: value mod_a::hash_b.a (from environment)
41
+ hash_b:
42
+ hash_ba:
43
+ bab: value hash_b.hash_ba.bab (from environment)
44
+ hash_c:
45
+ hash_ca:
46
+ caa: value hash_c.hash_ca.caa (from environment)
47
+ lookup_options:
38
48
  mod_a::hash_b:
39
- a: value mod_a::hash_b.a (from environment)
40
- hash_b:
41
- hash_ba:
42
- bab: value hash_b.hash_ba.bab (from environment)
49
+ merge: hash
43
50
  hash_c:
44
- hash_ca:
45
- caa: value hash_c.hash_ca.caa (from environment)
46
- lookup_options:
47
- mod_a::hash_b:
48
- merge: hash
49
- hash_c:
50
- merge: hash
51
- YAML
52
- }
51
+ merge: hash
52
+ YAML
53
+ }
54
+ end
55
+
56
+ let(:environment_files) do
57
+ {
58
+ env_name => {
59
+ 'modules' => env_modules,
60
+ 'hiera.yaml' => env_hiera_yaml,
61
+ 'data' => env_data
53
62
  }
54
63
  }
55
64
  end
@@ -168,7 +177,7 @@ describe "The lookup function" do
168
177
  compiler.compile
169
178
  end
170
179
  end
171
- rescue Puppet::DataBinding::LookupError => e
180
+ rescue RuntimeError => e
172
181
  invocation_with_explain.report_text { e.message }
173
182
  end
174
183
  else
@@ -207,13 +216,7 @@ describe "The lookup function" do
207
216
  let(:environment_files) do
208
217
  {
209
218
  env_name => {
210
- 'modules' => {},
211
- 'data' => {
212
- 'common.yaml' => <<-YAML.unindent
213
- ---
214
- a: value a
215
- YAML
216
- }
219
+ 'data' => env_data
217
220
  }
218
221
  }
219
222
  end
@@ -223,36 +226,43 @@ describe "The lookup function" do
223
226
  end
224
227
 
225
228
  context "but an environment.conf with 'environment_data_provider=hiera'" do
226
- let(:environment_files_1) do
227
- DeepMerge.deep_merge!(environment_files, 'environment.conf' => "environment_data_provider=hiera\n")
228
- end
229
-
230
- let(:populated_env_dir) do
231
- dir_contained_in(env_dir, DeepMerge.deep_merge!(environment_files, env_name => environment_files_1))
232
- env_dir
229
+ let(:environment_files) do
230
+ {
231
+ env_name => {
232
+ 'environment.conf' => "environment_data_provider=hiera\n",
233
+ 'data' => env_data
234
+ }
235
+ }
233
236
  end
234
237
 
235
238
  it 'finds data in the environment and reports deprecation warning for environment.conf' do
236
- expect(lookup('a')).to eql('value a')
239
+ expect(lookup('a')).to eql('value a (from environment)')
237
240
  expect(warnings).to include(/Defining environment_data_provider='hiera' in environment.conf is deprecated. A 'hiera.yaml' file should be used instead/)
238
241
  end
239
242
 
240
243
  context 'and a hiera.yaml file' do
241
- let(:environment_files_2) { DeepMerge.deep_merge!(environment_files_1,'hiera.yaml' => <<-YAML.unindent) }
242
- ---
243
- version: 4
244
- hierarchy:
245
- - name: common
246
- backend: yaml
247
- YAML
244
+ let(:env_hiera_yaml) do
245
+ <<-YAML.unindent
246
+ ---
247
+ version: 4
248
+ hierarchy:
249
+ - name: common
250
+ backend: yaml
251
+ YAML
252
+ end
248
253
 
249
- let(:populated_env_dir) do
250
- dir_contained_in(env_dir, DeepMerge.deep_merge!(environment_files, env_name => environment_files_2))
251
- env_dir
254
+ let(:environment_files) do
255
+ {
256
+ env_name => {
257
+ 'hiera.yaml' => env_hiera_yaml,
258
+ 'environment.conf' => "environment_data_provider=hiera\n",
259
+ 'data' => env_data
260
+ }
261
+ }
252
262
  end
253
263
 
254
264
  it 'finds data in the environment and reports deprecation warnings for both environment.conf and hiera.yaml' do
255
- expect(lookup('a')).to eql('value a')
265
+ expect(lookup('a')).to eql('value a (from environment)')
256
266
  expect(warnings).to include(/Defining environment_data_provider='hiera' in environment.conf is deprecated/)
257
267
  expect(warnings).to include(/Use of 'hiera.yaml' version 4 is deprecated. It should be converted to version 5/)
258
268
  end
@@ -284,17 +294,21 @@ describe "The lookup function" do
284
294
  end
285
295
 
286
296
  context 'that has interpolated paths configured' do
297
+ let(:env_hiera_yaml) do
298
+ <<-YAML.unindent
299
+ ---
300
+ version: 5
301
+ hierarchy:
302
+ - name: "Varying"
303
+ data_hash: yaml_data
304
+ path: "x%{::var.sub}.yaml"
305
+ YAML
306
+ end
307
+
287
308
  let(:environment_files) do
288
309
  {
289
310
  env_name => {
290
- 'hiera.yaml' => <<-YAML.unindent,
291
- ---
292
- version: 5
293
- hierarchy:
294
- - name: "Varying"
295
- data_hash: yaml_data
296
- path: "x%{::var.sub}.yaml"
297
- YAML
311
+ 'hiera.yaml' => env_hiera_yaml,
298
312
  'modules' => {},
299
313
  'data' => {
300
314
  'x.yaml' => <<-YAML.unindent,
@@ -513,20 +527,27 @@ describe "The lookup function" do
513
527
  }
514
528
  end
515
529
 
516
- let(:environment_files) do
530
+ let(:env_modules) do
517
531
  {
518
- env_name => {
519
- 'hiera.yaml' => <<-YAML.unindent,
520
- ---
521
- version: 5
522
- hierarchy:
523
- - name: X
524
- paths:
525
- - first.yaml
526
- - second.yaml
527
- YAML
528
- 'data' => {
529
- 'first.yaml' => <<-YAML.unindent,
532
+ 'mod' => mod_base
533
+ }
534
+ end
535
+
536
+ let(:env_hiera_yaml) do
537
+ <<-YAML.unindent
538
+ ---
539
+ version: 5
540
+ hierarchy:
541
+ - name: X
542
+ paths:
543
+ - first.yaml
544
+ - second.yaml
545
+ YAML
546
+ end
547
+
548
+ let(:env_data) do
549
+ {
550
+ 'first.yaml' => <<-YAML.unindent,
530
551
  a:
531
552
  aa:
532
553
  aaa: a.aa.aaa
@@ -560,8 +581,8 @@ describe "The lookup function" do
560
581
  merge: first
561
582
  '^mod::ha.*_b':
562
583
  merge: hash
563
- YAML
564
- 'second.yaml' => <<-YAML.unindent,
584
+ YAML
585
+ 'second.yaml' => <<-YAML.unindent,
565
586
  a:
566
587
  aa:
567
588
  aab: a.aa.aab
@@ -573,12 +594,7 @@ describe "The lookup function" do
573
594
  c:
574
595
  ca:
575
596
  cab: c.ca.cab
576
- YAML
577
- },
578
- 'modules' => {
579
- 'mod' => mod_base
580
- }
581
- }
597
+ YAML
582
598
  }
583
599
  end
584
600
 
@@ -662,16 +678,85 @@ describe "The lookup function" do
662
678
  end
663
679
  end
664
680
 
681
+ context 'and an environment Hiera v5 configuration using globs' do
682
+ let(:env_hiera_yaml) do
683
+ <<-YAML.unindent
684
+ ---
685
+ version: 5
686
+ hierarchy:
687
+ - name: Globs
688
+ globs:
689
+ - "globs/*.yaml"
690
+ - "globs_%{domain}/*.yaml"
691
+ YAML
692
+ end
693
+
694
+ let(:env_data) do
695
+ {
696
+ 'globs' => {
697
+ 'a.yaml' => <<-YAML.unindent,
698
+ glob_a: value glob_a
699
+ YAML
700
+ 'b.yaml' => <<-YAML.unindent
701
+ glob_b:
702
+ a: value glob_b.a
703
+ b: value glob_b.b
704
+ YAML
705
+ },
706
+ 'globs_example.com' => {
707
+ 'a.yaml' => <<-YAML.unindent,
708
+ glob_c: value glob_a
709
+ YAML
710
+ 'b.yaml' => <<-YAML.unindent
711
+ glob_b:
712
+ c: value glob_b.c
713
+ d: value glob_b.d
714
+ YAML
715
+
716
+ }
717
+ }
718
+ end
719
+
720
+ let(:environment_files) do
721
+ {
722
+ env_name => {
723
+ 'hiera.yaml' => env_hiera_yaml,
724
+ 'data' => env_data
725
+ }
726
+ }
727
+ end
728
+
729
+ it 'finds environment data using globs' do
730
+ expect(lookup('glob_a')).to eql('value glob_a')
731
+ expect(warnings).to be_empty
732
+ end
733
+
734
+ it 'performs merges between interpolated and globbed paths' do
735
+ expect(lookup('glob_b', 'merge' => 'hash')).to eql(
736
+ {
737
+ 'a' => 'value glob_b.a',
738
+ 'b' => 'value glob_b.b',
739
+ 'c' => 'value glob_b.c',
740
+ 'd' => 'value glob_b.d'
741
+ })
742
+ expect(warnings).to be_empty
743
+ end
744
+ end
745
+
665
746
  context 'and an environment Hiera v3 configuration' do
747
+ let(:env_hiera_yaml) do
748
+ <<-YAML.unindent
749
+ ---
750
+ :backends: yaml
751
+ :yaml:
752
+ :datadir: #{env_dir}/#{env_name}/hieradata
753
+ YAML
754
+ end
755
+
666
756
  let(:environment_files) do
667
757
  {
668
758
  env_name => {
669
- 'hiera.yaml' => <<-YAML.unindent,
670
- ---
671
- :backends: yaml
672
- :yaml:
673
- :datadir: #{env_dir}/#{env_name}/hieradata
674
- YAML
759
+ 'hiera.yaml' => env_hiera_yaml,
675
760
  'hieradata' => {
676
761
  'common.yaml' => <<-YAML.unindent,
677
762
  g: Value g
@@ -1194,7 +1279,7 @@ describe "The lookup function" do
1194
1279
  YAML
1195
1280
  end
1196
1281
 
1197
- it 'finds data in the environment and reports no deprecation warnings' do
1282
+ it 'finds global data and reports no deprecation warnings' do
1198
1283
  expect(lookup('a')).to eql('value a (from global)')
1199
1284
  expect(warnings).to be_empty
1200
1285
  end
@@ -1793,5 +1878,208 @@ describe "The lookup function" do
1793
1878
  end
1794
1879
  end
1795
1880
  end
1881
+
1882
+ context 'and an eyaml lookup_key function' do
1883
+ let(:private_key_name) { 'private_key.pkcs7.pem' }
1884
+ let(:public_key_name) { 'public_key.pkcs7.pem' }
1885
+
1886
+ let(:private_key) do
1887
+ <<-PKCS7.unindent
1888
+ -----BEGIN RSA PRIVATE KEY-----
1889
+ MIIEogIBAAKCAQEAwHB3GvImq59em4LV9DMfP0Zjs21eW3Jd5I9fuY0jLJhIkH6f
1890
+ CR7tyOpYV6xUj+TF8giq9WLxZI7sourMJMWjEWhVjgUr5lqp1RLv4lwfDv3Wk4XC
1891
+ 2LUuqj1IAErUXKeRz8i3lUSZW1Pf4CaMpnIiPdWbz6f0KkaJSFi9bqexONBx4fKQ
1892
+ NlgZwm2/aYjjrYng788I0QhWDKUqsQOi5mZKlHNRsDlk7J3Afhsx/jTLrCX/G8+2
1893
+ tPtLsHyRN39kluM5vYHbKXDsCG/a88Z2yUE2+r4Clp0FUKffiEDBPm0/H0sQ4Q1o
1894
+ EfQFDQRKaIkhpsm0nOnLYTy3/xJc5uqDNkLiawIDAQABAoIBAE98pNXOe8ab93oI
1895
+ mtNZYmjCbGAqprTjEoFb71A3SfYbmK2Gf65GxjUdBwx/tBYTiuekSOk+yzKcDoZk
1896
+ sZnmwKpqDByzaiSmAkxunANFxdZtZvpcX9UfUX0j/t+QCROUa5gF8j6HrUiZ5nkx
1897
+ sxr1PcuItekaGLJ1nDLz5JsWTQ+H4M+GXQw7/t96x8v8g9el4exTiAHGk6Fv16kD
1898
+ 017T02M9qTTmV3Ab/enDIBmKVD42Ta36K/wc4l1aoUQNiRbIGVh96Cgd1CFXLF3x
1899
+ CsaNbYT4SmRXaYqoj6MKq+QFEGxadFmJy48NoSd4joirIn2lUjHxJebw3lLbNLDR
1900
+ uvQnQ2ECgYEA/nD94wEMr6078uMv6nKxPpNGq7fihwSKf0G/PQDqrRmjUCewuW+k
1901
+ /iXMe1Y/y0PjFeNlSbUsUvKQ5xF7F/1AnpuPHIrn3cjGVLb71W+zen1m8SnhsW/f
1902
+ 7dPgtcb4SCvfhmLgoov+P34YcNfGi6qgPUu6319IqoB3BIi7PvfEomkCgYEAwZ4+
1903
+ V0bMjFdDn2hnYzjTNcF2aUQ1jPvtuETizGwyCbbMLl9522lrjC2DrH41vvqX35ct
1904
+ CBJkhQFbtHM8Gnmozv0vxhI2jP+u14mzfePZsaXuYrEgWRj+BCsYUHodXryxnEWj
1905
+ yVrTNskab1B5jFm2SCJDmKcycBOYpRBLCMx6W7MCgYBA99z7/6KboOIzzKrJdGup
1906
+ jLV410UyMIikoccQ7pD9jhRTPS80yjsY4dHqlEVJw5XSWvPb9DTTITi6p44EvBep
1907
+ 6BKMuTMnQELUEr0O7KypVCfa4FTOl8BX28f+4kU3OGykxc6R8qkC0VGwTohV1UWB
1908
+ ITsgGhZV4uOA9uDI3T8KMQKBgEnQY2HwmuDSD/TA39GDA3qV8+ez2lqSXRGIKZLX
1909
+ mMf9SaBQQ+uzKA4799wWDbVuYeIbB07xfCL83pJP8FUDlqi6+7Celu9wNp7zX1ua
1910
+ Nw8z/ErhzjxJe+Xo7A8aTwIkG+5A2m1UU/up9YsEeiJYvVaIwY58B42U2vfq20BS
1911
+ fD9jAoGAX2MscBzIsmN+U9R0ptL4SXcPiVnOl8mqvQWr1B4OLgxX7ghht5Fs956W
1912
+ bHipxOWMFCPJA/AhNB8q1DvYiD1viZbIALSCJVUkzs4AEFIjiPsCBKxerl7jF6Xp
1913
+ 1WYSaCmfvoCVEpFNt8cKp4Gq+zEBYAV4Q6TkcD2lDtEW49MuN8A=
1914
+ -----END RSA PRIVATE KEY-----
1915
+ PKCS7
1916
+ end
1917
+
1918
+ let(:public_key) do
1919
+ <<-PKCS7.unindent
1920
+ -----BEGIN CERTIFICATE-----
1921
+ MIIC2TCCAcGgAwIBAgIBATANBgkqhkiG9w0BAQUFADAAMCAXDTE3MDExMzA5MTY1
1922
+ MloYDzIwNjcwMTAxMDkxNjUyWjAAMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
1923
+ CgKCAQEAwHB3GvImq59em4LV9DMfP0Zjs21eW3Jd5I9fuY0jLJhIkH6fCR7tyOpY
1924
+ V6xUj+TF8giq9WLxZI7sourMJMWjEWhVjgUr5lqp1RLv4lwfDv3Wk4XC2LUuqj1I
1925
+ AErUXKeRz8i3lUSZW1Pf4CaMpnIiPdWbz6f0KkaJSFi9bqexONBx4fKQNlgZwm2/
1926
+ aYjjrYng788I0QhWDKUqsQOi5mZKlHNRsDlk7J3Afhsx/jTLrCX/G8+2tPtLsHyR
1927
+ N39kluM5vYHbKXDsCG/a88Z2yUE2+r4Clp0FUKffiEDBPm0/H0sQ4Q1oEfQFDQRK
1928
+ aIkhpsm0nOnLYTy3/xJc5uqDNkLiawIDAQABo1wwWjAPBgNVHRMBAf8EBTADAQH/
1929
+ MB0GA1UdDgQWBBSejWrVnw7QaBjNFCHMNFi+doSOcTAoBgNVHSMEITAfgBSejWrV
1930
+ nw7QaBjNFCHMNFi+doSOcaEEpAIwAIIBATANBgkqhkiG9w0BAQUFAAOCAQEAAe85
1931
+ BQ1ydAHFqo0ib38VRPOwf5xPHGbYGhvQi4/sU6aTuR7pxaOJPYz05jLhS+utEmy1
1932
+ sknBq60G67yhQE7IHcfwrl1arirG2WmKGvAbjeYL2K1UiU0pVD3D+Klkv/pK6jIQ
1933
+ eOJRGb3qNUn0Sq9EoYIOXiGXQ641F0bZZ0+5H92kT1lmnF5oLfCb84ImD9T3snH6
1934
+ pIr5RKRx/0YmJIcv3WdpoPT903rOJiRIEgIj/hDk9QZTBpm222Ul5yQQ5pBywpSp
1935
+ xh0bmJKAQWhQm7QlybKfyaQmg5ot1jEzWAvD2I5FjHQxmAlchjb6RreaRhExj+JE
1936
+ 5O117dMBdzDBjcNMOA==
1937
+ -----END CERTIFICATE-----
1938
+ PKCS7
1939
+ end
1940
+
1941
+ let(:keys_dir) do
1942
+ keys = tmpdir('keys')
1943
+ dir_contained_in(keys, {
1944
+ private_key_name => private_key,
1945
+ public_key_name => public_key
1946
+ })
1947
+ keys
1948
+ end
1949
+
1950
+ let(:private_key_path) { File.join(keys_dir, private_key_name) }
1951
+ let(:public_key_path) { File.join(keys_dir, public_key_name) }
1952
+
1953
+ let(:env_hiera_yaml) do
1954
+ <<-YAML.unindent
1955
+ version: 5
1956
+ hierarchy:
1957
+ - name: EYaml
1958
+ path: common.eyaml
1959
+ lookup_key: eyaml_lookup_key
1960
+ options:
1961
+ pkcs7_private_key: #{private_key_path}
1962
+ pkcs7_public_key: #{public_key_path}
1963
+ YAML
1964
+ end
1965
+
1966
+ let(:data_files) do
1967
+ {
1968
+ 'common.eyaml' => <<-YAML.unindent
1969
+ a: >
1970
+ ENC[PKCS7,MIIBmQYJKoZIhvcNAQcDoIIBijCCAYYCAQAxggEhMIIBHQIBADAFMAACAQEw
1971
+ DQYJKoZIhvcNAQEBBQAEggEAUwwNRA5ZKM87SLnjnJfzDFRQbeheSYMTOhcr
1972
+ sgTPCGtzEAzvRBrkdIRAvDZVRfadV9OB+bJsYrhWIkU1bYiOn1m78ginh96M
1973
+ 44RuspnIZYnL9Dhs+JyC8VvB5nlvlEph2RGt+KYg9iU4JYhwZ2+8+yxB6/UK
1974
+ H5HGKDCjBbEc8o9MbCckLsciIh11hKKgT6K0yhKB/nBxxM78nrX0BxmAHX2u
1975
+ bejKDRa9S/0uS7Y91nvnbIkaQpZ4KteSQ+J4/lQBMlMAeE+2F9ncM8jFKnQC
1976
+ rzzdbn1O/zwsEt5J5CRP1Sc+8hM644+IqkLs+17segxArHVGOsEqyDcHbXEK
1977
+ 9jspfzBcBgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBCIq/L5HeJgA9XQm67j
1978
+ JHUngDDS5s52FsuSIMin7Z/pV+XuaJGFkL80ia4bXnCWilmtM8oUa/DZuBje
1979
+ dCILO7I8QqU=]
1980
+ hash_a:
1981
+ hash_aa:
1982
+ aaa: >
1983
+ ENC[PKCS7,MIIBqQYJKoZIhvcNAQcDoIIBmjCCAZYCAQAxggEhMIIBHQIBADAFMAACAQEw
1984
+ DQYJKoZIhvcNAQEBBQAEggEAhvGXL5RxVUs9wdqJvpCyXtfCHrm2HbG/u30L
1985
+ n8EuRD9ravlsgIISAnd27JPtrxA+0rZq4EQRGz6OcovnH9vTg86/lVBhhPnz
1986
+ b83ArptGJhRvTYUJ19GZI3AYjJbhWj/Jo5NL56oQJaPBccqHxMApm/U0wlus
1987
+ QtASL94cLuh4toVIBQCQzD5/Bx51p2wQobm9p4WKSl1zJhDceurmoLZXqhuN
1988
+ JwwEBwXopJvgid3ZDPbdX8nI6vHhb/8wDq9yb5DOsrkgqDqQgwPU9sUUioQj
1989
+ Hr1pGyeOWnbEe99iEb2+m7TWsC0NN7OBo06mAgFNbBLjvn2k4PiCxrOOgJ8S
1990
+ LI5eXjBsBgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBCWNS6j3m/Xvrp5RFaN
1991
+ ovm/gEB4oPlYJswoXuWqcEBfwZzbpy96x3b2Le/yoa72ylbPAUc5GfLENvFQ
1992
+ zXpTtSmQE0fixY4JMaBTke65ZRvoiOQO]
1993
+ array_a:
1994
+ - >
1995
+ ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEw
1996
+ DQYJKoZIhvcNAQEBBQAEggEAmXZfyfU77vVCZqHpR10qhD0Jy9DpMGBgal97
1997
+ vUO2VHX7KlCgagK0kz8/uLRIthkYzcpn8ISmw/+CIAny3jOjxOsylJiujqyu
1998
+ hx/JEFl8bOKOg40Bd0UuBaw/qZ+CoAtOorhiIW7x6t7DpknItC6gkH/cSJ4/
1999
+ p3MdhoARRuwj2fvuaChVsD39l2rXjgJj0OJOaDXdbuisG75VRZf5l8IH6+44
2000
+ Q7m6W7BU69LX+ozn+W3filQoiJ5MPf8w/KXAObMSbKYIDsrZUyIWyyNUbpW0
2001
+ MieIkHj93bX3gIEcenECLdWaEzcPa7MHgl6zevQKg4H0JVmcvKYyfHYqcrVE
2002
+ PqizKDA8BgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBDf259KZEay1widVSFy
2003
+ I9zGgBAICjm0x2GeqoCnHdiAA+jt]
2004
+ - >
2005
+ ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEw
2006
+ DQYJKoZIhvcNAQEBBQAEggEATVy4hHG356INFKOswAhoravh66iJljp+Vn3o
2007
+ UVD1kyRiqY5tz3UVSptzUmzD+YssX/f73AKCjUI3HrPNL7kAxsk6fWS7nDEj
2008
+ AuxtCqGYeBha6oYJYziSGIHfAdY3MiJUI1C9g/OQB4TTvKdrlDArPiY8THJi
2009
+ bzLLMbVQYJ6ixSldwkdKD75vtikyamx+1LSyVBSg8maVyPvLHtLZJuT71rln
2010
+ WON3Ious9PIbd+izbcCzaoqh5UnTfDCjOuAYliXalBxamIIwNzSV1sdR8/qf
2011
+ t22zpYK4J8lgCBV2gKfrOWSi9MAs6JhCeOb8wNLMmAUTbc0WrFJxoCwAPX0z
2012
+ MAjsNjA8BgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBC4v4bNE4gFlbLmVY+9
2013
+ BtSLgBBm7U0wu6d6s9wF9Ek9IHPe]
2014
+ YAML
2015
+ }
2016
+ end
2017
+
2018
+ let(:env_data) { data_files }
2019
+
2020
+ it 'finds data in the environment' do
2021
+ expect(lookup('a')).to eql("Encrypted value 'a' (from environment)")
2022
+ end
2023
+
2024
+ it 'can read encrypted values inside a hash' do
2025
+ expect(lookup('hash_a.hash_aa.aaa')).to eql('Encrypted value hash_a.hash_aa.aaa (from environment)')
2026
+ end
2027
+
2028
+ it 'can read encrypted values inside an array' do
2029
+ expect(lookup('array_a')).to eql(['array_a[0]', 'array_a[1]'])
2030
+ end
2031
+
2032
+ context 'declared in global scope as a Hiera v3 backend' do
2033
+ let(:environment_files) { {} }
2034
+ let(:hiera_yaml) do
2035
+ <<-YAML.unindent
2036
+ :backends: eyaml
2037
+ :eyaml:
2038
+ :datadir: #{code_dir}/hieradata
2039
+ :pkcs7_private_key: #{private_key_path}
2040
+ :pkcs7_public_key: #{public_key_path}
2041
+ :hierarchy:
2042
+ - common
2043
+ YAML
2044
+ end
2045
+
2046
+ let(:data_files) do
2047
+ {
2048
+ 'common.eyaml' => <<-YAML.unindent
2049
+ a: >
2050
+ ENC[PKCS7,MIIBmQYJKoZIhvcNAQcDoIIBijCCAYYCAQAxggEhMIIBHQIBADAFMAACAQEw
2051
+ DQYJKoZIhvcNAQEBBQAEggEAH457bsfL8kYw9O50roE3dcE21nCnmPnQ2XSX
2052
+ LYRJ2C78LarbfFonKz0gvDW7tyhsLWASFCFaiU8T1QPBd2b3hoQK8E4B2Ual
2053
+ xga/K7r9y3OSgRomTm9tpTltC6re0Ubh3Dy71H61obwxEdNVTqjPe95+m2b8
2054
+ 6zWZVnzZzXXsTG1S17yJn1zaB/LXHbWNy4KyLLKCGAml+Gfl6ZMjmaplTmUA
2055
+ QIC5rI8abzbPP3TDMmbLOGNkrmLqI+3uS8tSueTMoJmWaMF6c+H/cA7oRxmV
2056
+ QCeEUVXjyFvCHcmbA+keS/RK9XF+vc07/XS4XkYSPs/I5hLQji1y9bkkGAs0
2057
+ tehxQjBcBgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBDHpA6Fcl/R16aIYcow
2058
+ oiO4gDAvfFH6jLUwXkcYtagnwdmhkd9TQJtxNWcIwMpvmk036MqIoGwwhQdg
2059
+ gV4beiCFtLU=]
2060
+ YAML
2061
+ }
2062
+ end
2063
+
2064
+ let(:code_dir_files) do
2065
+ {
2066
+ 'hiera.yaml' => hiera_yaml,
2067
+ 'hieradata' => data_files
2068
+ }
2069
+ end
2070
+
2071
+ before(:each) do
2072
+ Puppet.settings[:hiera_config] = File.join(code_dir, 'hiera.yaml')
2073
+ end
2074
+
2075
+ it 'finds data in the global layer' do
2076
+ expect(lookup('a')).to eql("Encrypted value 'a' (from global)")
2077
+ end
2078
+
2079
+ it 'delegates configured eyaml backend to eyaml_lookup_key function' do
2080
+ expect(explain('a')).to match(/Hierarchy entry "eyaml"\n.*\n.*\n.*"common"\n\s*Found key: "a"/m)
2081
+ end
2082
+ end
2083
+ end
1796
2084
  end
1797
2085
  end