summaryrefslogtreecommitdiff
path: root/chef-config
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-01-22 18:19:01 -0800
committerdanielsdeleo <dan@chef.io>2016-01-26 18:12:46 -0800
commit16d041135ad382e9c7ace7081aa30dba520d8310 (patch)
tree6613ad2dd9391aa8403a60844439979ccbedcf66 /chef-config
parentf766e4a564688a75aebc9070269259b5d8adc4a2 (diff)
downloadchef-16d041135ad382e9c7ace7081aa30dba520d8310.tar.gz
Add test for repo_mode behavior
Diffstat (limited to 'chef-config')
-rw-r--r--chef-config/lib/chef-config/config.rb4
-rw-r--r--chef-config/spec/unit/config_spec.rb43
2 files changed, 44 insertions, 3 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index a5ccea5234..fca7429120 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -321,10 +321,8 @@ module ChefConfig
# Chef 11 server.
# * "hosted_everything": ChefFS manages all object types as of the Chef 12
# Server, including RBAC objects and Policyfile objects (new to Chef 12).
- #
- # TODO: add a test
default :repo_mode do
- if local_mode
+ if local_mode && !chef_zero.osc_compat
"hosted_everything"
elsif chef_server_url =~ /\/+organizations\/.+/
"hosted_everything"
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 5983981ddd..ed72577cf7 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -288,6 +288,49 @@ RSpec.describe ChefConfig::Config do
expect(ChefConfig::Config[:ssl_ca_path]).to be_nil
end
+ describe "ChefConfig::Config[:repo_mode]" do
+
+ context "when local mode is enabled" do
+
+ before { ChefConfig::Config[:local_mode] = true }
+
+ it "defaults to 'hosted_everything'" do
+ expect(ChefConfig::Config[:repo_mode]).to eq("hosted_everything")
+ end
+
+ context "and osc_compat is enabled" do
+
+ before { ChefConfig::Config.chef_zero.osc_compat = true }
+
+ it "defaults to 'everything'" do
+ expect(ChefConfig::Config[:repo_mode]).to eq("everything")
+ end
+ end
+ end
+
+ context "when local mode is not enabled" do
+
+ context "and the chef_server_url is multi-tenant" do
+
+ before { ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/example" }
+
+ it "defaults to 'hosted_everything'" do
+ expect(ChefConfig::Config[:repo_mode]).to eq("hosted_everything")
+ end
+
+ end
+
+ context "and the chef_server_url is not multi-tenant" do
+
+ before { ChefConfig::Config[:chef_server_url] = "https://chef.example/" }
+
+ it "defaults to 'everything'" do
+ expect(ChefConfig::Config[:repo_mode]).to eq("everything")
+ end
+ end
+ end
+ end
+
# On Windows, we'll detect an omnibus build and set this to the
# cacert.pem included in the package, but it's nil if you're on Windows
# w/o omnibus (e.g., doing development on Windows, custom build, etc.)