diff options
-rw-r--r-- | Rakefile | 6 | ||||
-rw-r--r-- | cucumber.yml | 1 | ||||
-rw-r--r-- | features/api/environments/list_environment_cookbooks_api.feature | 40 | ||||
-rw-r--r-- | features/api/nodes/cookbook_sync_api.feature | 19 | ||||
-rw-r--r-- | features/data/config/knife-stephen.rb | 12 | ||||
-rw-r--r-- | features/steps/fixture_steps.rb | 28 |
6 files changed, 106 insertions, 0 deletions
@@ -332,6 +332,12 @@ begin end end + namespace :environments do + Cucumber::Rake::Task.new("cookbooks") do |t| + t.profile = "api_environments_cookbook_list" + end + end + namespace :nodes do Cucumber::Rake::Task.new("sync") do |t| t.profile = "api_nodes_sync" diff --git a/cucumber.yml b/cucumber.yml index e67dc1b933..6ecb740c8b 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -25,6 +25,7 @@ api_environments_delete: --tags @environments_delete --format pretty -r features api_environments_list: --tags @environments_list --format pretty -r features/steps -r features/support features api_environments_show: --tags @environments_show --format pretty -r features/steps -r features/support features api_environments_update: --tags @environments_update --format pretty -r features/steps -r features/support features +api_environments_cookbook_list: --tags @environments_cookbook_list --format pretty -r features/steps -r features/support features api_nodes: --tags @api_nodes --format pretty -r features/steps -r features/support features api_nodes_sync: --tags @cookbook_sync --format pretty -r features/steps -r features/support features api_nodes_create: --tags @nodes_create --format pretty -r features/steps -r features/support features diff --git a/features/api/environments/list_environment_cookbooks_api.feature b/features/api/environments/list_environment_cookbooks_api.feature new file mode 100644 index 0000000000..65523ada93 --- /dev/null +++ b/features/api/environments/list_environment_cookbooks_api.feature @@ -0,0 +1,40 @@ +@api @api_environments @environments_cookbook_list +Feature: List cookbook versions for an environment via the REST API + In order to know what cookbooks are available in a given environment + As a developer + I was to list all cookbooks versions for a given environment via the REST API + + Scenario Outline: List cookbook versions for an environment + Given I am an administrator + And I upload multiple versions of the 'version_test' cookbook + And an 'environment' named 'cookbooks-0.1.0' exists + And I am <user_type> + When I 'GET' the path '/environments/cookbooks_test/cookbooks' + Then the inflated responses key 'version_test' should match 'http://.+/cookbooks/version_test/0\.1\.0' + + Examples: + | user_type | + | an administrator | + | a non-admin | + + Scenario Outline: List cookbook versions for an environment should restrict only the specified cookbooks + Given I am an administrator + And I upload multiple versions of the 'version_test' cookbook + And an 'environment' named '<env_name>' exists + When I 'GET' the path '/environments/cookbooks_test/cookbooks' + Then the inflated responses key 'version_test' should match 'http://.+/cookbooks/version_test/<version_regexp>' + And the inflated responses key 'attribute_include' should match 'http://.+/cookbooks/attribute_include/0.1.0' + And the inflated responses key 'attribute_settings' should match 'http://.+/cookbooks/attribute_settings/0.1.0' + And the inflated responses key 'deploy' should match 'http://.+/cookbooks/deploy/0.0.0' + + Examples: + | env_name | version_regexp | + | cookbooks-0.1.0 | 0.1.0 | + | cookbooks-0.1.1 | 0.1.1 | + | cookbooks-0.2.0 | 0.2.0 | + + Scenario: List cookbook versions for an environment with a wrong private key + Given I am an administrator + And an 'environment' named 'cookbooks-0.1.0' exists + When I 'GET' the path '/environments/cookbooks_test/cookbooks' using a wrong private key + Then I should get a '401 "Unauthorized"' exception diff --git a/features/api/nodes/cookbook_sync_api.feature b/features/api/nodes/cookbook_sync_api.feature index 2a8934a81a..ae11c81a2f 100644 --- a/features/api/nodes/cookbook_sync_api.feature +++ b/features/api/nodes/cookbook_sync_api.feature @@ -27,6 +27,25 @@ Feature: Synchronize cookbooks to the edge And the inflated responses key 'version_test' should exist And the inflated responses key 'version_test' should match '"version":"0.10.0"' as json + Scenario: Retrieve the list of cookbook files to syncronize when the node has a chef_environment + Given I am an administrator + And an 'environment' named 'cookbooks-0.1.0' exists + And a 'node' named 'has_environment' exists + And I upload multiple versions of the 'version_test' cookbook + When I 'GET' the path '/nodes/has_environment/cookbooks' + Then the inflated responses key 'version_test' should exist + And the inflated responses key 'version_test' should match '"version":"0.1.0"' as json + Given an 'environment' named 'cookbooks-0.1.1' + When I 'PUT' the 'environment' to the path '/environments/cookbooks_test' + And I 'GET' the path '/nodes/has_environment/cookbooks' + Then the inflated responses key 'version_test' should exist + And the inflated responses key 'version_test' should match '"version":"0.1.1"' as json + Given an 'environment' named 'cookbooks-0.2.0' + When I 'PUT' the 'environment' to the path '/environments/cookbooks_test' + And I 'GET' the path '/nodes/has_environment/cookbooks' + Then the inflated responses key 'version_test' should exist + And the inflated responses key 'version_test' should match '"version":"0.2.0"' as json + Scenario: Retrieve the list of cookbook files to synchronize with a wrong private key Given I am an administrator And a 'node' named 'sync' exists diff --git a/features/data/config/knife-stephen.rb b/features/data/config/knife-stephen.rb new file mode 100644 index 0000000000..c1678104a5 --- /dev/null +++ b/features/data/config/knife-stephen.rb @@ -0,0 +1,12 @@ +log_level :debug +log_location STDOUT +# Webui is an admin. +# env.rb gets the client name from Chef::Config[:web_ui_client_name] but we +# cannot use that since it won't be loaded in knife's memory. +systmpdir = File.expand_path(File.join(Dir.tmpdir, "chef_integration")) +node_name 'chef-webui' +client_key File.join(systmpdir, "webui.pem") +validation_client_name 'chef-validator' +validation_key File.join(systmpdir, "validation.pem") +chef_server_url 'http://localhost:4000' +cache_type 'BasicFile' diff --git a/features/steps/fixture_steps.rb b/features/steps/fixture_steps.rb index 62826d633b..8c52fcb06c 100644 --- a/features/steps/fixture_steps.rb +++ b/features/steps/fixture_steps.rb @@ -199,6 +199,13 @@ Before do n.name 'paradise' n.run_list << "version_test" n + end, + 'has_environment' => Proc.new do + n = Chef::Node.new + n.name 'has_environment' + n.chef_environment 'cookbooks_test' + n.run_list << "version_test" + n end }, 'hash' => { @@ -217,6 +224,27 @@ Before do e.name 'production' e.description 'The real deal' e + end, + 'cookbooks-0.1.0' => Proc.new do + e = Chef::Environment.new + e.name 'cookbooks_test' + e.description 'use cookbook version 0.1.0' + e.cookbook 'version_test', '0.1.0' + e + end, + 'cookbooks-0.1.1' => Proc.new do + e = Chef::Environment.new + e.name 'cookbooks_test' + e.description 'use cookbook version 0.1.1' + e.cookbook 'version_test', '0.1.1' + e + end, + 'cookbooks-0.2.0' => Proc.new do + e = Chef::Environment.new + e.name 'cookbooks_test' + e.description 'use cookbook version 0.2.0' + e.cookbook 'version_test', '0.2.0' + e end } } |