summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-06-10 16:28:47 -0700
committerdanielsdeleo <dan@opscode.com>2013-06-10 16:29:58 -0700
commite7bc340024b0942113a8096807fcfaabc7ea8521 (patch)
treeb8800a75829f26c670445421b5711f721c81178f /spec/support
parentfad0c545f1fc23692651d15a8c379ebb1aa75fcb (diff)
downloadchef-e7bc340024b0942113a8096807fcfaabc7ea8521.tar.gz
Prevent integration tests from loading real config
knife integration tests were picking up default config and therefore pointing at a chef-server other than the chef-zero test instance. This could potentially lead to data loss or manglement if the test code successfully runs against a production chef-server/org. To prevent the above, load a dummy config file with an added failsafe mechanism to ensure we've not loaded a real one.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared/integration/knife_support.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index ce07414a65..984e67d347 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -45,7 +45,22 @@ module KnifeSupport
# Don't print stuff
Chef::Config[:verbosity] = ( DEBUG ? 2 : 0 )
+ instance.config[:config_file] = File.join(CHEF_SPEC_DATA, "null_config.rb")
+
+
+ # Configure chef with a (mostly) blank knife.rb
+ # We set a global and then mutate it in our stub knife.rb so we can be
+ # extra sure that we're not loading someone's real knife.rb and then
+ # running test scenarios against a real chef server. If things don't
+ # smell right, abort.
+
+ $__KNIFE_INTEGRATION_FAILSAFE_CHECK = "ole"
instance.configure_chef
+
+ unless $__KNIFE_INTEGRATION_FAILSAFE_CHECK == "ole ole"
+ raise Exception, "Potential misconfiguration of integration tests detected. Aborting test."
+ end
+
logger = Logger.new(stderr)
logger.formatter = proc { |severity, datetime, progname, msg| "#{severity}: #{msg}\n" }
Chef::Log.use_log_devices([logger])