puppet 0.25.0 → 0.25.1

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 (138) hide show
  1. data/CHANGELOG +4772 -19114
  2. data/README +1 -1
  3. data/Rakefile +7 -25
  4. data/{sbin → bin}/puppetca +0 -0
  5. data/{sbin → bin}/puppetd +0 -0
  6. data/{sbin → bin}/puppetmasterd +0 -0
  7. data/{sbin → bin}/puppetqd +0 -0
  8. data/{sbin → bin}/puppetrun +0 -0
  9. data/conf/osx/createpackage.sh +1 -1
  10. data/conf/redhat/client.init +6 -3
  11. data/conf/redhat/puppet.spec +26 -14
  12. data/conf/redhat/server.init +3 -2
  13. data/ext/vim/syntax/puppet.vim +4 -1
  14. data/install.rb +25 -7
  15. data/lib/puppet.rb +1 -1
  16. data/lib/puppet/agent.rb +2 -2
  17. data/lib/puppet/application/puppet.rb +3 -3
  18. data/lib/puppet/application/puppetd.rb +0 -7
  19. data/lib/puppet/application/puppetdoc.rb +1 -0
  20. data/lib/puppet/application/puppetmasterd.rb +2 -2
  21. data/lib/puppet/configurer.rb +6 -1
  22. data/lib/puppet/configurer/fact_handler.rb +2 -2
  23. data/lib/puppet/defaults.rb +2 -2
  24. data/lib/puppet/external/nagios/base.rb +4 -3
  25. data/lib/puppet/external/pson/common.rb +367 -0
  26. data/lib/puppet/external/pson/pure.rb +77 -0
  27. data/lib/puppet/external/pson/pure/generator.rb +429 -0
  28. data/lib/puppet/external/pson/pure/parser.rb +269 -0
  29. data/lib/puppet/external/pson/version.rb +8 -0
  30. data/lib/puppet/feature/pson.rb +6 -0
  31. data/lib/puppet/feature/rails.rb +1 -5
  32. data/lib/puppet/file_serving/configuration.rb +2 -2
  33. data/lib/puppet/indirector/certificate/rest.rb +6 -0
  34. data/lib/puppet/indirector/facts/facter.rb +1 -1
  35. data/lib/puppet/indirector/ldap.rb +1 -1
  36. data/lib/puppet/indirector/queue.rb +3 -3
  37. data/lib/puppet/indirector/rest.rb +1 -1
  38. data/lib/puppet/network/authstore.rb +34 -53
  39. data/lib/puppet/network/formats.rb +59 -9
  40. data/lib/puppet/network/http/mongrel/rest.rb +10 -9
  41. data/lib/puppet/network/http/webrick.rb +8 -1
  42. data/lib/puppet/network/http/webrick/rest.rb +2 -5
  43. data/lib/puppet/network/http_server/webrick.rb +1 -4
  44. data/lib/puppet/parser/ast/leaf.rb +1 -3
  45. data/lib/puppet/parser/collector.rb +14 -8
  46. data/lib/puppet/parser/compiler.rb +7 -0
  47. data/lib/puppet/parser/functions/fqdn_rand.rb +4 -10
  48. data/lib/puppet/parser/functions/regsubst.rb +44 -30
  49. data/lib/puppet/parser/functions/require.rb +18 -3
  50. data/lib/puppet/parser/functions/versioncmp.rb +1 -1
  51. data/lib/puppet/parser/interpreter.rb +1 -1
  52. data/lib/puppet/parser/lexer.rb +29 -31
  53. data/lib/puppet/parser/loaded_code.rb +4 -0
  54. data/lib/puppet/parser/parser_support.rb +5 -2
  55. data/lib/puppet/parser/resource.rb +31 -6
  56. data/lib/puppet/property.rb +3 -2
  57. data/lib/puppet/provider/macauthorization/macauthorization.rb +14 -14
  58. data/lib/puppet/provider/package/dpkg.rb +1 -1
  59. data/lib/puppet/provider/package/portage.rb +15 -5
  60. data/lib/puppet/provider/package/rug.rb +1 -1
  61. data/lib/puppet/provider/package/up2date.rb +1 -1
  62. data/lib/puppet/provider/package/urpmi.rb +1 -1
  63. data/lib/puppet/provider/service/daemontools.rb +7 -10
  64. data/lib/puppet/provider/service/runit.rb +7 -17
  65. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -47
  66. data/lib/puppet/provider/zone/solaris.rb +12 -3
  67. data/lib/puppet/relationship.rb +12 -12
  68. data/lib/puppet/reports/rrdgraph.rb +1 -1
  69. data/lib/puppet/reports/store.rb +2 -2
  70. data/lib/puppet/reports/tagmail.rb +5 -16
  71. data/lib/puppet/resource.rb +15 -20
  72. data/lib/puppet/resource/catalog.rb +40 -29
  73. data/lib/puppet/ssl/certificate_revocation_list.rb +0 -2
  74. data/lib/puppet/ssl/host.rb +2 -3
  75. data/lib/puppet/sslcertificates/ca.rb +0 -5
  76. data/lib/puppet/type/cron.rb +1 -1
  77. data/lib/puppet/type/file/owner.rb +7 -4
  78. data/lib/puppet/type/resources.rb +17 -17
  79. data/lib/puppet/type/yumrepo.rb +10 -3
  80. data/lib/puppet/util.rb +6 -11
  81. data/lib/puppet/util/inifile.rb +8 -0
  82. data/lib/puppet/util/log.rb +2 -2
  83. data/lib/puppet/util/monkey_patches.rb +0 -43
  84. data/lib/puppet/util/{json.rb → pson.rb} +6 -6
  85. data/lib/puppet/util/rdoc.rb +5 -3
  86. data/lib/puppet/util/selinux.rb +12 -6
  87. data/lib/puppet/util/settings.rb +25 -16
  88. data/lib/puppet/util/settings/file_setting.rb +4 -2
  89. data/spec/integration/application/puppet.rb +4 -4
  90. data/spec/integration/defaults.rb +2 -2
  91. data/spec/integration/indirector/catalog/queue.rb +5 -5
  92. data/spec/integration/indirector/certificate/rest.rb +3 -1
  93. data/spec/integration/network/formats.rb +36 -36
  94. data/spec/integration/parser/functions/require.rb +5 -3
  95. data/spec/integration/provider/mailalias/aliases.rb +4 -4
  96. data/spec/integration/resource/catalog.rb +4 -4
  97. data/spec/unit/application/puppet.rb +16 -15
  98. data/spec/unit/application/puppetd.rb +1 -1
  99. data/spec/unit/application/puppetdoc.rb +6 -0
  100. data/spec/unit/application/puppetmasterd.rb +6 -6
  101. data/spec/unit/configurer/fact_handler.rb +3 -3
  102. data/spec/unit/file_serving/configuration.rb +16 -2
  103. data/spec/unit/indirector/certificate/rest.rb +34 -0
  104. data/spec/unit/indirector/queue.rb +15 -15
  105. data/spec/unit/indirector/rest.rb +31 -9
  106. data/spec/unit/network/authstore.rb +105 -26
  107. data/spec/unit/network/formats.rb +124 -39
  108. data/spec/unit/parser/ast/leaf.rb +15 -0
  109. data/spec/unit/parser/collector.rb +20 -9
  110. data/spec/unit/parser/compiler.rb +19 -0
  111. data/spec/unit/parser/functions/fqdn_rand.rb +62 -0
  112. data/spec/unit/parser/functions/regsubst.rb +80 -0
  113. data/spec/unit/parser/functions/require.rb +19 -7
  114. data/spec/unit/parser/interpreter.rb +2 -2
  115. data/spec/unit/parser/lexer.rb +32 -7
  116. data/spec/unit/parser/loaded_code.rb +18 -1
  117. data/spec/unit/parser/parser.rb +10 -2
  118. data/spec/unit/parser/resource.rb +53 -2
  119. data/spec/unit/parser/scope.rb +1 -1
  120. data/spec/unit/property.rb +14 -4
  121. data/spec/unit/provider/package/dpkg.rb +7 -0
  122. data/spec/unit/provider/service/daemontools.rb +19 -2
  123. data/spec/unit/provider/service/redhat.rb +2 -0
  124. data/spec/unit/provider/service/runit.rb +15 -4
  125. data/spec/unit/provider/ssh_authorized_key/parsed.rb +32 -55
  126. data/spec/unit/relationship.rb +21 -46
  127. data/spec/unit/resource.rb +30 -39
  128. data/spec/unit/resource/catalog.rb +66 -51
  129. data/spec/unit/ssl/certificate_revocation_list.rb +0 -12
  130. data/spec/unit/type/cron.rb +33 -0
  131. data/spec/unit/type/file/owner.rb +10 -4
  132. data/spec/unit/util/json.rb +9 -9
  133. data/spec/unit/util/log.rb +36 -0
  134. data/spec/unit/util/settings.rb +6 -0
  135. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys2 +1 -0
  136. data/test/lib/puppettest/support/utils.rb +8 -16
  137. metadata +36 -13
  138. data/lib/puppet/feature/json.rb +0 -2
@@ -178,9 +178,16 @@ module Puppet
178
178
 
179
179
  # Store all modifications back to disk
180
180
  def self.store
181
- file = inifile.store
182
- unless file.nil?
183
- File.chmod(0644, file)
181
+ inifile.store
182
+ unless Puppet[:noop]
183
+ target_mode = 0644 # FIXME: should be configurable
184
+ inifile.each_file do |file|
185
+ current_mode = File.stat(file).mode & 0777
186
+ unless current_mode == target_mode
187
+ Puppet::info "changing mode of #{file} from %03o to %03o" % [current_mode, target_mode]
188
+ File.chmod(target_mode, file)
189
+ end
190
+ end
184
191
  end
185
192
  end
186
193
 
@@ -185,19 +185,14 @@ module Util
185
185
 
186
186
  def binary(bin)
187
187
  if bin =~ /^\//
188
- if FileTest.file? bin and FileTest.executable? bin
189
- return bin
190
- else
191
- return nil
192
- end
188
+ return bin if FileTest.file? bin and FileTest.executable? bin
193
189
  else
194
- x = %x{which #{bin} 2>/dev/null}.chomp
195
- if x == ""
196
- return nil
197
- else
198
- return x
199
- end
190
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
191
+ dest=File.join(dir, bin)
192
+ return dest if FileTest.file? dest and FileTest.executable? dest
193
+ end
200
194
  end
195
+ return nil
201
196
  end
202
197
  module_function :binary
203
198
 
@@ -180,6 +180,14 @@ module Puppet::Util::IniConfig
180
180
  end
181
181
  end
182
182
 
183
+ # Execute BLOCK, passing each file constituting this inifile
184
+ # as an argument
185
+ def each_file(&block)
186
+ @files.keys.each do |file|
187
+ yield(file)
188
+ end
189
+ end
190
+
183
191
  # Return the Section with the given name or nil
184
192
  def [](name)
185
193
  name = name.to_s
@@ -282,9 +282,9 @@ class Puppet::Util::Log
282
282
 
283
283
  def colorize(level, str)
284
284
  case Puppet[:color]
285
- when false; str
286
- when true, :ansi, "ansi"; console_color(level, str)
285
+ when true, :ansi, "ansi", :yes, "yes"; console_color(level, str)
287
286
  when :html, "html"; html_color(level, str)
287
+ else str
288
288
  end
289
289
  end
290
290
 
@@ -1,43 +0,0 @@
1
- #
2
- # Monkey patches to ruby classes for compatibility
3
- #
4
- #
5
- # In earlier versions of ruby (e.g. 1.8.1) yaml serialized symbols with an explicit
6
- # type designation. Later versions understand the explicit form in addition to the
7
- # implicit "literal" form (e.g. :symbol) which they produce.
8
- #
9
- # This causes problems when the puppet master and the client are running on different
10
- # versions of ruby; the newer version can produce yaml that it's older partner can't
11
- # decypher.
12
- #
13
- # This patch causes newer versions to produce the older encoding for Symbols. It is
14
- # only applied if the existing library does not already produce them. Thus it will
15
- # not be applied on older rubys and it will not be applied more than once. It also
16
- # checks that it has been applied to a version which support it and, if not reverts
17
- # to the original.
18
- #
19
- require "yaml"
20
-
21
- if :test.to_yaml !~ %r{!ruby/sym}
22
- class Symbol
23
- if !respond_to? :original_to_yaml
24
- alias :original_to_yaml :to_yaml
25
- def to_yaml(opts={})
26
- YAML::quick_emit(nil,opts) { |out|
27
- if out.respond_to? :scalar
28
- # 1.8.5 through 1.8.8, possibly others
29
- out.scalar("tag:ruby:sym", to_s,:to_yaml_style)
30
- elsif out.respond_to? :<<
31
- # 1.8.2, possibly others
32
- out << "!ruby/sym "
33
- self.id2name.to_yaml( :Emitter => out )
34
- else
35
- # go back to the base version if neither of the above work
36
- alias :to_yaml :original_to_yaml
37
- to_yaml(opts)
38
- end
39
- }
40
- end
41
- end
42
- end
43
- end
@@ -1,13 +1,13 @@
1
- # A simple module to provide consistency between how we use JSON and how
1
+ # A simple module to provide consistency between how we use PSON and how
2
2
  # ruby expects it to be used. Basically, we don't want to require
3
3
  # that the sender specify a class.
4
- # Ruby wants everyone to provide a 'json_class' field, and the JSON support
4
+ # Ruby wants everyone to provide a 'type' field, and the PSON support
5
5
  # requires such a field to track the class down. Because we use our URL to
6
6
  # figure out what class we're working on, we don't need that, and we don't want
7
7
  # our consumers and producers to need to know anything about our internals.
8
- module Puppet::Util::Json
9
- def json_create(json)
10
- raise ArgumentError, "No data provided in json data" unless json['data']
11
- from_json(json['data'])
8
+ module Puppet::Util::Pson
9
+ def pson_create(pson)
10
+ raise ArgumentError, "No data provided in pson data" unless pson['data']
11
+ from_pson(pson['data'])
12
12
  end
13
13
  end
@@ -49,13 +49,15 @@ module Puppet::Util::RDoc
49
49
  # of a manifest
50
50
  def output(file, ast)
51
51
  astobj = []
52
- ast[:nodes].each do |name, k|
52
+ ast.nodes.each do |name, k|
53
53
  astobj << k if k.file == file
54
54
  end
55
- ast[:classes].each do |name, k|
55
+
56
+ ast.hostclasses.each do |name,k|
56
57
  astobj << k if k.file == file
57
58
  end
58
- ast[:definitions].each do |name, k|
59
+
60
+ ast.definitions.each do |name, k|
59
61
  astobj << k if k.file == file
60
62
  end
61
63
  astobj.sort! {|a,b| a.line <=> b.line }.each do |k|
@@ -154,16 +154,22 @@ module Puppet::Util::SELinux
154
154
  def read_mounts
155
155
  mounts = ""
156
156
  begin
157
- mountfh = File.open("/proc/mounts")
158
- # We use read_nonblock() in a loop rather than read() to work-around
159
- # a linux kernel bug. See ticket #1963 for details.
160
- while true
161
- mounts += mountfh.read_nonblock(1024)
157
+ if File.instance_methods.include? "read_nonblock"
158
+ # If possible we use read_nonblock() in a loop rather than read() to work-
159
+ # a linux kernel bug. See ticket #1963 for details.
160
+ mountfh = File.open("/proc/mounts")
161
+ mounts += mountfh.read_nonblock(1024) while true
162
+ else
163
+ # Otherwise we shell out and let cat do it for us
164
+ mountfh = IO.popen("/bin/cat /proc/mounts")
165
+ mounts = mountfh.read
162
166
  end
163
167
  rescue EOFError
164
- mountfh.close
168
+ # that's expected
165
169
  rescue
166
170
  return nil
171
+ ensure
172
+ mountfh.close
167
173
  end
168
174
 
169
175
  mntpoint = {}
@@ -653,6 +653,30 @@ Generated on #{Time.now}.
653
653
  @config.has_key?(param)
654
654
  end
655
655
 
656
+ def uninterpolated_value(param, environment = nil)
657
+ param = param.to_sym
658
+ environment = environment.to_sym if environment
659
+
660
+ # See if we can find it within our searchable list of values
661
+ val = catch :foundval do
662
+ each_source(environment) do |source|
663
+ # Look for the value. We have to test the hash for whether
664
+ # it exists, because the value might be false.
665
+ @sync.synchronize do
666
+ if @values[source].include?(param)
667
+ throw :foundval, @values[source][param]
668
+ end
669
+ end
670
+ end
671
+ throw :foundval, nil
672
+ end
673
+
674
+ # If we didn't get a value, use the default
675
+ val = @config[param].default if val.nil?
676
+
677
+ return val
678
+ end
679
+
656
680
  # Find the correct value using our search path. Optionally accept an environment
657
681
  # in which to search before the other configuration sections.
658
682
  def value(param, environment = nil)
@@ -672,22 +696,7 @@ Generated on #{Time.now}.
672
696
  return cached
673
697
  end
674
698
 
675
- # See if we can find it within our searchable list of values
676
- val = catch :foundval do
677
- each_source(environment) do |source|
678
- # Look for the value. We have to test the hash for whether
679
- # it exists, because the value might be false.
680
- @sync.synchronize do
681
- if @values[source].include?(param)
682
- throw :foundval, @values[source][param]
683
- end
684
- end
685
- end
686
- throw :foundval, nil
687
- end
688
-
689
- # If we didn't get a value, use the default
690
- val = @config[param].default if val.nil?
699
+ val = uninterpolated_value(param, environment)
691
700
 
692
701
  # Convert it if necessary
693
702
  val = convert(val, environment)
@@ -16,7 +16,8 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
16
16
 
17
17
  def group=(value)
18
18
  unless AllowedGroups.include?(value)
19
- raise SettingError, "Invalid group %s on setting %s. Valid groups are %s." % [value, name, AllowedGroups.join(', ')]
19
+ identifying_fields = [desc,name,default].compact.join(': ')
20
+ raise SettingError, "Internal error: The :group setting for %s must be 'service', not '%s'" % [identifying_fields,value]
20
21
  end
21
22
  @group = value
22
23
  end
@@ -28,7 +29,8 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
28
29
 
29
30
  def owner=(value)
30
31
  unless AllowedOwners.include?(value)
31
- raise SettingError, "Invalid owner %s on setting %s. Valid owners are %s." % [value, name, AllowedOwners.join(', ')]
32
+ identifying_fields = [desc,name,default].compact.join(': ')
33
+ raise SettingError, "Internal error: The :owner setting for %s must be either 'root' or 'service', not '%s'" % [identifying_fields,value]
32
34
  end
33
35
  @owner = value
34
36
  end
@@ -10,16 +10,16 @@ describe "Puppet" do
10
10
  include PuppetSpec::Files
11
11
 
12
12
  describe "when applying provided catalogs" do
13
- confine "JSON library is missing; cannot test applying catalogs" => Puppet.features.json?
14
- it "should be able to apply catalogs provided in a file in json" do
15
- file_to_create = tmpfile("json_catalog")
13
+ confine "PSON library is missing; cannot test applying catalogs" => Puppet.features.pson?
14
+ it "should be able to apply catalogs provided in a file in pson" do
15
+ file_to_create = tmpfile("pson_catalog")
16
16
  catalog = Puppet::Resource::Catalog.new
17
17
  resource = Puppet::Resource.new(:file, file_to_create, :content => "my stuff")
18
18
  catalog.add_resource resource
19
19
 
20
20
  manifest = tmpfile("manifest")
21
21
 
22
- File.open(manifest, "w") { |f| f.print catalog.to_json }
22
+ File.open(manifest, "w") { |f| f.print catalog.to_pson }
23
23
 
24
24
  puppet = Puppet::Application[:puppet]
25
25
  puppet.options[:catalog] = manifest
@@ -89,8 +89,8 @@ describe "Puppet defaults" do
89
89
  end
90
90
  end
91
91
 
92
- it "should default to json for the preferred serialization format" do
93
- Puppet.settings.value(:preferred_serialization_format).should == "json"
92
+ it "should default to pson for the preferred serialization format" do
93
+ Puppet.settings.value(:preferred_serialization_format).should == "pson"
94
94
  end
95
95
 
96
96
  describe "when enabling storeconfigs" do
@@ -6,7 +6,7 @@ require 'puppet/resource/catalog'
6
6
 
7
7
 
8
8
  describe "Puppet::Resource::Catalog::Queue" do
9
- confine "Missing json support; cannot test queue" => Puppet.features.json?
9
+ confine "Missing pson support; cannot test queue" => Puppet.features.pson?
10
10
 
11
11
  before do
12
12
  Puppet::Resource::Catalog.indirection.terminus(:queue)
@@ -23,13 +23,13 @@ describe "Puppet::Resource::Catalog::Queue" do
23
23
 
24
24
  after { Puppet.settings.clear }
25
25
 
26
- it "should render catalogs to json and send them via the queue client when catalogs are saved" do
26
+ it "should render catalogs to pson and send them via the queue client when catalogs are saved" do
27
27
  terminus = Puppet::Resource::Catalog.indirection.terminus(:queue)
28
28
 
29
29
  client = mock 'client'
30
30
  terminus.stubs(:client).returns client
31
31
 
32
- client.expects(:send_message).with(:catalog, @catalog.to_json)
32
+ client.expects(:send_message).with(:catalog, @catalog.to_pson)
33
33
 
34
34
  request = Puppet::Indirector::Request.new(:catalog, :save, "foo", :instance => @catalog)
35
35
 
@@ -40,9 +40,9 @@ describe "Puppet::Resource::Catalog::Queue" do
40
40
  client = mock 'client'
41
41
  Puppet::Resource::Catalog::Queue.stubs(:client).returns client
42
42
 
43
- json = @catalog.to_json
43
+ pson = @catalog.to_pson
44
44
 
45
- client.expects(:subscribe).with(:catalog).yields(json)
45
+ client.expects(:subscribe).with(:catalog).yields(pson)
46
46
 
47
47
  Puppet.expects(:err).never
48
48
 
@@ -64,6 +64,8 @@ describe "Certificate REST Terminus" do
64
64
 
65
65
  # There's no good '==' method on certs.
66
66
  result.content.to_s.should == @host.certificate.content.to_s
67
- result.name.should == @host.certificate.name
67
+
68
+ # also make sure it uses the provided name, rather than the internal one.
69
+ result.name.should == "bar"
68
70
  end
69
71
  end
@@ -4,13 +4,13 @@ require File.dirname(__FILE__) + '/../../spec_helper'
4
4
 
5
5
  require 'puppet/network/formats'
6
6
 
7
- class JsonIntTest
7
+ class PsonIntTest
8
8
  attr_accessor :string
9
9
  def ==(other)
10
10
  other.class == self.class and string == other.string
11
11
  end
12
12
 
13
- def self.from_json(data)
13
+ def self.from_pson(data)
14
14
  new(data[0])
15
15
  end
16
16
 
@@ -18,15 +18,15 @@ class JsonIntTest
18
18
  @string = string
19
19
  end
20
20
 
21
- def to_json(*args)
21
+ def to_pson(*args)
22
22
  {
23
- 'json_class' => self.class.name,
23
+ 'type' => self.class.name,
24
24
  'data' => [@string]
25
- }.to_json(*args)
25
+ }.to_pson(*args)
26
26
  end
27
27
 
28
28
  def self.canonical_order(s)
29
- s.gsub(/\{"data":\[(.*?)\],"json_class":"JsonIntTest"\}/,'{"json_class":"JsonIntTest","data":[\1]}')
29
+ s.gsub(/\{"data":\[(.*?)\],"type":"PsonIntTest"\}/,'{"type":"PsonIntTest","data":[\1]}')
30
30
  end
31
31
 
32
32
  end
@@ -45,65 +45,65 @@ describe Puppet::Network::FormatHandler.format(:s) do
45
45
  end
46
46
  end
47
47
 
48
- describe Puppet::Network::FormatHandler.format(:json) do
49
- describe "when json is absent" do
50
- confine "'json' library is present" => (! Puppet.features.json?)
48
+ describe Puppet::Network::FormatHandler.format(:pson) do
49
+ describe "when pson is absent" do
50
+ confine "'pson' library is present" => (! Puppet.features.pson?)
51
51
 
52
52
  before do
53
- @json = Puppet::Network::FormatHandler.format(:json)
53
+ @pson = Puppet::Network::FormatHandler.format(:pson)
54
54
  end
55
55
 
56
56
  it "should not be suitable" do
57
- @json.should_not be_suitable
57
+ @pson.should_not be_suitable
58
58
  end
59
59
  end
60
60
 
61
- describe "when json is available" do
62
- confine "Missing 'json' library" => Puppet.features.json?
61
+ describe "when pson is available" do
62
+ confine "Missing 'pson' library" => Puppet.features.pson?
63
63
 
64
64
  before do
65
- @json = Puppet::Network::FormatHandler.format(:json)
65
+ @pson = Puppet::Network::FormatHandler.format(:pson)
66
66
  end
67
67
 
68
- it "should be able to render an instance to json" do
69
- instance = JsonIntTest.new("foo")
70
- JsonIntTest.canonical_order(@json.render(instance)).should == JsonIntTest.canonical_order('{"json_class":"JsonIntTest","data":["foo"]}' )
68
+ it "should be able to render an instance to pson" do
69
+ instance = PsonIntTest.new("foo")
70
+ PsonIntTest.canonical_order(@pson.render(instance)).should == PsonIntTest.canonical_order('{"type":"PsonIntTest","data":["foo"]}' )
71
71
  end
72
72
 
73
- it "should be able to render arrays to json" do
74
- @json.render([1,2]).should == '[1,2]'
73
+ it "should be able to render arrays to pson" do
74
+ @pson.render([1,2]).should == '[1,2]'
75
75
  end
76
76
 
77
- it "should be able to render arrays containing hashes to json" do
78
- @json.render([{"one"=>1},{"two"=>2}]).should == '[{"one":1},{"two":2}]'
77
+ it "should be able to render arrays containing hashes to pson" do
78
+ @pson.render([{"one"=>1},{"two"=>2}]).should == '[{"one":1},{"two":2}]'
79
79
  end
80
80
 
81
- it "should be able to render multiple instances to json" do
82
- Puppet.features.add(:json, :libs => ["json"])
81
+ it "should be able to render multiple instances to pson" do
82
+ Puppet.features.add(:pson, :libs => ["pson"])
83
83
 
84
- one = JsonIntTest.new("one")
85
- two = JsonIntTest.new("two")
84
+ one = PsonIntTest.new("one")
85
+ two = PsonIntTest.new("two")
86
86
 
87
- JsonIntTest.canonical_order(@json.render([one,two])).should == JsonIntTest.canonical_order('[{"json_class":"JsonIntTest","data":["one"]},{"json_class":"JsonIntTest","data":["two"]}]')
87
+ PsonIntTest.canonical_order(@pson.render([one,two])).should == PsonIntTest.canonical_order('[{"type":"PsonIntTest","data":["one"]},{"type":"PsonIntTest","data":["two"]}]')
88
88
  end
89
89
 
90
- it "should be able to intern json into an instance" do
91
- @json.intern(JsonIntTest, '{"json_class":"JsonIntTest","data":["foo"]}').should == JsonIntTest.new("foo")
90
+ it "should be able to intern pson into an instance" do
91
+ @pson.intern(PsonIntTest, '{"type":"PsonIntTest","data":["foo"]}').should == PsonIntTest.new("foo")
92
92
  end
93
93
 
94
- it "should be able to intern json with no class information into an instance" do
95
- @json.intern(JsonIntTest, '["foo"]').should == JsonIntTest.new("foo")
94
+ it "should be able to intern pson with no class information into an instance" do
95
+ @pson.intern(PsonIntTest, '["foo"]').should == PsonIntTest.new("foo")
96
96
  end
97
97
 
98
- it "should be able to intern multiple instances from json" do
99
- @json.intern_multiple(JsonIntTest, '[{"json_class": "JsonIntTest", "data": ["one"]},{"json_class": "JsonIntTest", "data": ["two"]}]').should == [
100
- JsonIntTest.new("one"), JsonIntTest.new("two")
98
+ it "should be able to intern multiple instances from pson" do
99
+ @pson.intern_multiple(PsonIntTest, '[{"type": "PsonIntTest", "data": ["one"]},{"type": "PsonIntTest", "data": ["two"]}]').should == [
100
+ PsonIntTest.new("one"), PsonIntTest.new("two")
101
101
  ]
102
102
  end
103
103
 
104
- it "should be able to intern multiple instances from json with no class information" do
105
- @json.intern_multiple(JsonIntTest, '[["one"],["two"]]').should == [
106
- JsonIntTest.new("one"), JsonIntTest.new("two")
104
+ it "should be able to intern multiple instances from pson with no class information" do
105
+ @pson.intern_multiple(PsonIntTest, '[["one"],["two"]]').should == [
106
+ PsonIntTest.new("one"), PsonIntTest.new("two")
107
107
  ]
108
108
  end
109
109
  end