summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-01-27 15:51:04 -0800
committerJohn Keiser <john@johnkeiser.com>2016-02-01 08:08:13 -0800
commit2c471e0c7bf0e79017e65a78b59b59bd78b92152 (patch)
treea048d328e369f7fadeed1c88902ae1692fda0bad
parente39cc95d16188a88a9ae0ca1b8ec4c41ff4a983f (diff)
downloadchef-2c471e0c7bf0e79017e65a78b59b59bd78b92152.tar.gz
Adjust tests for ACLs
-rw-r--r--Gemfile2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb1
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb17
-rw-r--r--spec/integration/knife/download_spec.rb9
-rw-r--r--spec/integration/knife/list_spec.rb33
5 files changed, 60 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index 2c37e6c7d4..e20618825c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -51,6 +51,8 @@ group(:travis) do
gem "bundler-audit", git: "https://github.com/rubysec/bundler-audit.git", ref: "4e32fca"
end
+gem "chef-zero", github: "chef/chef-zero", branch: "cd/run-acl-specs"
+
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
# If you want to load debugging tools into the bundle exec sandbox,
diff --git a/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb b/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb
index 1b1e036585..d72b90f5c0 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb
@@ -28,6 +28,7 @@ class Chef
# and make one acls/policies/NAME.json for each one.
def children
if @children.nil?
+ # /acls/policies -> List ../../policies
names = parent.parent.child(name).children.map { |child| "#{child.policy_name}.json" }
@children = names.uniq.map { |name| make_child_entry(name, true) }
end
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index 145adc3e4c..b836ebac82 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -37,6 +37,7 @@ describe "ChefFSDataStore tests", :workstation do
when_the_repository "has one of each thing" do
before do
file "clients/x.json", {}
+ file "cookbook_artifacts/x-111/metadata.rb", cookbook_x_100_metadata_rb
file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb
file "data_bags/x/y.json", {}
file "environments/x.json", {}
@@ -47,18 +48,20 @@ describe "ChefFSDataStore tests", :workstation do
file "groups/x.json", {}
file "containers/x.json", {}
file "groups/x.json", {}
- file "policies/x.json", {}
+ file "policies/x-111.json", {}
file "policy_groups/x.json", {}
end
context "GET /TYPE" do
- it "knife list -z -R returns everything" do
+ it "knife list -z -R returns everything", :focus do
knife("list -z -Rfp /").should_succeed <<EOM
/acls/
/acls/clients/
/acls/clients/x.json
/acls/containers/
/acls/containers/x.json
+/acls/cookbook_artifacts/
+/acls/cookbook_artifacts/x.json
/acls/cookbooks/
/acls/cookbooks/x.json
/acls/data_bags/
@@ -70,6 +73,10 @@ describe "ChefFSDataStore tests", :workstation do
/acls/nodes/
/acls/nodes/x.json
/acls/organization.json
+/acls/policies/
+/acls/policies/x.json
+/acls/policy_groups/
+/acls/policy_groups/x.json
/acls/roles/
/acls/roles/x.json
/clients/
@@ -77,6 +84,8 @@ describe "ChefFSDataStore tests", :workstation do
/containers/
/containers/x.json
/cookbook_artifacts/
+/cookbook_artifacts/x-111/
+/cookbook_artifacts/x-111/metadata.rb
/cookbooks/
/cookbooks/x/
/cookbooks/x/metadata.rb
@@ -93,6 +102,7 @@ describe "ChefFSDataStore tests", :workstation do
/nodes/x.json
/org.json
/policies/
+/policies/x-111.json
/policy_groups/
/policy_groups/x.json
/roles/
@@ -287,12 +297,15 @@ EOM
/acls/
/acls/clients/
/acls/containers/
+/acls/cookbook_artifacts/
/acls/cookbooks/
/acls/data_bags/
/acls/environments/
/acls/groups/
/acls/nodes/
/acls/organization.json
+/acls/policies/
+/acls/policy_groups/
/acls/roles/
/clients/
/containers/
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index 86f1d9f4a4..c6755cccaa 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -1120,8 +1120,10 @@ Created /acls/containers/environments.json
Created /acls/containers/groups.json
Created /acls/containers/nodes.json
Created /acls/containers/policies.json
+Created /acls/containers/policy_groups.json
Created /acls/containers/roles.json
Created /acls/containers/sandboxes.json
+Created /acls/cookbook_artifacts
Created /acls/cookbooks
Created /acls/data_bags
Created /acls/environments
@@ -1132,6 +1134,8 @@ Created /acls/groups/billing-admins.json
Created /acls/groups/clients.json
Created /acls/groups/users.json
Created /acls/nodes
+Created /acls/policies
+Created /acls/policy_groups
Created /acls/roles
Created /acls/organization.json
Created /clients
@@ -1146,6 +1150,7 @@ Created /containers/environments.json
Created /containers/groups.json
Created /containers/nodes.json
Created /containers/policies.json
+Created /containers/policy_groups.json
Created /containers/roles.json
Created /containers/sandboxes.json
Created /cookbook_artifacts
@@ -1196,11 +1201,15 @@ EOM
knife("download /acls /groups/clients.json /groups/users.json").should_succeed <<-EOM
Created /acls/clients/x.json
Created /acls/containers/x.json
+Created /acls/cookbook_artifacts/x.json
Created /acls/cookbooks/x.json
Created /acls/data_bags/x.json
Created /acls/environments/x.json
Created /acls/groups/x.json
Created /acls/nodes/x.json
+Created /acls/policies/blah.json
+Created /acls/policies/x.json
+Created /acls/policy_groups/x.json
Created /acls/roles/x.json
Updated /groups/clients.json
Updated /groups/users.json
diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb
index 85eb959847..0db7831518 100644
--- a/spec/integration/knife/list_spec.rb
+++ b/spec/integration/knife/list_spec.rb
@@ -698,12 +698,15 @@ roles
/acls:
clients
containers
+cookbook_artifacts
cookbooks
data_bags
environments
groups
nodes
organization.json
+policies
+policy_groups
roles
/acls/clients:
@@ -719,9 +722,12 @@ environments.json
groups.json
nodes.json
policies.json
+policy_groups.json
roles.json
sandboxes.json
+/acls/cookbook_artifacts:
+
/acls/cookbooks:
/acls/data_bags:
@@ -737,6 +743,10 @@ users.json
/acls/nodes:
+/acls/policies:
+
+/acls/policy_groups:
+
/acls/roles:
/clients:
@@ -752,6 +762,7 @@ environments.json
groups.json
nodes.json
policies.json
+policy_groups.json
roles.json
sandboxes.json
@@ -803,12 +814,15 @@ roles
/acls:
clients
containers
+cookbook_artifacts
cookbooks
data_bags
environments
groups
nodes
organization.json
+policies
+policy_groups
roles
/acls/clients:
@@ -824,9 +838,12 @@ environments.json
groups.json
nodes.json
policies.json
+policy_groups.json
roles.json
sandboxes.json
+/acls/cookbook_artifacts:
+
/acls/cookbooks:
/acls/data_bags:
@@ -842,6 +859,10 @@ users.json
/acls/nodes:
+/acls/policies:
+
+/acls/policy_groups:
+
/acls/roles:
/clients:
@@ -857,6 +878,7 @@ environments.json
groups.json
nodes.json
policies.json
+policy_groups.json
roles.json
sandboxes.json
@@ -935,8 +957,12 @@ EOM
/acls/containers/groups.json
/acls/containers/nodes.json
/acls/containers/policies.json
+/acls/containers/policy_groups.json
/acls/containers/roles.json
/acls/containers/sandboxes.json
+/acls/cookbook_artifacts/
+/acls/cookbook_artifacts/cookbook_artifact1.json
+/acls/cookbook_artifacts/cookbook_artifact2.json
/acls/cookbooks/
/acls/cookbooks/cookbook1.json
/acls/cookbooks/cookbook2.json
@@ -958,6 +984,12 @@ EOM
/acls/nodes/node1.json
/acls/nodes/node2.json
/acls/organization.json
+/acls/policies/
+/acls/policies/policy1.json
+/acls/policies/policy2.json
+/acls/policy_groups/
+/acls/policy_groups/policy_group1.json
+/acls/policy_groups/policy_group2.json
/acls/roles/
/acls/roles/role1.json
/acls/roles/role2.json
@@ -977,6 +1009,7 @@ EOM
/containers/groups.json
/containers/nodes.json
/containers/policies.json
+/containers/policy_groups.json
/containers/roles.json
/containers/sandboxes.json
/cookbook_artifacts/