puppet 4.10.4-x64-mingw32 → 4.10.5-x64-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 (70) hide show
  1. checksums.yaml +7 -0
  2. data/lib/puppet/application/lookup.rb +2 -2
  3. data/lib/puppet/configurer/fact_handler.rb +1 -1
  4. data/lib/puppet/face/epp.rb +26 -24
  5. data/lib/puppet/file_serving/metadata.rb +2 -2
  6. data/lib/puppet/forge.rb +5 -3
  7. data/lib/puppet/forge/cache.rb +1 -0
  8. data/lib/puppet/forge/repository.rb +2 -1
  9. data/lib/puppet/indirector/catalog/compiler.rb +4 -3
  10. data/lib/puppet/indirector/request.rb +9 -8
  11. data/lib/puppet/module.rb +30 -0
  12. data/lib/puppet/network/http/rack/rest.rb +2 -1
  13. data/lib/puppet/parser/compiler.rb +4 -0
  14. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  15. data/lib/puppet/parser/functions/binary_file.rb +1 -1
  16. data/lib/puppet/parser/functions/break.rb +1 -1
  17. data/lib/puppet/parser/functions/defined.rb +1 -1
  18. data/lib/puppet/parser/functions/dig.rb +1 -1
  19. data/lib/puppet/parser/functions/each.rb +1 -1
  20. data/lib/puppet/parser/functions/epp.rb +1 -1
  21. data/lib/puppet/parser/functions/filter.rb +1 -1
  22. data/lib/puppet/parser/functions/find_file.rb +1 -1
  23. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  24. data/lib/puppet/parser/functions/lest.rb +1 -1
  25. data/lib/puppet/parser/functions/map.rb +1 -1
  26. data/lib/puppet/parser/functions/match.rb +1 -1
  27. data/lib/puppet/parser/functions/new.rb +1 -1
  28. data/lib/puppet/parser/functions/next.rb +1 -1
  29. data/lib/puppet/parser/functions/reduce.rb +1 -1
  30. data/lib/puppet/parser/functions/return.rb +1 -1
  31. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  32. data/lib/puppet/parser/functions/slice.rb +1 -1
  33. data/lib/puppet/parser/functions/step.rb +1 -1
  34. data/lib/puppet/parser/functions/strftime.rb +1 -1
  35. data/lib/puppet/parser/functions/then.rb +1 -1
  36. data/lib/puppet/parser/functions/type.rb +1 -1
  37. data/lib/puppet/parser/functions/with.rb +1 -1
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -2
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +2 -2
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +2 -2
  41. data/lib/puppet/pops/merge_strategy.rb +1 -1
  42. data/lib/puppet/provider/nameservice.rb +4 -2
  43. data/lib/puppet/reports/http.rb +4 -2
  44. data/lib/puppet/resource/capability_finder.rb +1 -1
  45. data/lib/puppet/type/file/source.rb +9 -3
  46. data/lib/puppet/util.rb +122 -2
  47. data/lib/puppet/util/execution.rb +1 -1
  48. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  49. data/lib/puppet/version.rb +1 -1
  50. data/locales/puppet.pot +12 -4
  51. data/spec/integration/application/apply_spec.rb +10 -0
  52. data/spec/integration/type/file_spec.rb +29 -0
  53. data/spec/integration/util/execution_spec.rb +8 -0
  54. data/spec/unit/application/lookup_spec.rb +1 -1
  55. data/spec/unit/configurer/fact_handler_spec.rb +30 -8
  56. data/spec/unit/face/epp_face_spec.rb +9 -0
  57. data/spec/unit/file_serving/metadata_spec.rb +21 -0
  58. data/spec/unit/forge/forge_spec.rb +112 -0
  59. data/spec/unit/forge/repository_spec.rb +4 -4
  60. data/spec/unit/functions/lookup_spec.rb +26 -0
  61. data/spec/unit/indirector/catalog/compiler_spec.rb +1 -1
  62. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  63. data/spec/unit/indirector/request_spec.rb +16 -1
  64. data/spec/unit/module_spec.rb +29 -0
  65. data/spec/unit/network/http/api/indirected_routes_spec.rb +3 -3
  66. data/spec/unit/network/http/rack/rest_spec.rb +3 -3
  67. data/spec/unit/type/file_spec.rb +46 -0
  68. data/spec/unit/util_spec.rb +230 -1
  69. data/tasks/parallel.rake +12 -7
  70. metadata +188 -212
@@ -15,6 +15,14 @@ describe Puppet::Util::Execution do
15
15
  Puppet::Util::Execution.execpipe('echo $LC_ALL'){ |line| out << line.read.chomp }
16
16
  expect(out).to eq("C")
17
17
  end
18
+
19
+ it "should raise an ExecutionFailure with a missing command and :failonfail set to true" do
20
+ expect {
21
+ failonfail = true
22
+ # NOTE: critical to return l in the block for `output` in method to be #<IO:(closed)>
23
+ Puppet::Util::Execution.execpipe('conan_the_librarion', failonfail) { |l| l }
24
+ }.to raise_error(Puppet::ExecutionFailure)
25
+ end
18
26
  end
19
27
 
20
28
  describe "#execute (non-Windows)", :if => !Puppet.features.microsoft_windows? do
@@ -59,7 +59,7 @@ describe Puppet::Application::Lookup do
59
59
  lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
60
60
  lookup.stubs(:generate_scope).yields('scope')
61
61
 
62
- expected_merge = { "strategy" => "deep", "sort_merge_arrays" => false, "merge_hash_arrays" => true }
62
+ expected_merge = { "strategy" => "deep", "sort_merged_arrays" => false, "merge_hash_arrays" => true }
63
63
 
64
64
  (Puppet::Pops::Lookup).expects(:lookup).with(['atton', 'kreia'], nil, nil, false, expected_merge, anything).returns('rand')
65
65
 
@@ -72,25 +72,47 @@ describe Puppet::Configurer::FactHandler do
72
72
  it "should serialize and CGI escape the fact values for uploading" do
73
73
  facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
74
74
  Puppet::Node::Facts.indirection.save(facts)
75
- text = CGI.escape(facthandler.find_facts.render(:pson))
75
+ text = Puppet::Util.uri_query_encode(facthandler.find_facts.render(:pson))
76
76
 
77
77
  expect(facthandler.facts_for_uploading).to eq({:facts_format => :pson, :facts => text})
78
78
  end
79
79
 
80
- it "should properly accept facts containing a '+'" do
81
- fact_hash = { 'afact' => 'a+b' }
82
- facts = Puppet::Node::Facts.new(Puppet[:node_name_value], fact_hash)
83
- Puppet::Node::Facts.indirection.save(facts)
84
- text = CGI.escape(facthandler.find_facts.render(:pson))
80
+ [
81
+ { :hash => { 'afact' => 'a+b' }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'a%2Bb' + '%22%7D' },
82
+ { :hash => { 'afact' => 'a b' }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'a%20b' + '%22%7D' },
83
+ { :hash => { 'afact' => 'a&b' }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'a%26b' + '%22%7D' },
84
+ { :hash => { 'afact' => 'a*b' }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'a%2Ab' + '%22%7D' },
85
+ { :hash => { 'afact' => 'a=b' }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'a%3Db' + '%22%7D' },
86
+ # different UTF-8 widths
87
+ # 1-byte A
88
+ # 2-byte ۿ - http://www.fileformat.info/info/unicode/char/06ff/index.htm - 0xDB 0xBF / 219 191
89
+ # 3-byte ᚠ - http://www.fileformat.info/info/unicode/char/16A0/index.htm - 0xE1 0x9A 0xA0 / 225 154 160
90
+ # 4-byte 𠜎 - http://www.fileformat.info/info/unicode/char/2070E/index.htm - 0xF0 0xA0 0x9C 0x8E / 240 160 156 142
91
+ { :hash => { 'afact' => "A\u06FF\u16A0\u{2070E}" }, :encoded => '%22values%22%3A%7B%22afact%22%3A%22' + 'A%DB%BF%E1%9A%A0%F0%A0%9C%8E' + '%22%7D' },
92
+
93
+ ].each do |test_fact|
94
+ it "should properly accept the fact #{test_fact[:hash]}" do
95
+ facts = Puppet::Node::Facts.new(Puppet[:node_name_value], test_fact[:hash])
96
+ Puppet::Node::Facts.indirection.save(facts)
97
+ text = Puppet::Util.uri_query_encode(facthandler.find_facts.render(:pson))
85
98
 
86
- expect(facthandler.facts_for_uploading).to eq({:facts_format => :pson, :facts => text})
99
+ to_upload = facthandler.facts_for_uploading
100
+ expect(to_upload).to eq({:facts_format => :pson, :facts => text})
101
+ expect(text).to include(test_fact[:encoded])
102
+
103
+ # this is not sufficient to test whether these values are sent via HTTP GET or HTTP POST in actual catalog request
104
+ expect(JSON.parse(URI.unescape(to_upload[:facts]))['values']).to eq(test_fact[:hash])
105
+ end
87
106
  end
88
107
 
89
108
  it "should generate valid facts data against the facts schema" do
90
109
  facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
91
110
  Puppet::Node::Facts.indirection.save(facts)
92
111
 
93
- expect(CGI.unescape(facthandler.facts_for_uploading[:facts])).to validate_against('api/schemas/facts.json')
112
+ # prefer URI.unescape but validate CGI also works
113
+ encoded_facts = facthandler.facts_for_uploading[:facts]
114
+ expect(URI.unescape(encoded_facts)).to validate_against('api/schemas/facts.json')
115
+ expect(CGI.unescape(encoded_facts)).to validate_against('api/schemas/facts.json')
94
116
  end
95
117
 
96
118
  end
@@ -237,6 +237,15 @@ describe Puppet::Face[:epp, :current] do
237
237
  expect(eppface.render({ :e => 'trusted is hash: <%= $trusted =~ Hash %>' })).to eql("trusted is hash: true")
238
238
  end
239
239
 
240
+ it 'initializes the 4x loader' do
241
+ expect(eppface.render({ :e => <<-EPP.unindent })).to eql("\nString\n\nInteger\n\nBoolean\n")
242
+ <% $data = [type('a',generalized), type(2,generalized), type(true)] -%>
243
+ <% $data.each |$value| { %>
244
+ <%= $value %>
245
+ <% } -%>
246
+ EPP
247
+ end
248
+
240
249
  it "facts can be added to" do
241
250
  expect(eppface.render({
242
251
  :facts => {'the_crux' => 'biscuit'},
@@ -107,6 +107,27 @@ describe Puppet::FileServing::Metadata do
107
107
  expect(metadata.content_uri).to eq(uri)
108
108
  end
109
109
 
110
+ it "should accept UTF-8 characters" do
111
+ # different UTF-8 widths
112
+ # 1-byte A
113
+ # 2-byte ۿ - http://www.fileformat.info/info/unicode/char/06ff/index.htm - 0xDB 0xBF / 219 191
114
+ # 3-byte ᚠ - http://www.fileformat.info/info/unicode/char/16A0/index.htm - 0xE1 0x9A 0xA0 / 225 154 160
115
+ # 4-byte <U+070E> - http://www.fileformat.info/info/unicode/char/2070E/index.htm - 0xF0 0xA0 0x9C 0x8E / 240 160 156 142
116
+ mixed_utf8 = "A\u06FF\u16A0\u{2070E}" # Aۿᚠ<U+070E>
117
+
118
+ uri = "puppet:///modules/foo/files/ #{mixed_utf8}"
119
+ metadata.content_uri = uri
120
+ expect(metadata.content_uri).to eq(uri)
121
+ expect(metadata.content_uri.encoding).to eq(Encoding::UTF_8)
122
+ end
123
+
124
+ it "should always set it as UTF-8" do
125
+ uri = "puppet:///modules/foo/files/".encode(Encoding::ASCII)
126
+ metadata.content_uri = uri
127
+ expect(metadata.content_uri).to eq(uri)
128
+ expect(metadata.content_uri.encoding).to eq(Encoding::UTF_8)
129
+ end
130
+
110
131
  it "should fail if uri is opaque" do
111
132
  expect { metadata.content_uri = 'scheme:www.example.com' }.to raise_error ArgumentError, "Cannot use opaque URLs 'scheme:www.example.com'"
112
133
  end
@@ -0,0 +1,112 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'net/http'
4
+ require 'puppet/forge/repository'
5
+
6
+ describe Puppet::Forge do
7
+ before(:all) do
8
+ # any local http proxy will break these tests
9
+ ENV['http_proxy'] = nil
10
+ ENV['HTTP_PROXY'] = nil
11
+ end
12
+
13
+ let(:host) { 'fake.com' }
14
+ let(:forge) { Puppet::Forge.new("http://#{host}") }
15
+ # creates a repository like Puppet::Forge::Repository.new('http://fake.com', USER_AGENT)
16
+
17
+ # different UTF-8 widths
18
+ # 1-byte A
19
+ # 2-byte ۿ - http://www.fileformat.info/info/unicode/char/06ff/index.htm - 0xDB 0xBF / 219 191
20
+ # 3-byte ᚠ - http://www.fileformat.info/info/unicode/char/16A0/index.htm - 0xE1 0x9A 0xA0 / 225 154 160
21
+ # 4-byte ܎ - http://www.fileformat.info/info/unicode/char/2070E/index.htm - 0xF0 0xA0 0x9C 0x8E / 240 160 156 142
22
+ let (:mixed_utf8_query_param) { "foo + A\u06FF\u16A0\u{2070E}" } # Aۿᚠ
23
+ let (:mixed_utf8_query_param_encoded) { "foo%20%2B%20A%DB%BF%E1%9A%A0%F0%A0%9C%8E"}
24
+ let (:empty_json) { '{ "results": [], "pagination" : { "next" : null } }' }
25
+ let (:ok_response) { stub('response', :code => '200', :body => empty_json) }
26
+
27
+ describe "making a" do
28
+ before :each do
29
+ proxy_settings_of("proxy", 1234)
30
+ end
31
+
32
+ context "search request" do
33
+
34
+ it "includes any defined module_groups, ensuring to only encode them once in the URI" do
35
+ Puppet[:module_groups] = 'base+pe'
36
+
37
+ # ignores Puppet::Forge::Repository#read_response, provides response to search
38
+ performs_an_http_request(ok_response) do |http|
39
+ encoded_uri = "/v3/modules?query=#{mixed_utf8_query_param_encoded}&module_groups=base%20pe"
40
+ http.expects(:request).with(responds_with(:path, encoded_uri))
41
+ end
42
+
43
+ forge.search(mixed_utf8_query_param)
44
+ end
45
+
46
+ it "single encodes the search term in the URI" do
47
+ # ignores Puppet::Forge::Repository#read_response, provides response to search
48
+ performs_an_http_request(ok_response) do |http|
49
+ encoded_uri = "/v3/modules?query=#{mixed_utf8_query_param_encoded}"
50
+ http.expects(:request).with(responds_with(:path, encoded_uri))
51
+ end
52
+
53
+ forge.search(mixed_utf8_query_param)
54
+ end
55
+ end
56
+
57
+ context "fetch request" do
58
+
59
+ it "includes any defined module_groups, ensuring to only encode them once in the URI" do
60
+ Puppet[:module_groups] = 'base+pe'
61
+ module_name = 'puppetlabs-acl'
62
+
63
+ # ignores Puppet::Forge::Repository#read_response, provides response to fetch
64
+ performs_an_http_request(ok_response) do |http|
65
+ encoded_uri = "/v3/releases?module=#{module_name}&module_groups=base%20pe"
66
+ http.expects(:request).with(responds_with(:path, encoded_uri))
67
+ end
68
+
69
+ forge.fetch(module_name)
70
+ end
71
+
72
+ it "single encodes the module name term in the URI" do
73
+ module_name = "puppetlabs-#{mixed_utf8_query_param}"
74
+
75
+ # ignores Puppet::Forge::Repository#read_response, provides response to fetch
76
+ performs_an_http_request(ok_response) do |http|
77
+ encoded_uri = "/v3/releases?module=puppetlabs-#{mixed_utf8_query_param_encoded}"
78
+ http.expects(:request).with(responds_with(:path, encoded_uri))
79
+ end
80
+
81
+ forge.fetch(module_name)
82
+ end
83
+ end
84
+
85
+ def performs_an_http_request(result = nil, &block)
86
+ proxy_args = ["proxy", 1234, nil, nil]
87
+ mock_proxy(80, proxy_args, result, &block)
88
+ end
89
+ end
90
+
91
+ def proxy_settings_of(host, port)
92
+ Puppet[:http_proxy_host] = host
93
+ Puppet[:http_proxy_port] = port
94
+ end
95
+
96
+ def mock_proxy(port, proxy_args, result, &block)
97
+ http = mock("http client")
98
+ proxy = mock("http proxy")
99
+ proxy_class = mock("http proxy class")
100
+
101
+ Net::HTTP.expects(:Proxy).with(*proxy_args).returns(proxy_class)
102
+ proxy_class.expects(:new).with(host, port).returns(proxy)
103
+
104
+ proxy.expects(:open_timeout=)
105
+ proxy.expects(:read_timeout=)
106
+
107
+ proxy.expects(:start).yields(http).returns(result)
108
+ yield http
109
+
110
+ proxy
111
+ end
112
+ end
@@ -121,10 +121,10 @@ describe Puppet::Forge::Repository do
121
121
  expect(request['Authorization']).to eq(token)
122
122
  end
123
123
 
124
- it "escapes the received URI" do
124
+ it "encodes the received URI" do
125
125
  unescaped_uri = "héllo world !! ç à"
126
126
  performs_an_http_request do |http|
127
- http.expects(:request).with(responds_with(:path, URI.escape(unescaped_uri)))
127
+ http.expects(:request).with(responds_with(:path, Puppet::Util.uri_encode(unescaped_uri)))
128
128
  end
129
129
 
130
130
  repository.make_http_request(unescaped_uri)
@@ -197,10 +197,10 @@ describe Puppet::Forge::Repository do
197
197
  expect(request['User-Agent']).to match(/\bRuby\b/)
198
198
  end
199
199
 
200
- it "escapes the received URI" do
200
+ it "encodes the received URI" do
201
201
  unescaped_uri = "héllo world !! ç à"
202
202
  performs_an_authenticated_http_request do |http|
203
- http.expects(:request).with(responds_with(:path, URI.escape(unescaped_uri)))
203
+ http.expects(:request).with(responds_with(:path, Puppet::Util.uri_encode(unescaped_uri)))
204
204
  end
205
205
 
206
206
  repository.make_http_request(unescaped_uri)
@@ -933,6 +933,8 @@ describe "The lookup function" do
933
933
  bab: bab (from environment)
934
934
  bc:
935
935
  bca: bca (from environment)
936
+ sa:
937
+ sa1: ['e', 'd', '--f']
936
938
  YAML
937
939
  'second.yaml' => <<-YAML.unindent,
938
940
  a:
@@ -946,6 +948,8 @@ describe "The lookup function" do
946
948
  c:
947
949
  ca:
948
950
  cab: c.ca.cab
951
+ sa:
952
+ sa1: ['b', 'a', 'f', 'c']
949
953
  YAML
950
954
  }
951
955
  end
@@ -1026,6 +1030,28 @@ describe "The lookup function" do
1026
1030
  expect(lookup('a')).to eql({'aa' => { 'aaa' => 'a.aa.aaa', 'aab' => 'a.aa.aab' }})
1027
1031
  end
1028
1032
  end
1033
+
1034
+ context 'and lookup options use a hash' do
1035
+
1036
+ let(:env_lookup_options) { <<-YAML.unindent }
1037
+ lookup_options:
1038
+ 'sa':
1039
+ merge:
1040
+ strategy: deep
1041
+ knockout_prefix: --
1042
+ sort_merged_arrays: true
1043
+ YAML
1044
+
1045
+ it 'applies knockout_prefix and sort_merged_arrays' do
1046
+ expect(lookup('sa')).to eql({ 'sa1' => %w(a b c d e) })
1047
+ end
1048
+
1049
+ it 'overrides knockout_prefix and sort_merged_arrays with explicitly given values' do
1050
+ expect(
1051
+ lookup('sa', 'merge' => { 'strategy' => 'deep', 'knockout_prefix' => '##', 'sort_merged_arrays' => false })).to(
1052
+ eql({ 'sa1' => %w(b a f c e d --f) }))
1053
+ end
1054
+ end
1029
1055
  end
1030
1056
 
1031
1057
  context 'and an environment Hiera v5 configuration using globs' do
@@ -258,7 +258,7 @@ describe Puppet::Resource::Catalog::Compiler do
258
258
  def a_request_that_contains(facts, format = :pson)
259
259
  request = Puppet::Indirector::Request.new(:catalog, :find, "hostname", nil)
260
260
  request.options[:facts_format] = format.to_s
261
- request.options[:facts] = CGI.escape(facts.render(format))
261
+ request.options[:facts] = Puppet::Util.uri_encode(facts.render(format))
262
262
  request
263
263
  end
264
264
 
@@ -41,16 +41,16 @@ describe Puppet::FileBucketFile::File, :uses_checksums => true do
41
41
  end
42
42
 
43
43
  it "fails if the contents collide with existing contents" do
44
- # This is the shortest known MD5 collision. See https://eprint.iacr.org/2010/643.pdf
44
+ # This is the shortest known MD5 collision (little endian). See https://eprint.iacr.org/2010/643.pdf
45
45
  first_contents = [0x6165300e,0x87a79a55,0xf7c60bd0,0x34febd0b,
46
46
  0x6503cf04,0x854f709e,0xfb0fc034,0x874c9c65,
47
47
  0x2f94cc40,0x15a12deb,0x5c15f4a3,0x490786bb,
48
- 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("I" * 16)
48
+ 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("V" * 16)
49
49
 
50
50
  collision_contents = [0x6165300e,0x87a79a55,0xf7c60bd0,0x34febd0b,
51
51
  0x6503cf04,0x854f749e,0xfb0fc034,0x874c9c65,
52
52
  0x2f94cc40,0x15a12deb,0xdc15f4a3,0x490786bb,
53
- 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("I" * 16)
53
+ 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("V" * 16)
54
54
 
55
55
  checksum_value = save_bucket_file(first_contents, "/foo/bar")
56
56
 
@@ -149,6 +149,21 @@ describe Puppet::Indirector::Request do
149
149
  expect(request.key.encoding).to eq(Encoding::UTF_8)
150
150
  end
151
151
 
152
+ it "should set the request key properly given a UTF-8 URI" do
153
+ # different UTF-8 widths
154
+ # 1-byte A
155
+ # 2-byte ۿ - http://www.fileformat.info/info/unicode/char/06ff/index.htm - 0xDB 0xBF / 219 191
156
+ # 3-byte ᚠ - http://www.fileformat.info/info/unicode/char/16A0/index.htm - 0xE1 0x9A 0xA0 / 225 154 160
157
+ # 4-byte <U+070E> - http://www.fileformat.info/info/unicode/char/2070E/index.htm - 0xF0 0xA0 0x9C 0x8E / 240 160 156 142
158
+ mixed_utf8 = "A\u06FF\u16A0\u{2070E}" # Aۿᚠ<U+070E>
159
+
160
+ key = "a/path/stu ff/#{mixed_utf8}"
161
+ req = Puppet::Indirector::Request.new(:ind, :method, "http:///#{key}", nil)
162
+ expect(req.key).to eq(key)
163
+ expect(req.key.encoding).to eq(Encoding::UTF_8)
164
+ expect(req.uri).to eq("http:///#{key}")
165
+ end
166
+
152
167
  it "should set the :uri attribute to the full URI" do
153
168
  expect(Puppet::Indirector::Request.new(:ind, :method, "http:///a/path/stu ff", nil).uri).to eq('http:///a/path/stu ff')
154
169
  end
@@ -231,7 +246,7 @@ describe Puppet::Indirector::Request do
231
246
  end
232
247
 
233
248
  it "should be able to return the URI-escaped key" do
234
- expect(Puppet::Indirector::Request.new(:myind, :find, "my key", nil).escaped_key).to eq(URI.escape("my key"))
249
+ expect(Puppet::Indirector::Request.new(:myind, :find, "my key", nil).escaped_key).to eq(Puppet::Util.uri_encode("my key"))
235
250
  end
236
251
 
237
252
  it "should set its environment to an environment instance when a string is specified as its environment" do
@@ -440,6 +440,35 @@ describe Puppet::Module do
440
440
  end
441
441
  end
442
442
 
443
+
444
+ describe "initialize_i18n" do
445
+
446
+ let(:modpath) { tmpdir('modpath') }
447
+ let(:modname) { 'puppetlabs-i18n'}
448
+ let(:modroot) { "#{modpath}/#{modname}/" }
449
+ let(:config_path) { "#{modroot}/locales/config.yaml" }
450
+ let(:mod_obj) { PuppetSpec::Modules.create( modname, modpath, :metadata => { :dependencies => [] }, :env => env ) }
451
+
452
+ it "is expected to initialize an un-initialized module" do
453
+ expect(GettextSetup.translation_repositories.has_key? modname).to be false
454
+
455
+ FileUtils.mkdir_p("#{mod_obj.path}/locales")
456
+ config = {
457
+ "gettext" => {
458
+ "project_name" => modname
459
+ }
460
+ }
461
+ File.open(config_path, 'w') { |file| file.write(config.to_yaml) }
462
+
463
+ mod_obj.initialize_i18n
464
+
465
+ expect(GettextSetup.translation_repositories.has_key? modname).to be true
466
+ end
467
+ it "is expected return nil if module is intiailized" do
468
+ expect(mod_obj.initialize_i18n).to be nil
469
+ end
470
+ end
471
+
443
472
  describe "when managing supported platforms" do
444
473
  it "should support specifying a supported platform" do
445
474
  mod.supports "solaris"
@@ -127,13 +127,13 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
127
127
  end
128
128
 
129
129
  it "should not URI unescape the indirection key" do
130
- escaped = URI.escape("foo bar")
130
+ escaped = Puppet::Util.uri_encode("foo bar")
131
131
  indirection, _, key, _ = handler.uri2indirection("GET", "#{master_url_prefix}/node/#{escaped}", params)
132
132
  expect(key).to eq(escaped)
133
133
  end
134
134
 
135
135
  it "should not unescape the URI passed through in a call to check_authorization" do
136
- key_escaped = URI.escape("foo bar")
136
+ key_escaped = Puppet::Util.uri_encode("foo bar")
137
137
  uri_escaped = "#{master_url_prefix}/node/#{key_escaped}"
138
138
  handler.expects(:check_authorization).with(anything, uri_escaped, anything)
139
139
  indirection, _, _, _ = handler.uri2indirection("GET", uri_escaped, params)
@@ -199,7 +199,7 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
199
199
  end
200
200
 
201
201
  it "should use the escaped key as the remainder of the URI" do
202
- escaped = URI.escape("with spaces")
202
+ escaped = Puppet::Util.uri_encode("with spaces")
203
203
  expect(handler.class.request_to_uri_and_body(request).first.split("/")[4].sub(/\?.+/, '')).to eq(escaped)
204
204
  end
205
205
 
@@ -67,7 +67,7 @@ describe "Puppet::Network::HTTP::RackREST", :if => Puppet.features.rack? do
67
67
 
68
68
  it "should return the unescaped path for an escaped request path" do
69
69
  unescaped_path = '/foo/bar baz'
70
- escaped_path = URI.escape(unescaped_path)
70
+ escaped_path = Puppet::Util.uri_encode(unescaped_path)
71
71
  req = mk_req(escaped_path)
72
72
  expect(@handler.path(req)).to eq(unescaped_path)
73
73
  end
@@ -170,7 +170,7 @@ describe "Puppet::Network::HTTP::RackREST", :if => Puppet.features.rack? do
170
170
  end
171
171
 
172
172
  it "should CGI-decode the HTTP parameters" do
173
- encoding = CGI.escape("foo bar")
173
+ encoding = Puppet::Util.uri_query_encode("foo bar")
174
174
  req = mk_req("/?foo=#{encoding}")
175
175
  result = @handler.params(req)
176
176
  expect(result[:foo]).to eq("foo bar")
@@ -201,7 +201,7 @@ describe "Puppet::Network::HTTP::RackREST", :if => Puppet.features.rack? do
201
201
  end
202
202
 
203
203
  it "should treat YAML encoded parameters like it was any string" do
204
- escaping = CGI.escape(YAML.dump(%w{one two}))
204
+ escaping = Puppet::Util.uri_query_encode(YAML.dump(%w{one two}))
205
205
  req = mk_req("/?foo=#{escaping}")
206
206
  expect(@handler.params(req)[:foo]).to eq("---\n- one\n- two\n")
207
207
  end