summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-29 00:46:11 -0500
committerLuke Kanies <luke@madstop.com>2008-07-29 00:46:11 -0500
commit40375a8fc34dbd85d87f507ba72c7394b25b7271 (patch)
treeefd5a93980b042b73322bd31e6fdb41203d07576
parent93eeff59d807261ed154cc104e318ae604602430 (diff)
parent8f5800f0608dff46407cb5f23ee73f314fe051e8 (diff)
downloadpuppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.tar.gz
puppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.tar.xz
puppet-40375a8fc34dbd85d87f507ba72c7394b25b7271.zip
Merge branch '0.24.x' into merging
Conflicts: test/ral/type/filesources.rb
-rw-r--r--CHANGELOG36
-rwxr-xr-xbin/puppet2
-rw-r--r--conf/debian/README.source (renamed from debian/README.source)0
-rw-r--r--conf/debian/TODO.Debian (renamed from debian/TODO.Debian)0
-rw-r--r--conf/debian/changelog (renamed from debian/changelog)0
-rw-r--r--conf/debian/compat (renamed from debian/compat)0
-rw-r--r--conf/debian/control (renamed from debian/control)0
-rw-r--r--conf/debian/copyright (renamed from debian/copyright)0
-rw-r--r--conf/debian/docs (renamed from debian/docs)0
-rw-r--r--conf/debian/fileserver.conf (renamed from debian/fileserver.conf)0
-rw-r--r--conf/debian/puppet.NEWS (renamed from debian/puppet.NEWS)0
-rw-r--r--conf/debian/puppet.conf (renamed from debian/puppet.conf)0
-rw-r--r--conf/debian/puppet.dirs (renamed from debian/puppet.dirs)0
-rw-r--r--conf/debian/puppet.files (renamed from debian/puppet.files)0
-rw-r--r--conf/debian/puppet.init (renamed from debian/puppet.init)0
-rw-r--r--conf/debian/puppet.logrotate (renamed from debian/puppet.logrotate)0
-rw-r--r--conf/debian/puppet.postinst (renamed from debian/puppet.postinst)0
-rw-r--r--conf/debian/puppet.postrm (renamed from debian/puppet.postrm)0
-rw-r--r--conf/debian/puppet.preinst (renamed from debian/puppet.preinst)0
-rw-r--r--conf/debian/puppetmaster.files (renamed from debian/puppetmaster.files)0
-rw-r--r--conf/debian/puppetmaster.init (renamed from debian/puppetmaster.init)0
-rwxr-xr-xconf/debian/rules (renamed from debian/rules)0
-rw-r--r--conf/debian/watch (renamed from debian/watch)0
-rw-r--r--conf/redhat/client.init10
-rw-r--r--conf/redhat/server.init10
-rw-r--r--examples/allatonce (renamed from examples/code/allatonce)0
-rw-r--r--examples/assignments (renamed from examples/code/assignments)0
-rw-r--r--examples/components (renamed from examples/code/components)0
-rwxr-xr-xexamples/etc/init.d/sleeper (renamed from examples/root/etc/init.d/sleeper)0
-rw-r--r--examples/etc/otherfile (renamed from examples/root/etc/otherfile)0
-rw-r--r--examples/etc/puppet/fileserver.conf (renamed from examples/root/etc/puppet/fileserver.conf)0
-rw-r--r--examples/etc/puppet/namespaceauth.conf (renamed from examples/root/etc/puppet/namespaceauth.conf)0
-rw-r--r--examples/etc/puppet/puppet.conf (renamed from examples/root/etc/puppet/puppet.conf)0
-rw-r--r--examples/etc/puppet/tagmail.conf (renamed from examples/root/etc/puppet/tagmail.conf)0
-rw-r--r--examples/execs (renamed from examples/code/execs)0
-rw-r--r--examples/file.bl (renamed from examples/code/file.bl)0
-rw-r--r--examples/filedefaults (renamed from examples/code/filedefaults)0
-rw-r--r--examples/fileparsing (renamed from examples/code/fileparsing)0
-rw-r--r--examples/filerecursion (renamed from examples/code/filerecursion)0
-rw-r--r--examples/functions (renamed from examples/code/functions)0
-rw-r--r--examples/groups (renamed from examples/code/groups)0
-rw-r--r--examples/head (renamed from examples/code/head)0
-rw-r--r--examples/importing (renamed from examples/code/importing)0
-rw-r--r--examples/mac_automount.pp (renamed from examples/code/mac_automount.pp)0
-rwxr-xr-xexamples/mac_dscl.pp (renamed from examples/code/mac_dscl.pp)0
-rwxr-xr-xexamples/mac_dscl_revert.pp (renamed from examples/code/mac_dscl_revert.pp)0
-rwxr-xr-xexamples/mac_netinfo.pp (renamed from examples/code/mac_netinfo.pp)0
-rwxr-xr-xexamples/mac_pkgdmg.pp (renamed from examples/code/mac_pkgdmg.pp)0
-rw-r--r--examples/modules/sample-module.pp (renamed from examples/code/modules/sample-module.pp)0
-rw-r--r--examples/modules/sample-module/README.txt (renamed from examples/code/modules/sample-module/README.txt)0
-rw-r--r--examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb (renamed from examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb)0
-rw-r--r--examples/modules/sample-module/manifests/init.pp (renamed from examples/code/modules/sample-module/manifests/init.pp)0
-rw-r--r--examples/modules/sample-module/templates/sample.erb (renamed from examples/code/modules/sample-module/templates/sample.erb)0
-rw-r--r--examples/nodes (renamed from examples/code/nodes)0
-rw-r--r--examples/one (renamed from examples/code/one)0
-rw-r--r--examples/relationships (renamed from examples/code/relationships)0
-rw-r--r--examples/root/etc/configfile0
-rw-r--r--examples/root/etc/debian-passwd29
-rw-r--r--examples/root/etc/debian-syslog.conf71
-rw-r--r--examples/selectors (renamed from examples/code/selectors)0
-rw-r--r--examples/simpletests (renamed from examples/code/simpletests)0
-rw-r--r--examples/svncommit (renamed from examples/code/svncommit)0
-rwxr-xr-xext/bin/sleeper (renamed from examples/root/bin/sleeper)0
-rwxr-xr-xext/module_puppet2
-rw-r--r--lib/puppet/defaults.rb5
-rw-r--r--lib/puppet/file_serving/terminus_helper.rb8
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb2
-rw-r--r--lib/puppet/indirector/direct_file_server.rb2
-rw-r--r--lib/puppet/indirector/file_server.rb28
-rw-r--r--lib/puppet/indirector/module_files.rb28
-rw-r--r--lib/puppet/indirector/node/exec.rb7
-rw-r--r--lib/puppet/network/client/master.rb15
-rw-r--r--lib/puppet/network/handler/master.rb14
-rw-r--r--lib/puppet/network/http.rb14
-rwxr-xr-xlib/puppet/provider/service/redhat.rb16
-rw-r--r--lib/puppet/provider/ssh_authorized_key/parsed.rb36
-rw-r--r--lib/puppet/sslcertificates/support.rb4
-rwxr-xr-xlib/puppet/type/file/source.rb3
-rwxr-xr-xlib/puppet/type/group.rb2
-rw-r--r--lib/puppet/type/ssh_authorized_key.rb26
-rw-r--r--lib/puppet/util.rb2
-rwxr-xr-xspec/integration/defaults.rb4
-rwxr-xr-xspec/integration/file_serving/metadata.rb1
-rwxr-xr-xspec/integration/indirector/module_files.rb8
-rwxr-xr-xspec/integration/node/catalog.rb10
-rw-r--r--spec/shared_behaviours/file_server_terminus.rb4
-rw-r--r--spec/shared_behaviours/file_serving.rb22
-rwxr-xr-xspec/unit/file_serving/terminus_helper.rb94
-rwxr-xr-xspec/unit/indirector/catalog/compiler.rb8
-rwxr-xr-xspec/unit/indirector/direct_file_server.rb13
-rwxr-xr-xspec/unit/indirector/file_metadata/modules.rb6
-rwxr-xr-xspec/unit/indirector/file_server.rb104
-rwxr-xr-xspec/unit/indirector/module_files.rb86
-rwxr-xr-xspec/unit/indirector/node/exec.rb6
-rwxr-xr-xspec/unit/module.rb4
-rwxr-xr-xspec/unit/network/client/master.rb96
-rwxr-xr-xspec/unit/network/http.rb12
-rwxr-xr-xspec/unit/network/http/mongrel.rb10
-rwxr-xr-xspec/unit/network/http/mongrel/rest.rb16
-rwxr-xr-xspec/unit/network/http/webrick.rb1
-rwxr-xr-xspec/unit/network/http/webrick/rest.rb1
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed.rb21
-rwxr-xr-xspec/unit/rails.rb2
-rwxr-xr-xspec/unit/type/file.rb5
-rwxr-xr-xspec/unit/type/group.rb40
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb41
-rwxr-xr-xtest/certmgr/support.rb43
-rw-r--r--test/lib/puppettest/runnable_test.rb3
-rwxr-xr-xtest/network/handler/master.rb34
-rwxr-xr-xtest/other/provider.rb45
-rwxr-xr-xtest/ral/type/filesources.rb117
111 files changed, 724 insertions, 505 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c0934b351..8b2bd3349 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,7 +8,39 @@
set file paths to 'false' to disable the CRL.
0.24.5
- Added message referencing ReductveLabs build library
+ You can now select the encoding format when transferring the catalog,
+ with 'yaml' still being the default but 'marshal' being an option.
+ This is because testing has shown drastic performance differences
+ between the two, with up to 70% of compile time being spent
+ in YAML code. Use the 'catalog_format' setting to choose your format,
+ and the setting must be set on the client.
+
+ Fixed #1431 - Provider confines must now specify similar tests in one call.
+ I.e., you can't do confine :operatingsystem => %w{a b} and then
+ confine :operatingsystem => %w{b c}; you'd need to do them in one command.
+ This now-obsolete behaviour does not seem to be used anywhere.
+ The fix for #1431 is actually just removing the tests that exposed
+ this change; the change happened when I refactored how confines work.
+
+ Updated /spec/unit/rails.rb test
+
+ Fix #1426 - services on redhat are restarted again and status is
+ called from the Red Hat provider
+
+ Fixed #1414 - Return code from waitpid now right shifted 8 bits
+
+ Fixed #174 - a native type type for managing ssh authorized_keys
+ files is available.
+
+ Further moves from the examples directory and ext directory
+
+ Fixed #1397 One line fix, fail instead of log
+
+ Moved debian to conf and updated examples directory
+
+ Fixed #1368 - updated Red Hat init scripts
+
+ Added message referencing ReductiveLabs build library
Fixed #1396 - Added sha1 function from DavidS to core
@@ -62,8 +94,6 @@
but external nodes just use the certificate name and any custom terminus
types will use just the certificate name.
- Fixed #1201 - all external node attributes are converted to strings.
-
Fixing #1168 (for 0.24.x) -- automatically downcasing the fqdn.
Also requiring that passed in certnames be downcased; the setting
system isn't currently flexible enough to automatically downcase
diff --git a/bin/puppet b/bin/puppet
index 530766800..0e64b1cf3 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -207,7 +207,7 @@ end
begin
# Compile our catalog
- catalog = Puppet::Node::Catalog.find(node.name, :node => node)
+ catalog = Puppet::Node::Catalog.find(node.name, :use_node => node)
# Translate it to a RAL catalog
catalog = catalog.to_ral
diff --git a/debian/README.source b/conf/debian/README.source
index fd9155241..fd9155241 100644
--- a/debian/README.source
+++ b/conf/debian/README.source
diff --git a/debian/TODO.Debian b/conf/debian/TODO.Debian
index ac70b97be..ac70b97be 100644
--- a/debian/TODO.Debian
+++ b/conf/debian/TODO.Debian
diff --git a/debian/changelog b/conf/debian/changelog
index 69984d622..69984d622 100644
--- a/debian/changelog
+++ b/conf/debian/changelog
diff --git a/debian/compat b/conf/debian/compat
index b8626c4cf..b8626c4cf 100644
--- a/debian/compat
+++ b/conf/debian/compat
diff --git a/debian/control b/conf/debian/control
index 8b0e92e7e..8b0e92e7e 100644
--- a/debian/control
+++ b/conf/debian/control
diff --git a/debian/copyright b/conf/debian/copyright
index 06bdcab30..06bdcab30 100644
--- a/debian/copyright
+++ b/conf/debian/copyright
diff --git a/debian/docs b/conf/debian/docs
index e845566c0..e845566c0 100644
--- a/debian/docs
+++ b/conf/debian/docs
diff --git a/debian/fileserver.conf b/conf/debian/fileserver.conf
index 04a51c080..04a51c080 100644
--- a/debian/fileserver.conf
+++ b/conf/debian/fileserver.conf
diff --git a/debian/puppet.NEWS b/conf/debian/puppet.NEWS
index a712aafd4..a712aafd4 100644
--- a/debian/puppet.NEWS
+++ b/conf/debian/puppet.NEWS
diff --git a/debian/puppet.conf b/conf/debian/puppet.conf
index c541c748a..c541c748a 100644
--- a/debian/puppet.conf
+++ b/conf/debian/puppet.conf
diff --git a/debian/puppet.dirs b/conf/debian/puppet.dirs
index 9ce18f88e..9ce18f88e 100644
--- a/debian/puppet.dirs
+++ b/conf/debian/puppet.dirs
diff --git a/debian/puppet.files b/conf/debian/puppet.files
index d92ac32e9..d92ac32e9 100644
--- a/debian/puppet.files
+++ b/conf/debian/puppet.files
diff --git a/debian/puppet.init b/conf/debian/puppet.init
index 063f9273f..063f9273f 100644
--- a/debian/puppet.init
+++ b/conf/debian/puppet.init
diff --git a/debian/puppet.logrotate b/conf/debian/puppet.logrotate
index 3864e396d..3864e396d 100644
--- a/debian/puppet.logrotate
+++ b/conf/debian/puppet.logrotate
diff --git a/debian/puppet.postinst b/conf/debian/puppet.postinst
index ac765ba85..ac765ba85 100644
--- a/debian/puppet.postinst
+++ b/conf/debian/puppet.postinst
diff --git a/debian/puppet.postrm b/conf/debian/puppet.postrm
index da994c3c3..da994c3c3 100644
--- a/debian/puppet.postrm
+++ b/conf/debian/puppet.postrm
diff --git a/debian/puppet.preinst b/conf/debian/puppet.preinst
index ce8e76083..ce8e76083 100644
--- a/debian/puppet.preinst
+++ b/conf/debian/puppet.preinst
diff --git a/debian/puppetmaster.files b/conf/debian/puppetmaster.files
index 15bc694b1..15bc694b1 100644
--- a/debian/puppetmaster.files
+++ b/conf/debian/puppetmaster.files
diff --git a/debian/puppetmaster.init b/conf/debian/puppetmaster.init
index ea5c1bafb..ea5c1bafb 100644
--- a/debian/puppetmaster.init
+++ b/conf/debian/puppetmaster.init
diff --git a/debian/rules b/conf/debian/rules
index ecabcbad0..ecabcbad0 100755
--- a/debian/rules
+++ b/conf/debian/rules
diff --git a/debian/watch b/conf/debian/watch
index 29d439f6d..29d439f6d 100644
--- a/debian/watch
+++ b/conf/debian/watch
diff --git a/conf/redhat/client.init b/conf/redhat/client.init
index b77bd017a..c3cb91e90 100644
--- a/conf/redhat/client.init
+++ b/conf/redhat/client.init
@@ -62,6 +62,11 @@ restart() {
start
}
+genconfig() {
+ echo -n $"Generate configuration puppet: "
+ $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --genconfig
+}
+
case "$1" in
start)
start
@@ -86,8 +91,11 @@ case "$1" in
shift
$puppetd -o ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} $@
;;
+ genconfig)
+ genconfig
+ ;;
*)
- echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once}"
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once|genconfig}"
exit 1
esac
diff --git a/conf/redhat/server.init b/conf/redhat/server.init
index b64622140..8266977de 100644
--- a/conf/redhat/server.init
+++ b/conf/redhat/server.init
@@ -62,6 +62,11 @@ restart() {
start
}
+genconfig() {
+ echo -n $"Generate configuration puppetmaster: "
+ $PUPPETMASTER $PUPPETMASTER_OPTS --genconfig
+}
+
case "$1" in
start)
start
@@ -79,8 +84,11 @@ case "$1" in
status $PUPPETMASTER
RETVAL=$?
;;
+ genconfig)
+ genconfig
+ ;;
*)
- echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|genconfig}"
exit 1
esac
diff --git a/examples/code/allatonce b/examples/allatonce
index 8912ec4e7..8912ec4e7 100644
--- a/examples/code/allatonce
+++ b/examples/allatonce
diff --git a/examples/code/assignments b/examples/assignments
index 3edcef84e..3edcef84e 100644
--- a/examples/code/assignments
+++ b/examples/assignments
diff --git a/examples/code/components b/examples/components
index 3da43c571..3da43c571 100644
--- a/examples/code/components
+++ b/examples/components
diff --git a/examples/root/etc/init.d/sleeper b/examples/etc/init.d/sleeper
index 6da5eae32..6da5eae32 100755
--- a/examples/root/etc/init.d/sleeper
+++ b/examples/etc/init.d/sleeper
diff --git a/examples/root/etc/otherfile b/examples/etc/otherfile
index e69de29bb..e69de29bb 100644
--- a/examples/root/etc/otherfile
+++ b/examples/etc/otherfile
diff --git a/examples/root/etc/puppet/fileserver.conf b/examples/etc/puppet/fileserver.conf
index 32dfcdd5c..32dfcdd5c 100644
--- a/examples/root/etc/puppet/fileserver.conf
+++ b/examples/etc/puppet/fileserver.conf
diff --git a/examples/root/etc/puppet/namespaceauth.conf b/examples/etc/puppet/namespaceauth.conf
index fb08d428b..fb08d428b 100644
--- a/examples/root/etc/puppet/namespaceauth.conf
+++ b/examples/etc/puppet/namespaceauth.conf
diff --git a/examples/root/etc/puppet/puppet.conf b/examples/etc/puppet/puppet.conf
index 151364ebd..151364ebd 100644
--- a/examples/root/etc/puppet/puppet.conf
+++ b/examples/etc/puppet/puppet.conf
diff --git a/examples/root/etc/puppet/tagmail.conf b/examples/etc/puppet/tagmail.conf
index 31c77f4bc..31c77f4bc 100644
--- a/examples/root/etc/puppet/tagmail.conf
+++ b/examples/etc/puppet/tagmail.conf
diff --git a/examples/code/execs b/examples/execs
index 44f133098..44f133098 100644
--- a/examples/code/execs
+++ b/examples/execs
diff --git a/examples/code/file.bl b/examples/file.bl
index ef46ba223..ef46ba223 100644
--- a/examples/code/file.bl
+++ b/examples/file.bl
diff --git a/examples/code/filedefaults b/examples/filedefaults
index 56cf76a9a..56cf76a9a 100644
--- a/examples/code/filedefaults
+++ b/examples/filedefaults
diff --git a/examples/code/fileparsing b/examples/fileparsing
index f9766b9f6..f9766b9f6 100644
--- a/examples/code/fileparsing
+++ b/examples/fileparsing
diff --git a/examples/code/filerecursion b/examples/filerecursion
index b7d8278c2..b7d8278c2 100644
--- a/examples/code/filerecursion
+++ b/examples/filerecursion
diff --git a/examples/code/functions b/examples/functions
index 8e95c3a72..8e95c3a72 100644
--- a/examples/code/functions
+++ b/examples/functions
diff --git a/examples/code/groups b/examples/groups
index 35505a2eb..35505a2eb 100644
--- a/examples/code/groups
+++ b/examples/groups
diff --git a/examples/code/head b/examples/head
index 59cbb6593..59cbb6593 100644
--- a/examples/code/head
+++ b/examples/head
diff --git a/examples/code/importing b/examples/importing
index f02604109..f02604109 100644
--- a/examples/code/importing
+++ b/examples/importing
diff --git a/examples/code/mac_automount.pp b/examples/mac_automount.pp
index bab0136fc..bab0136fc 100644
--- a/examples/code/mac_automount.pp
+++ b/examples/mac_automount.pp
diff --git a/examples/code/mac_dscl.pp b/examples/mac_dscl.pp
index ff59f9d8d..ff59f9d8d 100755
--- a/examples/code/mac_dscl.pp
+++ b/examples/mac_dscl.pp
diff --git a/examples/code/mac_dscl_revert.pp b/examples/mac_dscl_revert.pp
index c9bd2b541..c9bd2b541 100755
--- a/examples/code/mac_dscl_revert.pp
+++ b/examples/mac_dscl_revert.pp
diff --git a/examples/code/mac_netinfo.pp b/examples/mac_netinfo.pp
index 544b64818..544b64818 100755
--- a/examples/code/mac_netinfo.pp
+++ b/examples/mac_netinfo.pp
diff --git a/examples/code/mac_pkgdmg.pp b/examples/mac_pkgdmg.pp
index a2499e815..a2499e815 100755
--- a/examples/code/mac_pkgdmg.pp
+++ b/examples/mac_pkgdmg.pp
diff --git a/examples/code/modules/sample-module.pp b/examples/modules/sample-module.pp
index 57079a0aa..57079a0aa 100644
--- a/examples/code/modules/sample-module.pp
+++ b/examples/modules/sample-module.pp
diff --git a/examples/code/modules/sample-module/README.txt b/examples/modules/sample-module/README.txt
index ee4b8201a..ee4b8201a 100644
--- a/examples/code/modules/sample-module/README.txt
+++ b/examples/modules/sample-module/README.txt
diff --git a/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb
index 9f732b5bc..9f732b5bc 100644
--- a/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb
+++ b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb
diff --git a/examples/code/modules/sample-module/manifests/init.pp b/examples/modules/sample-module/manifests/init.pp
index 1af8dff1f..1af8dff1f 100644
--- a/examples/code/modules/sample-module/manifests/init.pp
+++ b/examples/modules/sample-module/manifests/init.pp
diff --git a/examples/code/modules/sample-module/templates/sample.erb b/examples/modules/sample-module/templates/sample.erb
index b13561b45..b13561b45 100644
--- a/examples/code/modules/sample-module/templates/sample.erb
+++ b/examples/modules/sample-module/templates/sample.erb
diff --git a/examples/code/nodes b/examples/nodes
index 42488e689..42488e689 100644
--- a/examples/code/nodes
+++ b/examples/nodes
diff --git a/examples/code/one b/examples/one
index 452d32f3e..452d32f3e 100644
--- a/examples/code/one
+++ b/examples/one
diff --git a/examples/code/relationships b/examples/relationships
index 795788947..795788947 100644
--- a/examples/code/relationships
+++ b/examples/relationships
diff --git a/examples/root/etc/configfile b/examples/root/etc/configfile
deleted file mode 100644
index e69de29bb..000000000
--- a/examples/root/etc/configfile
+++ /dev/null
diff --git a/examples/root/etc/debian-passwd b/examples/root/etc/debian-passwd
deleted file mode 100644
index 59cdf4acf..000000000
--- a/examples/root/etc/debian-passwd
+++ /dev/null
@@ -1,29 +0,0 @@
-root:x:0:0:root:/root:/bin/bash
-daemon:x:1:1:daemon:/usr/sbin:/bin/sh
-bin:x:2:2:bin:/bin:/bin/sh
-sys:x:3:3:sys:/dev:/bin/sh
-sync:x:4:65534:sync:/bin:/bin/sync
-games:x:5:60:games:/usr/games:/bin/sh
-man:x:6:12:man:/var/cache/man:/bin/sh
-lp:x:7:7:lp:/var/spool/lpd:/bin/sh
-mail:x:8:8:mail:/var/mail:/bin/sh
-news:x:9:9:news:/var/spool/news:/bin/sh
-uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
-proxy:x:13:13:proxy:/bin:/bin/sh
-postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh
-www-data:x:33:33:www-data:/var/www:/bin/sh
-backup:x:34:34:backup:/var/backups:/bin/sh
-operator:x:37:37:Operator:/var:/bin/sh
-list:x:38:38:Mailing List Manager:/var/list:/bin/sh
-irc:x:39:39:ircd:/var/run/ircd:/bin/sh
-gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
-nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
-sshd:x:102:65534::/var/run/sshd:/bin/false
-gdm:x:101:101:Gnome Display Manager:/var/lib/gdm:/bin/false
-telnetd:x:103:103::/usr/lib/telnetd:/bin/false
-nagios:x:1000:1001::/home/nagios:
-messagebus:x:104:107::/var/run/dbus:/bin/false
-saned:x:109:109::/home/saned:/bin/false
-ganglia:x:105:110:Ganglia Monitor:/var/lib/ganglia:/bin/false
-zope:x:106:111::/var/lib/zope2.7/var:/bin/false
-fbgetty:x:112:112::/home/fbgetty:/bin/false
diff --git a/examples/root/etc/debian-syslog.conf b/examples/root/etc/debian-syslog.conf
deleted file mode 100644
index 8f2925960..000000000
--- a/examples/root/etc/debian-syslog.conf
+++ /dev/null
@@ -1,71 +0,0 @@
-# /etc/syslog.conf Configuration file for syslogd.
-#
-# For more information see syslog.conf(5)
-# manpage.
-
-#
-# First some standard logfiles. Log by facility.
-#
-
-auth,authpriv.* /var/log/auth.log
-*.*;auth,authpriv.none -/var/log/syslog
-#cron.* /var/log/cron.log
-daemon.* -/var/log/daemon.log
-kern.* -/var/log/kern.log
-lpr.* -/var/log/lpr.log
-mail.* -/var/log/mail.log
-user.* -/var/log/user.log
-uucp.* /var/log/uucp.log
-
-#
-# Logging for the mail system. Split it up so that
-# it is easy to write scripts to parse these files.
-#
-mail.info -/var/log/mail.info
-mail.warn -/var/log/mail.warn
-mail.err /var/log/mail.err
-
-# Logging for INN news system
-#
-news.crit /var/log/news/news.crit
-news.err /var/log/news/news.err
-news.notice -/var/log/news/news.notice
-
-#
-# Some `catch-all' logfiles.
-#
-*.=debug;\
- auth,authpriv.none;\
- news.none;mail.none -/var/log/debug
-*.=info;*.=notice;*.=warn;\
- auth,authpriv.none;\
- cron,daemon.none;\
- mail,news.none -/var/log/messages
-
-#
-# Emergencies are sent to everybody logged in.
-#
-*.emerg *
-
-#
-# I like to have messages displayed on the console, but only on a virtual
-# console I usually leave idle.
-#
-#daemon,mail.*;\
-# news.=crit;news.=err;news.=notice;\
-# *.=debug;*.=info;\
-# *.=notice;*.=warn /dev/tty8
-
-# The named pipe /dev/xconsole is for the `xconsole' utility. To use it,
-# you must invoke `xconsole' with the `-file' option:
-#
-# $ xconsole -file /dev/xconsole [...]
-#
-# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
-# busy site..
-#
-daemon.*;mail.*;\
- news.crit;news.err;news.notice;\
- *.=debug;*.=info;\
- *.=notice;*.=warn |/dev/xconsole
-
diff --git a/examples/code/selectors b/examples/selectors
index a70399bc7..a70399bc7 100644
--- a/examples/code/selectors
+++ b/examples/selectors
diff --git a/examples/code/simpletests b/examples/simpletests
index b4fd3234e..b4fd3234e 100644
--- a/examples/code/simpletests
+++ b/examples/simpletests
diff --git a/examples/code/svncommit b/examples/svncommit
index 350cd8580..350cd8580 100644
--- a/examples/code/svncommit
+++ b/examples/svncommit
diff --git a/examples/root/bin/sleeper b/ext/bin/sleeper
index 980d66ac1..980d66ac1 100755
--- a/examples/root/bin/sleeper
+++ b/ext/bin/sleeper
diff --git a/ext/module_puppet b/ext/module_puppet
index 978d660cc..8609e4411 100755
--- a/ext/module_puppet
+++ b/ext/module_puppet
@@ -180,7 +180,7 @@ node.classes = classes
begin
# Compile our configuration
- catalog = Puppet::Node::Catalog.find(node.name, :node => node)
+ catalog = Puppet::Node::Catalog.find(node.name, :use_node => node)
rescue => detail
if Puppet[:trace]
puts detail.backtrace
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index fce928ce5..7c57dcd6d 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -427,7 +427,10 @@ module Puppet
:ca_server => ["$server", "The server to use for certificate
authority requests. It's a separate server because it cannot
and does not need to horizontally scale."],
- :ca_port => ["$masterport", "The port to use for the certificate authority."]
+ :ca_port => ["$masterport", "The port to use for the certificate authority."],
+ :catalog_format => ["yaml", "What format to use to dump the catalog. Only supports
+ 'marshal' and 'yaml'. Only matters on the client, since it asks the server
+ for a specific format."]
)
self.setdefaults(:filebucket,
diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb
index d465aa493..e5da0e29f 100644
--- a/lib/puppet/file_serving/terminus_helper.rb
+++ b/lib/puppet/file_serving/terminus_helper.rb
@@ -8,11 +8,11 @@ require 'puppet/file_serving/fileset'
# Define some common methods for FileServing termini.
module Puppet::FileServing::TerminusHelper
# Create model instances for all files in a fileset.
- def path2instances(key, path, options = {})
- args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = options[param] if options[param]; hash }
+ def path2instances(request, path)
+ args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = request.options[param] if request.options[param]; hash }
Puppet::FileServing::Fileset.new(path, args).files.collect do |file|
- inst = model.new(File.join(key, file), :path => path, :relative_path => file)
- inst.links = options[:links] if options[:links]
+ inst = model.new(File.join(request.key, file), :path => path, :relative_path => file)
+ inst.links = request.options[:links] if request.options[:links]
inst
end
end
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 455a92cc7..a6a812817 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -14,7 +14,7 @@ class Puppet::Node::Catalog::Compiler < Puppet::Indirector::Code
# Compile a node's catalog.
def find(request)
- unless node = request.options[:node] || find_node(request.key)
+ unless node = request.options[:use_node] || find_node(request.key)
raise ArgumentError, "Could not find node '%s'; cannot compile" % request.key
end
diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb
index 1711356f9..b3b4886f3 100644
--- a/lib/puppet/indirector/direct_file_server.rb
+++ b/lib/puppet/indirector/direct_file_server.rb
@@ -22,6 +22,6 @@ class Puppet::Indirector::DirectFileServer < Puppet::Indirector::Terminus
def search(request)
uri = key2uri(request.key)
return nil unless FileTest.exists?(uri.path)
- path2instances(request.key, uri.path, request.options)
+ path2instances(request, uri.path)
end
end
diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb
index 2eb323d46..b0df7ff5d 100644
--- a/lib/puppet/indirector/file_server.rb
+++ b/lib/puppet/indirector/file_server.rb
@@ -14,28 +14,28 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
include Puppet::FileServing::TerminusHelper
# Is the client authorized to perform this action?
- def authorized?(method, key, options = {})
- return false unless [:find, :search].include?(method)
+ def authorized?(request)
+ return false unless [:find, :search].include?(request.method)
- uri = key2uri(key)
+ uri = key2uri(request.key)
- configuration.authorized?(uri.path, :node => options[:node], :ipaddress => options[:ipaddress])
+ configuration.authorized?(uri.path, :node => request.node, :ipaddress => request.ip)
end
# Find our key using the fileserver.
- def find(key, options = {})
- return nil unless path = find_path(key, options)
- result = model.new(key, :path => path)
- result.links = options[:links] if options[:links]
+ def find(request)
+ return nil unless path = find_path(request)
+ result = model.new(request.key, :path => path)
+ result.links = request.options[:links] if request.options[:links]
return result
end
# Search for files. This returns an array rather than a single
# file.
- def search(key, options = {})
- return nil unless path = find_path(key, options)
+ def search(request)
+ return nil unless path = find_path(request)
- path2instances(key, path, options)
+ path2instances(request, path)
end
private
@@ -46,10 +46,10 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
end
# Find our path; used by :find and :search.
- def find_path(key, options)
- uri = key2uri(key)
+ def find_path(request)
+ uri = key2uri(request.key)
- return nil unless path = configuration.file_path(uri.path, :node => options[:node])
+ return nil unless path = configuration.file_path(uri.path, :node => request.node)
return path
end
diff --git a/lib/puppet/indirector/module_files.rb b/lib/puppet/indirector/module_files.rb
index 84286d8a5..cf5c29cab 100644
--- a/lib/puppet/indirector/module_files.rb
+++ b/lib/puppet/indirector/module_files.rb
@@ -14,24 +14,24 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus
include Puppet::FileServing::TerminusHelper
# Is the client allowed access to this key with this method?
- def authorized?(method, key, options = {})
- return false unless [:find, :search].include?(method)
+ def authorized?(request)
+ return false unless [:find, :search].include?(request.method)
- uri = key2uri(key)
+ uri = key2uri(request.key)
# Make sure our file path starts with /modules, so that we authorize
# against the 'modules' mount.
path = uri.path =~ /^\/modules/ ? uri.path : "/modules" + uri.path
- configuration.authorized?(path, :node => options[:node], :ipaddress => options[:ipaddress])
+ configuration.authorized?(path, :node => request.node, :ipaddress => request.ip)
end
# Find our key in a module.
- def find(key, options = {})
- return nil unless path = find_path(key, options)
+ def find(request)
+ return nil unless path = find_path(request)
- result = model.new(key, :path => path)
- result.links = options[:links] if options[:links]
+ result = model.new(request.key, :path => path)
+ result.links = request.options[:links] if request.options[:links]
return result
end
@@ -41,9 +41,9 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus
end
# Search for a list of files.
- def search(key, options = {})
- return nil unless path = find_path(key, options)
- path2instances(key, path, options)
+ def search(request)
+ return nil unless path = find_path(request)
+ path2instances(request, path)
end
private
@@ -63,15 +63,15 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus
end
# The abstracted method for turning a key into a path; used by both :find and :search.
- def find_path(key, options)
- uri = key2uri(key)
+ def find_path(request)
+ uri = key2uri(request.key)
# Strip off /modules if it's there -- that's how requests get routed to this terminus.
# Also, strip off the leading slash if present.
module_name, relative_path = uri.path.sub(/^\/modules\b/, '').sub(%r{^/}, '').split(File::Separator, 2)
# And use the environment to look up the module.
- return nil unless mod = find_module(module_name, options[:node])
+ return nil unless mod = find_module(module_name, request.node)
path = File.join(mod.files, relative_path)
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb
index 029a35c4f..52cbc370c 100644
--- a/lib/puppet/indirector/node/exec.rb
+++ b/lib/puppet/indirector/node/exec.rb
@@ -30,13 +30,6 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
def create_node(name, result)
node = Puppet::Node.new(name)
set = false
- if current = result[:parameters]
- result[:parameters] = current.inject({}) do |strings, ary|
- param, value = ary
- strings[param] = value.to_s
- strings
- end
- end
[:parameters, :classes, :environment].each do |param|
if value = result[param]
node.send(param.to_s + "=", value)
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 26eff52a0..d401cd393 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -142,15 +142,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# If we can't retrieve the catalog, just return, which will either
# fail, or use the in-memory catalog.
- unless yaml_objects = get_actual_config(facts)
+ unless marshalled_objects = get_actual_config(facts)
use_cached_config(true)
return
end
begin
- objects = YAML.load(yaml_objects)
+ case Puppet[:catalog_format]
+ when "marshal": objects = Marshal.load(marshalled_objects)
+ when "yaml": objects = YAML.load(marshalled_objects)
+ else
+ raise "Invalid catalog format '%s'" % Puppet[:catalog_format]
+ end
rescue => detail
- msg = "Configuration could not be translated from yaml"
+ msg = "Configuration could not be translated from %s" % Puppet[:catalog_format]
msg += "; using cached catalog" if use_cached_config(true)
Puppet.warning msg
return
@@ -174,7 +179,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
if ! @catalog.from_cache
- self.cache(yaml_objects)
+ self.cache(marshalled_objects)
end
# Keep the state database up to date.
@@ -441,7 +446,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
benchmark(:debug, "Retrieved catalog") do
# error handling for this is done in the network client
begin
- textobjects = @driver.getconfig(textfacts, "yaml")
+ textobjects = @driver.getconfig(textfacts, Puppet[:catalog_format])
begin
textobjects = CGI.unescape(textobjects)
rescue => detail
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index a050b089b..9682c460e 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -64,7 +64,14 @@ class Puppet::Network::Handler
catalog = Puppet::Node::Catalog.find(client)
- return translate(catalog.extract)
+ case format
+ when "yaml":
+ return CGI.escape(catalog.extract.to_yaml(:UseBlock => true))
+ when "marshal":
+ return CGI.escape(Marshal.dump(catalog.extract))
+ else
+ raise "Invalid markup format '%s'" % format
+ end
end
#
@@ -90,11 +97,6 @@ class Puppet::Network::Handler
# Translate our configuration appropriately for sending back to a client.
def translate(config)
- if local?
- config
- else
- CGI.escape(config.to_yaml(:UseBlock => true))
- end
end
end
end
diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb
index 062c67c71..c219859b6 100644
--- a/lib/puppet/network/http.rb
+++ b/lib/puppet/network/http.rb
@@ -1,13 +1,15 @@
class Puppet::Network::HTTP
def self.server_class_by_type(kind)
- return Puppet::Network::HTTP::WEBrick if kind.to_sym == :webrick
- if kind.to_sym == :mongrel
+ case kind.to_sym
+ when :webrick:
+ require 'puppet/network/http/webrick'
+ return Puppet::Network::HTTP::WEBrick
+ when :mongrel:
raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel?
+ require 'puppet/network/http/mongrel'
return Puppet::Network::HTTP::Mongrel
+ else
+ raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
- raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
end
-
-require 'puppet/network/http/webrick'
-require 'puppet/network/http/mongrel'
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb
index e2d6ac947..3fad8bcfe 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -50,10 +50,22 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do
end
def restart
- if @resource[:hasrestart] == true
+ if @resource[:hasrestart] == :true
service(@resource[:name], "restart")
else
- return false
+ super
+ end
+ end
+
+ def status
+ if @resource[:hasstatus] == :true
+ begin
+ service(@resource[:name], "status")
+ rescue
+ return :stopped
+ end
+ else
+ super
end
end
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index 351ebcd1b..3bd22c06b 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -29,5 +29,41 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
record[:options] = record[:options].join(',')
end
}
+
+ def prefetch
+ # This was done in the type class but path expansion was failing for
+ # not yet existing users, the only workaround I found was to move that
+ # in the provider.
+ if user = @resource.should(:user)
+ target = File.expand_path("~%s/.ssh/authorized_keys" % user)
+ @property_hash[:target] = target
+ @resource[:target] = target
+ end
+
+ super
+ end
+
+ def flush
+ # As path expansion had to be moved in the provider, we cannot generate new file
+ # resources and thus have to chown and chmod here. It smells hackish.
+
+ # Create target's parent directory if nonexistant
+ if target = @property_hash[:target]
+ dir = File.dirname(@property_hash[:target])
+ if not File.exist? dir
+ Puppet.debug("Creating directory %s which did not exist" % dir)
+ Dir.mkdir(dir, 0700)
+ end
+ end
+
+ # Generate the file
+ super
+
+ # Ensure correct permissions
+ if target and user = @property_hash[:user]
+ File.chown(Puppet::Util.uid(user), nil, dir)
+ File.chown(Puppet::Util.uid(user), nil, @property_hash[:target])
+ end
+ end
end
diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb
index 95f15f0a8..d95944adc 100644
--- a/lib/puppet/sslcertificates/support.rb
+++ b/lib/puppet/sslcertificates/support.rb
@@ -128,6 +128,10 @@ module Puppet::SSLCertificates::Support
def rename_files_with_uppercase(file)
dir = File.dirname(file)
short = File.basename(file)
+
+ # If the dir isn't present, we clearly don't have the file.
+ #return nil unless FileTest.directory?(dir)
+
raise ArgumentError, "Tried to fix SSL files to a file containing uppercase" unless short.downcase == short
real_file = Dir.entries(dir).reject { |f| f =~ /^\./ }.find do |other|
other.downcase == short
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index f2704abb6..2514d3d1e 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -101,8 +101,7 @@ module Puppet
begin
desc = server.describe(path, @resource[:links])
rescue Puppet::Network::XMLRPCClientError => detail
- self.err "Could not describe %s: %s" % [path, detail]
- return nil
+ fail detail, "Could not describe %s: %s" % [path, detail]
end
return nil if desc == ""
diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb
index 36a4d49fa..2a5ac30da 100755
--- a/lib/puppet/type/group.rb
+++ b/lib/puppet/type/group.rb
@@ -110,7 +110,7 @@ module Puppet
isnamevar
end
- newparam(:allowdupe) do
+ newparam(:allowdupe, :boolean => true) do
desc "Whether to allow duplicate GIDs. This option does not work on
FreeBSD (contract to the ``pw`` man page)."
diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb
index 3a12e95ad..1db4a0ac3 100644
--- a/lib/puppet/type/ssh_authorized_key.rb
+++ b/lib/puppet/type/ssh_authorized_key.rb
@@ -27,11 +27,6 @@ module Puppet
newproperty(:user) do
desc "The user account in which the SSH key should be installed."
-
- def value=(value)
- @resource[:target] = File.expand_path("~%s/.ssh/authorized_keys" % value)
- super
- end
end
newproperty(:target) do
@@ -45,25 +40,6 @@ module Puppet
defaultto do :absent end
end
- def generate
- atype = Puppet::Type.type(:file)
- target = self.should(:target)
- dir = File.dirname(target)
- user = should(:user) ? should(:user) : "root"
-
- rels = []
-
- unless catalog.resource(:file, dir)
- rels << atype.create(:name => dir, :ensure => :directory, :mode => 0700, :owner => user)
- end
-
- unless catalog.resource(:file, target)
- rels << atype.create(:name => target, :ensure => :present, :mode => 0600, :owner => user)
- end
-
- rels
- end
-
autorequire(:user) do
if should(:user)
should(:user)
@@ -71,7 +47,7 @@ module Puppet
end
validate do
- unless should(:target)
+ unless should(:target) or should(:user)
raise Puppet::Error, "Attribute 'user' or 'target' is mandatory"
end
end
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 560afe10b..94c96db0c 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -313,7 +313,7 @@ module Util
$VERBOSE = oldverb
if child_pid
# Parent process executes this
- child_status = Process.waitpid2(child_pid)[1]
+ child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8
else
# Child process executes this
Process.setsid
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb
index eba58a3d5..fcf8ccf22 100755
--- a/spec/integration/defaults.rb
+++ b/spec/integration/defaults.rb
@@ -47,4 +47,8 @@ describe "Puppet defaults" do
Puppet.settings.element(:rundir).owner.should be_nil
Puppet.settings.element(:rundir).group.should be_nil
end
+
+ it "should default to yaml as the catalog format" do
+ Puppet.settings[:catalog_format].should == "yaml"
+ end
end
diff --git a/spec/integration/file_serving/metadata.rb b/spec/integration/file_serving/metadata.rb
index 5600365f1..067cb566a 100755
--- a/spec/integration/file_serving/metadata.rb
+++ b/spec/integration/file_serving/metadata.rb
@@ -16,4 +16,3 @@ describe Puppet::FileServing::Metadata, " when finding files" do
@indirection = Puppet::FileServing::Metadata.indirection
end
end
-
diff --git a/spec/integration/indirector/module_files.rb b/spec/integration/indirector/module_files.rb
index 1831bffbc..ae14aa5a7 100755
--- a/spec/integration/indirector/module_files.rb
+++ b/spec/integration/indirector/module_files.rb
@@ -20,7 +20,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module
FileTest.expects(:exists?).with(filepath).returns(true)
- @terminus.find("puppetmounts://host/modules/mymod/myfile").should be_instance_of(Puppet::FileServing::Content)
+ @request = Puppet::Indirector::Request.new(:content, :find, "puppetmounts://host/modules/mymod/myfile")
+
+ @terminus.find(@request).should be_instance_of(Puppet::FileServing::Content)
end
end
@@ -45,7 +47,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with FileServing::F
Dir.expects(:entries).with(filepath).returns(%w{one two})
- result = @terminus.search("puppetmounts://host/modules/mymod/myfile", :recurse => true)
+ @request = Puppet::Indirector::Request.new(:content, :search, "puppetmounts://host/modules/mymod/myfile", :recurse => true)
+
+ result = @terminus.search(@request)
result.should be_instance_of(Array)
result.length.should == 3
result.each { |r| r.should be_instance_of(Puppet::FileServing::Content) }
diff --git a/spec/integration/node/catalog.rb b/spec/integration/node/catalog.rb
index 87d62ea6a..75be9501a 100755
--- a/spec/integration/node/catalog.rb
+++ b/spec/integration/node/catalog.rb
@@ -40,5 +40,15 @@ describe Puppet::Node::Catalog do
Puppet::Node::Catalog.find("me").should be_nil
end
+
+ it "should pass provided node information directly to the terminus" do
+ terminus = mock 'terminus'
+
+ Puppet::Node::Catalog.indirection.stubs(:terminus).returns terminus
+
+ node = mock 'node'
+ terminus.expects(:find).with { |request| request.options[:use_node] == node }
+ Puppet::Node::Catalog.find("me", :use_node => node)
+ end
end
end
diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb
index 883db58f5..0230d39e8 100644
--- a/spec/shared_behaviours/file_server_terminus.rb
+++ b/spec/shared_behaviours/file_server_terminus.rb
@@ -24,6 +24,8 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do
# Stub out the modules terminus
@modules = mock 'modules terminus'
+
+ @request = Puppet::Indirector::Request.new(:indirection, :method, "puppetmounts://myhost/one/my/file")
end
it "should use the file server configuration to find files" do
@@ -35,6 +37,6 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do
FileTest.stubs(:exists?).with("/my/mount/path").returns(true)
@mount1.expects(:file).with("my/file", :node => nil).returns(path)
- @terminus.find("puppetmounts://myhost/one/my/file").should be_instance_of(@test_class)
+ @terminus.find(@request).should be_instance_of(@test_class)
end
end
diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb
index 82f207243..ba01f75a1 100644
--- a/spec/shared_behaviours/file_serving.rb
+++ b/spec/shared_behaviours/file_serving.rb
@@ -5,13 +5,13 @@
describe "Puppet::FileServing::Files", :shared => true do
it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
- uri = "puppet://myhost/mymod/my/file"
+ uri = "puppet://myhost/fakemod/my/file"
@indirection.terminus(:rest).expects(:find)
@test_class.find(uri)
end
it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet'" do
- uri = "puppet:///mymod/my/file"
+ uri = "puppet:///fakemod/my/file"
Puppet.settings.stubs(:value).with(:name).returns("puppetd")
Puppet.settings.stubs(:value).with(:modulepath).returns("")
@indirection.terminus(:rest).expects(:find)
@@ -19,7 +19,7 @@ describe "Puppet::FileServing::Files", :shared => true do
end
it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'puppet'" do
- uri = "puppet:///mymod/my/file"
+ uri = "puppet:///fakemod/my/file"
Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing"))
Puppet.settings.stubs(:value).with(:name).returns("puppet")
Puppet.settings.stubs(:value).with(:modulepath, "testing").returns("")
@@ -33,22 +33,32 @@ describe "Puppet::FileServing::Files", :shared => true do
end
it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do
- uri = "puppetmounts:///mymod/my/file"
+ uri = "puppetmounts:///fakemod/my/file"
@indirection.terminus(:file_server).expects(:find)
@indirection.terminus(:file_server).stubs(:authorized?).returns(true)
@test_class.find(uri)
end
it "should use the file terminus when the 'file' URI scheme is used" do
- uri = "file:///mymod/my/file"
+ uri = "file:///fakemod/my/file"
@indirection.terminus(:file).expects(:find)
@test_class.find(uri)
end
it "should use the file terminus when a fully qualified path is provided" do
- uri = "/mymod/my/file"
+ uri = "/fakemod/my/file"
@indirection.terminus(:file).expects(:find)
@test_class.find(uri)
end
+
+ it "should use the configuration to test whether the request is allowed" do
+ uri = "puppetmounts:///fakemod/my/file"
+ config = mock 'configuration'
+ @indirection.terminus(:file_server).stubs(:configuration).returns config
+
+ @indirection.terminus(:file_server).expects(:find)
+ config.expects(:authorized?).returns(true)
+ @test_class.find(uri, :node => "foo", :ip => "bar")
+ end
end
diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb
index b919469a2..763ce9eb0 100755
--- a/spec/unit/file_serving/terminus_helper.rb
+++ b/spec/unit/file_serving/terminus_helper.rb
@@ -14,65 +14,63 @@ describe Puppet::FileServing::TerminusHelper do
@model = mock 'model'
@helper.stubs(:model).returns(@model)
+
+ @request = stub 'request', :key => "url", :options => {}
end
it "should use a fileset to find paths" do
fileset = mock 'fileset', :files => []
Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset)
- @helper.path2instances("url", "/my/file")
+ @helper.path2instances(@request, "/my/file")
end
it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do
fileset = mock 'fileset', :files => []
Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset)
- @helper.path2instances("url", "/my/file", :links => :a, :ignore => :b, :recurse => :c)
- end
-end
-
-
-describe Puppet::FileServing::TerminusHelper, " when creating instances" do
- before do
- @helper = Object.new
- @helper.extend(Puppet::FileServing::TerminusHelper)
-
- @model = mock 'model'
- @helper.stubs(:model).returns(@model)
-
- @key = "puppet://host/mount/dir"
-
- @fileset = mock 'fileset', :files => %w{one two}
- Puppet::FileServing::Fileset.expects(:new).returns(@fileset)
- end
-
- it "should create an instance of the model for each path returned by the fileset" do
- @model.expects(:new).returns(:one)
- @model.expects(:new).returns(:two)
- @helper.path2instances(@key, "/my/file").length.should == 2
- end
-
- it "should set each instance's key to be the original key plus the file-specific path" do
- @model.expects(:new).with { |key, options| key == @key + "/one" }.returns(:one)
- @model.expects(:new).with { |key, options| key == @key + "/two" }.returns(:two)
- @helper.path2instances(@key, "/my/file")
- end
-
- it "should set each returned instance's path to the original path" do
- @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one)
- @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two)
- @helper.path2instances(@key, "/my/file")
- end
-
- it "should set each returned instance's relative path to the file-specific path" do
- @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one)
- @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two)
- @helper.path2instances(@key, "/my/file")
+ @request.stubs(:options).returns(:links => :a, :ignore => :b, :recurse => :c)
+ @helper.path2instances(@request, "/my/file")
end
- it "should set the links value on each instance if one is provided" do
- one = mock 'one', :links= => :manage
- two = mock 'two', :links= => :manage
- @model.expects(:new).returns(one)
- @model.expects(:new).returns(two)
- @helper.path2instances(@key, "/my/file", :links => :manage)
+ describe "when creating instances" do
+ before do
+ @request.stubs(:key).returns "puppet://host/mount/dir"
+
+ @fileset = mock 'fileset', :files => %w{one two}
+ Puppet::FileServing::Fileset.expects(:new).returns(@fileset)
+ end
+
+ it "should create an instance of the model for each path returned by the fileset" do
+ @model.expects(:new).returns(:one)
+ @model.expects(:new).returns(:two)
+ @helper.path2instances(@request, "/my/file").length.should == 2
+ end
+
+ it "should set each instance's key to be the original key plus the file-specific path" do
+ @model.expects(:new).with { |key, options| key == @request.key + "/one" }.returns(:one)
+ @model.expects(:new).with { |key, options| key == @request.key + "/two" }.returns(:two)
+ @helper.path2instances(@request, "/my/file")
+ end
+
+ it "should set each returned instance's path to the original path" do
+ @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one)
+ @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two)
+ @helper.path2instances(@request, "/my/file")
+ end
+
+ it "should set each returned instance's relative path to the file-specific path" do
+ @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one)
+ @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two)
+ @helper.path2instances(@request, "/my/file")
+ end
+
+ it "should set the links value on each instance if one is provided" do
+ one = mock 'one', :links= => :manage
+ two = mock 'two', :links= => :manage
+ @model.expects(:new).returns(one)
+ @model.expects(:new).returns(two)
+
+ @request.options[:links] = :manage
+ @helper.path2instances(@request, "/my/file")
+ end
end
end
diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb
index cf7186a5a..8cd3c72f4 100755
--- a/spec/unit/indirector/catalog/compiler.rb
+++ b/spec/unit/indirector/catalog/compiler.rb
@@ -114,13 +114,12 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
@node = Puppet::Node.new @name
@node.stubs(:merge)
@request = stub 'request', :key => @name, :options => {}
- Puppet::Node.stubs(:find).with(@name).returns(@node)
end
it "should directly use provided nodes" do
Puppet::Node.expects(:find).never
- @compiler.interpreter.expects(:compile).with(@node)
- @request.stubs(:options).returns(:node => @node)
+ @compiler.expects(:compile).with(@node)
+ @request.stubs(:options).returns(:use_node => @node)
@compiler.find(@request)
end
@@ -130,12 +129,14 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
end
it "should pass the found node to the interpreter for compiling" do
+ Puppet::Node.expects(:find).with(@name).returns(@node)
config = mock 'config'
@compiler.interpreter.expects(:compile).with(@node)
@compiler.find(@request)
end
it "should return the results of compiling as the catalog" do
+ Puppet::Node.stubs(:find).returns(@node)
config = mock 'config'
result = mock 'result'
@@ -144,6 +145,7 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
end
it "should benchmark the compile process" do
+ Puppet::Node.stubs(:find).returns(@node)
@compiler.stubs(:networked?).returns(true)
@compiler.expects(:benchmark).with do |level, message|
level == :notice and message =~ /^Compiled catalog/
diff --git a/spec/unit/indirector/direct_file_server.rb b/spec/unit/indirector/direct_file_server.rb
index a8583716a..0753f1bbe 100755
--- a/spec/unit/indirector/direct_file_server.rb
+++ b/spec/unit/indirector/direct_file_server.rb
@@ -69,29 +69,20 @@ describe Puppet::Indirector::DirectFileServer do
end
describe Puppet::Indirector::DirectFileServer, "when searching for multiple files" do
-
it "should return nil if the file does not exist" do
FileTest.expects(:exists?).with("/my/local").returns false
@server.find(@request).should be_nil
end
- it "should pass the original key to :path2instances" do
- FileTest.expects(:exists?).with("/my/local").returns true
- @server.expects(:path2instances).with { |uri, path, options| uri == @uri }
- @server.search(@request)
- end
-
it "should use :path2instances from the terminus_helper to return instances if the file exists" do
FileTest.expects(:exists?).with("/my/local").returns true
@server.expects(:path2instances)
@server.search(@request)
end
- it "should pass any options on to :path2instances" do
+ it "should pass the original request to :path2instances" do
FileTest.expects(:exists?).with("/my/local").returns true
- @server.expects(:path2instances).with { |uri, path, options| options == {:testing => :one, :other => :two}}
-
- @request.stubs(:options).returns(:testing => :one, :other => :two)
+ @server.expects(:path2instances).with(@request, "/my/local")
@server.search(@request)
end
end
diff --git a/spec/unit/indirector/file_metadata/modules.rb b/spec/unit/indirector/file_metadata/modules.rb
index 62f01832c..3905a49ad 100755
--- a/spec/unit/indirector/file_metadata/modules.rb
+++ b/spec/unit/indirector/file_metadata/modules.rb
@@ -23,11 +23,13 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do
@finder.stubs(:environment).returns(nil)
@module = Puppet::Module.new("mymod", "/path/to")
@finder.stubs(:find_module).returns(@module)
+
+ @request = Puppet::Indirector::Request.new(:metadata, :find, "puppetmounts://hostname/modules/mymod/my/file")
end
it "should return nil if the file is not found" do
FileTest.expects(:exists?).with("/path/to/files/my/file").returns false
- @finder.find("puppetmounts://hostname/modules/mymod/my/file").should be_nil
+ @finder.find(@request).should be_nil
end
it "should retrieve the instance's attributes if the file is found" do
@@ -35,6 +37,6 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do
instance = mock 'metadta'
Puppet::FileServing::Metadata.expects(:new).returns instance
instance.expects :collect_attributes
- @finder.find("puppetmounts://hostname/modules/mymod/my/file")
+ @finder.find(@request)
end
end
diff --git a/spec/unit/indirector/file_server.rb b/spec/unit/indirector/file_server.rb
index 79be8cc29..ba951737a 100755
--- a/spec/unit/indirector/file_server.rb
+++ b/spec/unit/indirector/file_server.rb
@@ -27,34 +27,37 @@ describe Puppet::Indirector::FileServer do
@uri = "puppetmounts://host/my/local/file"
@configuration = mock 'configuration'
Puppet::FileServing::Configuration.stubs(:create).returns(@configuration)
+
+ @request = Puppet::Indirector::Request.new(:myind, :mymethod, @uri)
end
describe Puppet::Indirector::FileServer, " when finding files" do
it "should use the path portion of the URI as the file name" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.find(@uri)
+ @file_server.find(@request)
end
it "should use the FileServing configuration to convert the file name to a fully qualified path" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.find(@uri)
+ @file_server.find(@request)
end
it "should pass the node name to the FileServing configuration if one is provided" do
@configuration.expects(:file_path).with("/my/local/file", :node => "testing")
- @file_server.find(@uri, :node => "testing")
+ @request.node = "testing"
+ @file_server.find(@request)
end
it "should return nil if no fully qualified path is found" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
- @file_server.find(@uri).should be_nil
+ @file_server.find(@request).should be_nil
end
it "should return an instance of the model created with the full path if a file is found" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file")
@model.expects(:new).returns(:myinstance)
- @file_server.find(@uri).should == :myinstance
+ @file_server.find(@request).should == :myinstance
end
end
@@ -66,23 +69,24 @@ describe Puppet::Indirector::FileServer do
it "should create the instance with the key used to find the instance" do
@model.expects(:new).with { |key, *options| key == @uri }
- @file_server.find(@uri)
+ @file_server.find(@request)
end
it "should create the instance with the path at which the instance was found" do
@model.expects(:new).with { |key, options| options[:path] == "/some/file" }
- @file_server.find(@uri)
+ @file_server.find(@request)
end
it "should set the provided :links setting on to the instance if one is provided" do
@model.expects(:new).returns(@instance)
@instance.expects(:links=).with(:mytest)
- @file_server.find(@uri, :links => :mytest)
+ @request.options[:links] = :mytest
+ @file_server.find(@request)
end
it "should not set a :links value if no :links parameter is provided" do
@model.expects(:new).returns(@instance)
- @file_server.find(@uri)
+ @file_server.find(@request)
end
end
@@ -93,41 +97,52 @@ describe Puppet::Indirector::FileServer do
end
it "should deny the :destroy method" do
- @file_server.authorized?(:destroy, "whatever").should be_false
+ @request.method = :destroy
+ @file_server.authorized?(@request).should be_false
end
it "should deny the :save method" do
- @file_server.authorized?(:save, "whatever").should be_false
- end
+ @request.method = :save
+ @file_server.authorized?(@request).should be_false
+ end
+
+ describe "and finding file information" do
+ before do
+ @request.key = "puppetmounts://host/my/file"
+ @request.method = :find
+ end
- it "should use the file server configuration to determine authorization" do
- @configuration.expects(:authorized?)
- @file_server.authorized?(:find, "puppetmounts://host/my/file")
- end
+ it "should use the file server configuration to determine authorization" do
+ @configuration.expects(:authorized?)
+ @file_server.authorized?(@request)
+ end
- it "should pass the file path from the URI to the file server configuration" do
- @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file")
- end
+ it "should pass the file path from the URI to the file server configuration" do
+ @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" }
+ @file_server.authorized?(@request)
+ end
- it "should pass the node name to the file server configuration" do
- @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode")
- end
+ it "should pass the node name to the file server configuration" do
+ @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" }
+ @request.node = "mynode"
+ @file_server.authorized?(@request)
+ end
- it "should pass the IP address to the file server configuration" do
- @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip")
- end
+ it "should pass the IP address to the file server configuration" do
+ @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" }
+ @request.ip = "myip"
+ @file_server.authorized?(@request)
+ end
- it "should return false if the file server configuration denies authorization" do
- @configuration.expects(:authorized?).returns(false)
- @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_false
- end
+ it "should return false if the file server configuration denies authorization" do
+ @configuration.expects(:authorized?).returns(false)
+ @file_server.authorized?(@request)
+ end
- it "should return true if the file server configuration approves authorization" do
- @configuration.expects(:authorized?).returns(true)
- @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_true
+ it "should return true if the file server configuration approves authorization" do
+ @configuration.expects(:authorized?).returns(true)
+ @file_server.authorized?(@request)
+ end
end
end
@@ -135,34 +150,35 @@ describe Puppet::Indirector::FileServer do
it "should use the path portion of the URI as the file name" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.search(@uri)
+ @file_server.search(@request)
end
it "should use the FileServing configuration to convert the file name to a fully qualified path" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.search(@uri)
+ @file_server.search(@request)
end
it "should pass the node name to the FileServing configuration if one is provided" do
@configuration.expects(:file_path).with("/my/local/file", :node => "testing")
- @file_server.search(@uri, :node => "testing")
+ @request.node = "testing"
+ @file_server.search(@request)
end
it "should return nil if no fully qualified path is found" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
- @file_server.search(@uri).should be_nil
+ @file_server.search(@request).should be_nil
end
it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
- @file_server.expects(:path2instances).with(@uri, "/my/file", {})
- @file_server.search(@uri)
+ @file_server.expects(:path2instances)
+ @file_server.search(@request)
end
- it "should pass any options on to :path2instances" do
+ it "should pass the request on to :path2instances" do
@configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
- @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two)
- @file_server.search(@uri, :testing => :one, :other => :two)
+ @file_server.expects(:path2instances).with(@request, "/my/file")
+ @file_server.search(@request)
end
end
end
diff --git a/spec/unit/indirector/module_files.rb b/spec/unit/indirector/module_files.rb
index f5b92e1fd..32dedd4f1 100755
--- a/spec/unit/indirector/module_files.rb
+++ b/spec/unit/indirector/module_files.rb
@@ -27,61 +27,66 @@ describe Puppet::Indirector::ModuleFiles do
@uri = "puppetmounts://host/modules/my/local/file"
@module = Puppet::Module.new("mymod", "/module/path")
+
+ @request = stub 'request', :key => @uri, :options => {}, :node => nil, :ip => nil, :method => :find
end
describe Puppet::Indirector::ModuleFiles, " when finding files" do
it "should strip off the leading '/modules' mount name" do
Puppet::Module.expects(:find).with('my', "myenv").returns @module
- @module_files.find(@uri)
+ @module_files.find(@request)
end
it "should not strip off leading terms that start with '/modules' but are longer words" do
+ @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file"
Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil
- @module_files.find("puppetmounts://host/modulestart/my/local/file")
+ @module_files.find(@request)
end
it "should search for a module whose name is the first term in the remaining file path" do
Puppet::Module.expects(:find).with('my', "myenv").returns @module
- @module_files.find(@uri)
+ @module_files.find(@request)
end
it "should search for a file relative to the module's files directory" do
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file")
- @module_files.find(@uri)
+ @module_files.find(@request)
end
it "should return nil if the module does not exist" do
Puppet::Module.expects(:find).with('my', "myenv").returns nil
- @module_files.find(@uri).should be_nil
+ @module_files.find(@request).should be_nil
end
it "should return nil if the module exists but the file does not" do
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false)
- @module_files.find(@uri).should be_nil
+ @module_files.find(@request).should be_nil
end
it "should return an instance of the model if a module is found and the file exists" do
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true)
@model.expects(:new).returns(:myinstance)
- @module_files.find(@uri).should == :myinstance
+ @module_files.find(@request).should == :myinstance
end
it "should use the node's environment to look up the module if the node name is provided" do
node = stub "node", :environment => "testing"
Puppet::Node.expects(:find).with("mynode").returns(node)
Puppet::Module.expects(:find).with('my', "testing")
- @module_files.find(@uri, :node => "mynode")
+
+ @request.stubs(:node).returns "mynode"
+ @module_files.find(@request)
end
it "should use the default environment setting to look up the module if the node name is not provided" do
env = stub "environment", :name => "testing"
Puppet::Node::Environment.stubs(:new).returns(env)
Puppet::Module.expects(:find).with('my', "testing")
- @module_files.find(@uri)
+ @module_files.find(@request)
end
end
@@ -95,23 +100,25 @@ describe Puppet::Indirector::ModuleFiles do
it "should create the instance with the key used to find the instance" do
@model.expects(:new).with { |key, *options| key == @uri }
- @module_files.find(@uri)
+ @module_files.find(@request)
end
it "should create the instance with the path at which the instance was found" do
@model.expects(:new).with { |key, options| options[:path] == "/module/path/files/local/file" }
- @module_files.find(@uri)
+ @module_files.find(@request)
end
it "should set the provided :links setting on to the instance if one is provided" do
@model.expects(:new).returns(@instance)
@instance.expects(:links=).with(:mytest)
- @module_files.find(@uri, :links => :mytest)
+
+ @request.options[:links] = :mytest
+ @module_files.find(@request)
end
it "should not set a :links value if no :links parameter is provided" do
@model.expects(:new).returns(@instance)
- @module_files.find(@uri)
+ @module_files.find(@request)
end
end
@@ -127,46 +134,53 @@ describe Puppet::Indirector::ModuleFiles do
end
it "should deny the :destroy method" do
- @module_files.authorized?(:destroy, "whatever").should be_false
+ @request.expects(:method).returns :destroy
+ @module_files.authorized?(@request).should be_false
end
it "should deny the :save method" do
- @module_files.authorized?(:save, "whatever").should be_false
+ @request.expects(:method).returns :save
+ @module_files.authorized?(@request).should be_false
end
it "should use the file server configuration to determine authorization" do
@configuration.expects(:authorized?)
- @module_files.authorized?(:find, "puppetmounts://host/my/file")
+ @module_files.authorized?(@request)
end
it "should use the path directly from the URI if it already includes /modules" do
+ @request.expects(:key).returns "puppetmounts://host/modules/my/file"
@configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" }
- @module_files.authorized?(:find, "puppetmounts://host/modules/my/file")
+ @module_files.authorized?(@request)
end
it "should add /modules to the file path if it's not included in the URI" do
+ @request.expects(:key).returns "puppetmounts://host/my/file"
@configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" }
- @module_files.authorized?(:find, "puppetmounts://host/my/file")
+ @module_files.authorized?(@request)
end
it "should pass the node name to the file server configuration" do
+ @request.expects(:key).returns "puppetmounts://host/my/file"
@configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" }
- @module_files.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode")
+ @request.stubs(:node).returns "mynode"
+ @module_files.authorized?(@request)
end
it "should pass the IP address to the file server configuration" do
+ @request.expects(:ip).returns "myip"
@configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" }
- @module_files.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip")
+ @module_files.authorized?(@request)
end
it "should return false if the file server configuration denies authorization" do
@configuration.expects(:authorized?).returns(false)
- @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_false
+ @module_files.authorized?(@request).should be_false
end
it "should return true if the file server configuration approves authorization" do
@configuration.expects(:authorized?).returns(true)
- @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_true
+ @module_files.authorized?(@request).should be_true
end
end
@@ -175,69 +189,71 @@ describe Puppet::Indirector::ModuleFiles do
it "should strip off the leading '/modules' mount name" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
- @module_files.search(@uri)
+ @module_files.search(@request)
end
it "should not strip off leading terms that start with '/modules' but are longer words" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil
- @module_files.search("puppetmounts://host/modulestart/my/local/file")
+ @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file"
+ @module_files.search @request
end
it "should search for a module whose name is the first term in the remaining file path" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
- @module_files.search(@uri)
+ @module_files.search(@request)
end
it "should search for a file relative to the module's files directory" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file")
- @module_files.search(@uri)
+ @module_files.search(@request)
end
it "should return nil if the module does not exist" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns nil
- @module_files.search(@uri).should be_nil
+ @module_files.search(@request).should be_nil
end
it "should return nil if the module exists but the file does not" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false)
- @module_files.search(@uri).should be_nil
+ @module_files.search(@request).should be_nil
end
it "should use the node's environment to look up the module if the node name is provided" do
node = stub "node", :environment => "testing"
Puppet::Node.expects(:find).with("mynode").returns(node)
Puppet::Module.expects(:find).with('my', "testing")
- @module_files.search(@uri, :node => "mynode")
+ @request.stubs(:node).returns "mynode"
+ @module_files.search(@request)
end
it "should use the default environment setting to look up the module if the node name is not provided and the environment is not set to ''" do
env = stub 'env', :name => "testing"
Puppet::Node::Environment.stubs(:new).returns(env)
Puppet::Module.expects(:find).with('my', "testing")
- @module_files.search(@uri)
+ @module_files.search(@request)
end
it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true)
- @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", {})
- @module_files.search(@uri)
+ @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file")
+ @module_files.search(@request)
end
- it "should pass any options on to :path2instances" do
+ it "should pass the request directly to :path2instances" do
Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv"))
Puppet::Module.expects(:find).with('my', "myenv").returns @module
FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true)
- @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", :testing => :one, :other => :two)
- @module_files.search(@uri, :testing => :one, :other => :two)
+ @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file")
+ @module_files.search(@request)
end
end
end
diff --git a/spec/unit/indirector/node/exec.rb b/spec/unit/indirector/node/exec.rb
index 2276e4298..09f13ab90 100755
--- a/spec/unit/indirector/node/exec.rb
+++ b/spec/unit/indirector/node/exec.rb
@@ -49,12 +49,6 @@ describe Puppet::Node::Exec do
@searcher.find(@request)
end
- it "should convert all parameters into strings" do
- @result[:parameters] = {"a" => true, "c" => 100}
- @node.expects(:parameters=).with "a" => "true", "c" => "100"
- @searcher.find(@request)
- end
-
it "should set the resulting classes as the node classes" do
@result[:classes] = %w{one two}
@node.expects(:classes=).with %w{one two}
diff --git a/spec/unit/module.rb b/spec/unit/module.rb
index 2dadaa501..e79001ae1 100755
--- a/spec/unit/module.rb
+++ b/spec/unit/module.rb
@@ -143,8 +143,8 @@ describe Puppet::Module, " when searching for manifests when no module is found"
it "should look for files relative to the current directory" do
cwd = Dir.getwd
- Dir.expects(:glob).with("#{cwd}/mymod/init.pp").returns(["#{cwd}/mymod/init.pp"])
- Puppet::Module.find_manifests("mymod/init.pp").should == ["#{cwd}/mymod/init.pp"]
+ Dir.expects(:glob).with("#{cwd}/foobar/init.pp").returns(["#{cwd}/foobar/init.pp"])
+ Puppet::Module.find_manifests("foobar/init.pp").should == ["#{cwd}/foobar/init.pp"]
end
it "should only return files, not directories" do
diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb
index 79ab8c86f..754fd0583 100755
--- a/spec/unit/network/client/master.rb
+++ b/spec/unit/network/client/master.rb
@@ -59,34 +59,92 @@ describe Puppet::Network::Client::Master, " when retrieving the catalog" do
@client.getconfig
end
- it "should load the retrieved catalog using YAML" do
- @client.stubs(:dostorage)
- @client.class.stubs(:facts).returns(@facts)
- @master.stubs(:getconfig).returns("myconfig")
+ describe "when the catalog format is set to yaml" do
+ before do
+ Puppet.settings.stubs(:value).returns "foo"
+ Puppet.settings.stubs(:value).with(:pluginsync).returns false
+ Puppet.settings.stubs(:value).with(:configtimeout).returns 10
+ Puppet.settings.stubs(:value).with(:factsync).returns false
+ Puppet.settings.stubs(:value).with(:catalog_format).returns "yaml"
+ end
- config = mock 'config'
- YAML.expects(:load).with("myconfig").returns(config)
+ it "should request a yaml-encoded catalog" do
+ @client.stubs(:dostorage)
+ @client.class.stubs(:facts).returns(@facts)
+ @master.expects(:getconfig).with { |*args| args[1] == "yaml" }
- @client.stubs(:setclasses)
+ @client.getconfig
+ end
- config.stubs(:classes)
- config.stubs(:to_catalog).returns(config)
- config.stubs(:host_config=)
- config.stubs(:from_cache).returns(true)
+ it "should load the retrieved catalog using YAML" do
+ @client.stubs(:dostorage)
+ @client.class.stubs(:facts).returns(@facts)
+ @master.stubs(:getconfig).returns("myconfig")
- @client.getconfig
+ config = mock 'config'
+ YAML.expects(:load).with("myconfig").returns(config)
+
+ @client.stubs(:setclasses)
+
+ config.stubs(:classes)
+ config.stubs(:to_catalog).returns(config)
+ config.stubs(:host_config=)
+ config.stubs(:from_cache).returns(true)
+
+ @client.getconfig
+ end
+
+ it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do
+ @client.stubs(:dostorage)
+ @client.class.stubs(:facts).returns(@facts)
+ @master.stubs(:getconfig).returns("myconfig")
+
+ YAML.expects(:load).with("myconfig").raises(ArgumentError)
+
+ @client.expects(:use_cached_config).with(true)
+
+ @client.getconfig
+ end
end
- it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do
- @client.stubs(:dostorage)
- @client.class.stubs(:facts).returns(@facts)
- @master.stubs(:getconfig).returns("myconfig")
+ describe "from Marshal" do
+ before do
+ Puppet.settings.stubs(:value).returns "foo"
+ Puppet.settings.stubs(:value).with(:pluginsync).returns false
+ Puppet.settings.stubs(:value).with(:configtimeout).returns 10
+ Puppet.settings.stubs(:value).with(:factsync).returns false
+ Puppet.settings.stubs(:value).with(:catalog_format).returns "marshal"
+ end
- YAML.expects(:load).with("myconfig").raises(ArgumentError)
+ it "should load the retrieved catalog using Marshal" do
+ @client.stubs(:dostorage)
+ @client.class.stubs(:facts).returns(@facts)
+ @master.stubs(:getconfig).returns("myconfig")
- @client.expects(:use_cached_config).with(true)
+ config = mock 'config'
+ Marshal.expects(:load).with("myconfig").returns(config)
- @client.getconfig
+ @client.stubs(:setclasses)
+
+ config.stubs(:classes)
+ config.stubs(:to_catalog).returns(config)
+ config.stubs(:host_config=)
+ config.stubs(:from_cache).returns(true)
+
+ @client.getconfig
+ end
+
+ it "should use the cached catalog if the retrieved catalog cannot be converted from Marshal" do
+ @client.stubs(:dostorage)
+ @client.class.stubs(:facts).returns(@facts)
+ @master.stubs(:getconfig).returns("myconfig")
+
+ Marshal.expects(:load).with("myconfig").raises(ArgumentError)
+
+ @client.expects(:use_cached_config).with(true)
+
+ @client.getconfig
+ end
end
it "should set the classes.txt file with the classes listed in the retrieved catalog" do
diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb
index 79a0a88d4..1fa025b0b 100755
--- a/spec/unit/network/http.rb
+++ b/spec/unit/network/http.rb
@@ -12,9 +12,15 @@ describe Puppet::Network::HTTP do
Puppet::Network::HTTP.server_class_by_type(:webrick).should be(Puppet::Network::HTTP::WEBrick)
end
- if Puppet.features.mongrel?
- it "should return the mongrel HTTP server class when asked for a mongrel server" do
- Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel)
+ describe "when asked for a mongrel server" do
+ if Puppet.features.mongrel?
+ it "should return the mongrel server class" do
+ Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel)
+ end
+ else
+ it "should fail" do
+ lambda { Puppet::Network::HTTP.server_class_by_type(:mongrel) }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb
index 1f87fd943..9c708067a 100755
--- a/spec/unit/network/http/mongrel.rb
+++ b/spec/unit/network/http/mongrel.rb
@@ -6,18 +6,22 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/network/http'
-describe Puppet::Network::HTTP::Mongrel, "after initializing" do
+describe "Puppet::Network::HTTP::Mongrel", "after initializing" do
confine "Mongrel is not available" => Puppet.features.mongrel?
it "should not be listening" do
+ require 'puppet/network/http/mongrel'
+
Puppet::Network::HTTP::Mongrel.new.should_not be_listening
end
end
-describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
+ require 'puppet/network/http/mongrel'
+
@server = Puppet::Network::HTTP::Mongrel.new
@mock_mongrel = mock('mongrel')
@mock_mongrel.stubs(:run)
@@ -109,7 +113,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
end
end
-describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning off listening" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb
index 3df925133..de5254a7a 100755
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -3,10 +3,12 @@
require File.dirname(__FILE__) + '/../../../../spec_helper'
require 'puppet/network/http'
-describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
+describe "Puppet::Network::HTTP::MongrelREST", "when initializing" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
+ require 'puppet/network/http/mongrel/rest'
+
@mock_mongrel = mock('Mongrel server')
@mock_mongrel.stubs(:register)
@mock_model = mock('indirected model')
@@ -33,7 +35,7 @@ describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
end
end
-describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
+describe "Puppet::Network::HTTP::MongrelREST", "when receiving a request" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
@@ -131,6 +133,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "and determining the request parameters", :shared => true do
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
before do
@mock_request.stubs(:params).returns({})
end
@@ -198,6 +202,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when finding a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to find model if key is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_response.expects(:start).with(404)
@@ -236,6 +242,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when destroying a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to destroy model if key is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_response.expects(:start).with(404)
@@ -281,6 +289,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when saving a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to save model if data is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_request.stubs(:body).returns('')
@@ -319,6 +329,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when searching for model instances" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should use a common method for determining the request parameters" do
setup_search_request('QUERY_STRING' => 'foo=baz&bar=xyzzy')
@handler.expects(:params).returns(:foo => :baz, :bar => :xyzzy)
diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb
index e3c3b81c0..7e5084bbc 100755
--- a/spec/unit/network/http/webrick.rb
+++ b/spec/unit/network/http/webrick.rb
@@ -5,6 +5,7 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/network/http'
+require 'puppet/network/http/webrick'
describe Puppet::Network::HTTP::WEBrick, "after initializing" do
it "should not be listening" do
diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb
index 45e5f0bd2..17d47e54c 100755
--- a/spec/unit/network/http/webrick/rest.rb
+++ b/spec/unit/network/http/webrick/rest.rb
@@ -2,6 +2,7 @@
require File.dirname(__FILE__) + '/../../../../spec_helper'
require 'puppet/network/http'
+require 'puppet/network/http/webrick/rest'
describe Puppet::Network::HTTP::WEBrickREST, "when initializing" do
before do
diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index c35ddc513..16efc5b58 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed.rb
@@ -71,4 +71,25 @@ describe provider_class do
genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n"
end
+
+ it "should prefetch ~user/.ssh/authorized_keys when user is given" do
+ key = Puppet::Type.type(:ssh_authorized_key).create(
+ :name => "Test",
+ :key => "AA",
+ :type => "rsa",
+ :ensure => :present,
+ :user => "root")
+ prov = @provider.new key
+
+ prov.prefetch
+ prov.target.should == File.expand_path("~root/.ssh/authorized_keys")
+ end
+
+ it "should create destination dir" do
+ # No idea how to test the flush method
+ end
+
+ it "should set correct default permissions" do
+ # No idea how to test the flush method
+ end
end
diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb
index 4a4667543..533236772 100755
--- a/spec/unit/rails.rb
+++ b/spec/unit/rails.rb
@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
require 'puppet/rails'
describe Puppet::Rails, "when initializing any connection" do
- confine Puppet.features.rails? => "Cannot test without ActiveRecord"
+ confine "Cannot test without ActiveRecord" => Puppet.features.rails?
before do
@logger = stub 'logger', :level= => nil
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 128e14a01..7f9688f0b 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -64,6 +64,11 @@ describe Puppet::Type.type(:file) do
@file.property(:source).retrieve
lambda { @file.property(:source).sync }.should raise_error(Puppet::Error)
end
+
+ it "should fail if it cannot describe remote contents" do
+ @filesource.server.stubs(:describe).raises(Puppet::Network::XMLRPCClientError.new("Testing"))
+ lambda { @file.retrieve }.should raise_error(Puppet::Error)
+ end
end
describe "when managing links" do
diff --git a/spec/unit/type/group.rb b/spec/unit/type/group.rb
new file mode 100755
index 000000000..d7e06dcd8
--- /dev/null
+++ b/spec/unit/type/group.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Type.type(:group) do
+ before do
+ @class = Puppet::Type.type(:group)
+ end
+
+ after do
+ @class.clear
+ end
+
+ it "should have a default provider" do
+ @class.defaultprovider.should_not be_nil
+ end
+
+ it "should have a default provider inheriting from Puppet::Provider" do
+ @class.defaultprovider.ancestors.should be_include(Puppet::Provider)
+ end
+
+ describe "when validating attributes" do
+ [:name, :allowdupe].each do |param|
+ it "should have a #{param} parameter" do
+ @class.attrtype(param).should == :param
+ end
+ end
+
+ [:ensure, :gid].each do |param|
+ it "should have a #{param} property" do
+ @class.attrtype(param).should == :property
+ end
+ end
+ end
+
+ # #1407 - we need to declare the allowdupe param as boolean.
+ it "should have a boolean method for determining if duplicates are allowed" do
+ @class.create(:name => "foo").methods.should be_include("allowdupe?")
+ end
+end
diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index bb38fafce..1860f2714 100755
--- a/spec/unit/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -77,47 +77,6 @@ describe ssh_authorized_key do
@class.attrtype(:target).should == :property
end
- it "should autorequire parent directories when user is given" do
- @catalog.add_resource @class.create(
- :name => "Test",
- :key => "AAA",
- :type => "ssh-rsa",
- :ensure => :present,
- :user => "root")
- @catalog.apply
-
- target = File.expand_path("~root/.ssh")
- @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
- end
-
- it "should set target when user is given" do
- @catalog.add_resource @class.create(
- :name => "Test",
- :key => "AAA",
- :type => "ssh-rsa",
- :ensure => :present,
- :user => "root")
- @catalog.apply
-
- target = File.expand_path("~root/.ssh/authorized_keys")
- @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
- end
-
-
- it "should autorequire parent directories when target is given" do
- target = "/tmp/home/foo/bar/.ssh/authorized_keys"
-
- @catalog.add_resource @class.create(
- :name => "Test",
- :key => "AAA",
- :type => "ssh-rsa",
- :ensure => :present,
- :target => target)
- @catalog.apply
-
- @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
- end
-
it "should raise an error when neither user nor target is given" do
proc do
@class.create(
diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb
index c055cbca1..10d431939 100755
--- a/test/certmgr/support.rb
+++ b/test/certmgr/support.rb
@@ -79,22 +79,31 @@ class TestCertSupport < Test::Unit::TestCase
end
end
- # Fixing #1382.
- def test_uppercase_files_are_renamed_and_read
- # Write a key out to disk in a file containing upper-case.
- key = OpenSSL::PKey::RSA.new(32)
- should_path = Puppet[:hostprivkey]
-
- dir, file = File.split(should_path)
- newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."}
- upper_path = File.join(dir, newfile)
- File.open(upper_path, "w") { |f| f.print key.to_s }
-
- user = CertUser.new
-
- assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk")
- assert(! FileTest.exist?(upper_path), "Upper case file was not removed")
- assert(FileTest.exist?(should_path), "File was not renamed to lower-case file")
- assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk")
+ # Fixing #1382. This test will always fail on Darwin, because its
+ # FS is case-insensitive.
+ unless Facter.value(:operatingsystem) == "Darwin"
+ def test_uppercase_files_are_renamed_and_read
+ # Write a key out to disk in a file containing upper-case.
+ key = OpenSSL::PKey::RSA.new(32)
+ should_path = Puppet[:hostprivkey]
+ puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect]
+
+ dir, file = File.split(should_path)
+ newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."}
+ puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect]
+ upper_path = File.join(dir, newfile)
+ puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect]
+ puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect]
+ File.open(upper_path, "w") { |f| f.print key.to_s }
+ puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect]
+ puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect]
+
+ user = CertUser.new
+
+ assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk")
+ assert(! FileTest.exist?(upper_path), "Upper case file was not removed")
+ assert(FileTest.exist?(should_path), "File was not renamed to lower-case file")
+ assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk")
+ end
end
end
diff --git a/test/lib/puppettest/runnable_test.rb b/test/lib/puppettest/runnable_test.rb
index e4b0f9033..e3cde5052 100644
--- a/test/lib/puppettest/runnable_test.rb
+++ b/test/lib/puppettest/runnable_test.rb
@@ -15,6 +15,9 @@ module PuppetTest
# Evaluate all of our tests to see if any of them are false
# and thus whether this test is considered not runnable.
def runnable?
+ if superclass.respond_to?(:runnable?) and ! superclass.runnable?
+ return false
+ end
@messages ||= []
return false unless @messages.empty?
return true unless defined? @confines
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 17bf1b3cc..bbdc021b9 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -56,3 +56,37 @@ class TestMaster < Test::Unit::TestCase
@master.getconfig("facts", "yaml", "foo.com")
end
end
+
+class TestMasterFormats < Test::Unit::TestCase
+ def setup
+ @facts = stub('facts', :save => nil)
+ Puppet::Node::Facts.stubs(:new).returns(@facts)
+
+ @master = Puppet::Network::Handler.master.new(:Code => "")
+ @master.stubs(:decode_facts)
+
+ @catalog = stub 'catalog', :extract => ""
+ Puppet::Node::Catalog.stubs(:find).returns(@catalog)
+ end
+
+ def test_marshal_can_be_used
+ @catalog.expects(:extract).returns "myextract"
+
+ Marshal.expects(:dump).with("myextract").returns "eh"
+
+ @master.getconfig("facts", "marshal", "foo.com")
+ end
+
+ def test_yaml_can_be_used
+ extract = mock 'extract'
+ @catalog.expects(:extract).returns extract
+
+ extract.expects(:to_yaml).returns "myaml"
+
+ @master.getconfig("facts", "yaml", "foo.com")
+ end
+
+ def test_failure_when_non_yaml_or_marshal_is_used
+ assert_raise(RuntimeError) { @master.getconfig("facts", "blah", "foo.com") }
+ end
+end
diff --git a/test/other/provider.rb b/test/other/provider.rb
index 3e4ad83d6..b0860f634 100755
--- a/test/other/provider.rb
+++ b/test/other/provider.rb
@@ -48,51 +48,6 @@ class TestImpl < Test::Unit::TestCase
end
- def test_provider_false_confine
- assert_nothing_raised do
- @provider.confine :false => false
- end
-
- assert(@provider.suitable?, "False did not check correctly")
- end
-
- def test_provider_true_confine
- assert_nothing_raised do
- @provider.confine :true => true
- end
-
- assert(@provider.suitable?, "True did not check correctly")
-
- # Now check whether we multiple true things work
- assert_nothing_raised do
- @provider.confine :true => false
- @provider.confine :true => true
- end
- assert(! @provider.suitable?, "One truth overrode another")
- end
-
- def test_provider_exists_confine
- file = tempfile()
-
- assert_nothing_raised do
- @provider.confine :exists => file
- end
-
- assert(! @provider.suitable?, "Exists did not check correctly")
- File.open(file, "w") { |f| f.puts "" }
- assert(@provider.suitable?, "Exists did not find file correctly")
- end
-
- def test_provider_facts_confine
- # Now check for multiple platforms
- assert_nothing_raised do
- @provider.confine :operatingsystem => [Facter["operatingsystem"].value, :yayos]
- @provider.confine :operatingsystem => [:fakeos, :otheros]
- end
-
- assert(@provider.suitable?, "Implementation not considered suitable")
- end
-
def test_provider_default
nondef = nil
assert_nothing_raised {
diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb
index 653db5c7d..e35b66fbd 100755
--- a/test/ral/type/filesources.rb
+++ b/test/ral/type/filesources.rb
@@ -144,16 +144,7 @@ class TestFileSources < Test::Unit::TestCase
# Make sure the munge didn't actually change the source
assert_equal([source], property.should, "munging changed the source")
- # First try it with a missing source
currentvalue = nil
- assert_nothing_raised do
- currentvalue = property.retrieve
- end
-
- # And make sure the property considers itself in sync, since there's nothing
- # to do
- assert(property.insync?(currentvalue), "source thinks there's work to do with no file or dest")
-
# Now make the dest a directory, and make sure the object sets :ensure
# up to create a directory
Dir.mkdir(source)
@@ -169,9 +160,6 @@ class TestFileSources < Test::Unit::TestCase
# Now remove the source, and make sure :ensure was not modified
Dir.rmdir(source)
- assert_nothing_raised do
- property.retrieve
- end
assert_equal(:directory, file.should(:ensure),
"Did not keep :ensure setting")
@@ -207,10 +195,6 @@ class TestFileSources < Test::Unit::TestCase
property = file.property(:source)
assert(property, "did not get source property")
- # Try it with no source at all
- currentvalues = file.retrieve
- assert(property.insync?(currentvalues[property]), "source property not in sync with missing source")
-
# with a directory
Dir.mkdir(source)
currentvalues = file.retrieve
@@ -525,6 +509,107 @@ class TestFileSources < Test::Unit::TestCase
return file
end
+ def test_NetworkSources
+ server = nil
+ mounts = {
+ "/" => "root"
+ }
+
+ fileserverconf = mkfileserverconf(mounts)
+
+ Puppet[:autosign] = true
+
+ Puppet[:masterport] = 8762
+ Puppet[:name] = "puppetmasterd"
+ Puppet[:certdnsnames] = "localhost"
+
+ serverpid = nil
+ assert_nothing_raised() {
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+ :Handlers => {
+ :CA => {}, # so that certs autogenerate
+ :FileServer => {
+ :Config => fileserverconf
+ }
+ }
+ )
+
+ }
+ serverpid = fork {
+ assert_nothing_raised() {
+ #trap(:INT) { server.shutdown; Kernel.exit! }
+ trap(:INT) { server.shutdown }
+ server.start
+ }
+ }
+ @@tmppids << serverpid
+
+ sleep(1)
+
+ fromdir, todir = run_complex_sources("root")
+ assert_trees_equal(fromdir,todir)
+ recursive_source_test(fromdir, todir)
+ assert_trees_equal(fromdir,todir)
+
+ assert_nothing_raised {
+ system("kill -INT %s" % serverpid)
+ }
+ end
+
+ def test_unmountedNetworkSources
+ server = nil
+ mounts = {
+ "/" => "root",
+ "/noexistokay" => "noexist"
+ }
+
+ fileserverconf = mkfileserverconf(mounts)
+
+ Puppet[:autosign] = true
+ Puppet[:masterport] = @port
+ Puppet[:certdnsnames] = "localhost"
+
+ serverpid = nil
+ assert_nothing_raised("Could not start on port %s" % @port) {
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+ :Port => @port,
+ :Handlers => {
+ :CA => {}, # so that certs autogenerate
+ :FileServer => {
+ :Config => fileserverconf
+ }
+ }
+ )
+
+ }
+
+ serverpid = fork {
+ assert_nothing_raised() {
+ #trap(:INT) { server.shutdown; Kernel.exit! }
+ trap(:INT) { server.shutdown }
+ server.start
+ }
+ }
+ @@tmppids << serverpid
+
+ sleep(1)
+
+ name = File.join(tmpdir(), "nosourcefile")
+ file = Puppet.type(:file).create(
+ :source => "puppet://localhost/noexist/file",
+ :name => name
+ )
+
+ assert_raise Puppet::Error do
+ file.retrieve
+ end
+
+ comp = mk_catalog(file)
+ comp.apply
+
+ assert(!FileTest.exists?(name), "File with no source exists anyway")
+ end
+
def test_alwayschecksum
from = tempfile()
to = tempfile()