summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rakefile2
-rw-r--r--cucumber.yml6
-rw-r--r--features/api/environments/create_environment_api.feature30
-rw-r--r--features/api/environments/delete_environment_api.feature28
-rw-r--r--features/api/environments/list_environments_api.feature51
-rw-r--r--features/api/environments/show_environment_api.feature34
-rw-r--r--features/api/environments/update_environment_api.feature39
-rw-r--r--features/steps/fixture_steps.rb14
8 files changed, 203 insertions, 1 deletions
diff --git a/Rakefile b/Rakefile
index e81536b373..230df0b957 100644
--- a/Rakefile
+++ b/Rakefile
@@ -319,7 +319,7 @@ begin
end
namespace :api do
- [ :nodes, :roles, :clients ].each do |api|
+ [ :nodes, :roles, :clients, :environments ].each do |api|
Cucumber::Rake::Task.new(api) do |apitask|
apitask.profile = "api_#{api.to_s}"
end
diff --git a/cucumber.yml b/cucumber.yml
index a7915f091f..e67dc1b933 100644
--- a/cucumber.yml
+++ b/cucumber.yml
@@ -19,6 +19,12 @@ api_roles_delete: --tags @roles_delete --format pretty -r features/steps -r feat
api_roles_list: --tags @roles_list --format pretty -r features/steps -r features/support features
api_roles_show: --tags @roles_show --format pretty -r features/steps -r features/support features
api_roles_update: --tags @roles_update --format pretty -r features/steps -r features/support features
+api_environments: --tags @api_environments --format pretty -r features/steps -r features/support features
+api_environments_create: --tags @environments_create --format pretty -r features/steps -r features/support features
+api_environments_delete: --tags @environments_delete --format pretty -r features/steps -r features/support 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_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/create_environment_api.feature b/features/api/environments/create_environment_api.feature
new file mode 100644
index 0000000000..4b066088c4
--- /dev/null
+++ b/features/api/environments/create_environment_api.feature
@@ -0,0 +1,30 @@
+@api @api_environments @environments_create
+Feature: Create an Environment via the REST API
+ In order to create environments programatically
+ As a developer
+ I want to create environments via the REST API
+
+ Scenario: Create a new environment
+ Given I am an administrator
+ And an 'environment' named 'cucumber'
+ When I 'POST' the 'environment' to the path '/environments'
+ Then the inflated responses key 'uri' should match 'http://.+/environments/cucumber'
+
+ Scenario: Create an environment that already exists
+ Given I am an administrator
+ And an 'environment' named 'cucumber'
+ When I 'POST' the 'environment' to the path '/environments'
+ And I 'POST' the 'environment' to the path '/environments'
+ Then I should get a '409 "Conflict"' exception
+
+ Scenario: Create an environment with the wrong private key
+ Given I am an administrator
+ And an 'environment' named 'cucumber'
+ When I 'POST' the 'environment' to the path '/environments' using a wrong private key
+ Then I should get a '401 "Unauthorized"' exception
+
+ Scenario: Create an environment as a non-admin
+ Given I am a non-admin
+ And an 'environment' named 'cucumber'
+ When I 'POST' the 'environment' to the path '/environments'
+ Then I should get a '403 "Forbidden"' exception
diff --git a/features/api/environments/delete_environment_api.feature b/features/api/environments/delete_environment_api.feature
new file mode 100644
index 0000000000..e4cc58a82d
--- /dev/null
+++ b/features/api/environments/delete_environment_api.feature
@@ -0,0 +1,28 @@
+@api @api_environments @environments_delete
+Feature: Delete environments via the REST API
+ In order to remove an environment
+ As a developer
+ I want to delete an environment via the REST API
+
+ Scenario: Delete an environment
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
+ When I 'DELETE' the path '/environments/cucumber'
+ Then the inflated response should respond to 'name' with 'cucumber'
+
+ Scenario: Delete an environment that does not exist
+ Given I am an administrator
+ When I 'DELETE' the path '/environments/graveyard'
+ Then I should get a '404 "Not Found"' exception
+
+ Scenario: Delete an environment with the wrong private key
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
+ When I 'DELETE' the path '/environments/cucumber' using a wrong private key
+ Then I should get a '401 "Unauthorized"' exception
+
+ Scenario: Delete an environment as a non-admin
+ Given I am a non-admin
+ And an 'environment' named 'cucumber' exists
+ When I 'DELETE' the path '/environments/cucumber'
+ Then I should get a '403 "Forbidden"' exception
diff --git a/features/api/environments/list_environments_api.feature b/features/api/environments/list_environments_api.feature
new file mode 100644
index 0000000000..793ca9d424
--- /dev/null
+++ b/features/api/environments/list_environments_api.feature
@@ -0,0 +1,51 @@
+@api @api_environments @environments_list
+Feature: List environments via the REST API
+ In order to know what environments exist programatically
+ As a developer
+ I want to list all the environments via the REST API
+
+ Scenario Outline: List environments when none have been created
+ Given I am <user_type>
+ And there are no environments
+ When I 'GET' the path '/environments'
+ Then the inflated response should be '0' items long
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
+
+ Scenario Outline: List the environments when one has been created
+ Given I am <user_type>
+ And an 'environment' named 'cucumber' exists
+ When I 'GET' the path '/environments'
+ Then the inflated responses key 'cucumber' should match 'http://.+/environments/cucumber'
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
+
+ Scenario Outline: List the environments when two have been created
+ Given I am <user_type>
+ And an 'environment' named 'cucumber' exists
+ And an 'environment' named 'production' exists
+ When I 'GET' the path '/environments'
+ Then the inflated response should be '2' items long
+ And the inflated responses key 'cucumber' should match 'http://.+/environments/cucumber'
+ And the inflated responses key 'production' should match 'http://.+/environments/production'
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
+
+ Scenario Outline: List environments with a wrong private key
+ Given I am <user_type>
+ When I 'GET' the path '/environments' using a wrong private key
+ Then I should get a '401 "Unauthorized"' exception
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
diff --git a/features/api/environments/show_environment_api.feature b/features/api/environments/show_environment_api.feature
new file mode 100644
index 0000000000..6c7a8e1f00
--- /dev/null
+++ b/features/api/environments/show_environment_api.feature
@@ -0,0 +1,34 @@
+@api @api_environments @environments_show
+Feature: Show an environment via the REST API
+ In order to know what the details for an environment are
+ As a developer
+ I want to show the details for a specific environment via the REST API
+
+ Scenario Outline: Show an environment
+ Given I am <user_type>
+ And an 'environment' named 'cucumber' exists
+ When I 'GET' the path '/environments/cucumber'
+ Then the inflated response should respond to 'name' with 'cucumber'
+ And the inflated response should respond to 'description' with 'I like to run tests'
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
+
+ Scenario Outline: Show an environment that does not exist
+ Given I am <user_type>
+ And there are no environments
+ When I 'GET' the path '/environments/cucumber'
+ Then I should get a '404 "Not Found"' exception
+
+ Examples:
+ | user_type |
+ | an administrator |
+ | a non-admin |
+
+ Scenario: Show an environment using the wrong private key
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
+ And I 'GET' the path '/environments/cucumber' using a wrong private key
+ Then I should get a '401 "Unauthorized"' exception
diff --git a/features/api/environments/update_environment_api.feature b/features/api/environments/update_environment_api.feature
new file mode 100644
index 0000000000..4906558f92
--- /dev/null
+++ b/features/api/environments/update_environment_api.feature
@@ -0,0 +1,39 @@
+@api @api_environments @environments_update
+Feature: Update an environment via the REST API
+ In order to keep my environment data up-to-date
+ As a developer
+ I want to update my environment via the REST API
+
+ Scenario Outline: Update an environment
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
+ And sending the method '<method>' to the 'environment' with '<updated_value>'
+ When I 'PUT' the 'environment' to the path '/environments/cucumber'
+ Then the inflated response should respond to '<method>' with '<updated_value>'
+ When I 'GET' the path '/envinronments/cucumber'
+ Then the inflated response should respond to '<method>' with '<updated_value>'
+
+ Examples:
+ | method | updated_value |
+ | description | I am a pickle |
+
+ Scenario: Update an environment that does not exist
+ Given I am an administrator
+ And an 'environment' named 'cucumber'
+ And sending the method 'description' to the 'environment' with 'This will not work'
+ When I 'PUT' the 'environment' to the path '/environments/cucumber'
+ Then I should get a '404 "Not Found"' exception
+
+ Scenario: Update an environment with the wrong private key
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
+ And sending the method 'description' to the 'environment' with 'This will not work'
+ When I 'PUT' the 'environment' to the path '/environments/cucumber' using a wrong private key
+ Then I should get a '401 "Unauthorized"' exception
+
+ Scenario: Update an environment as a non-admin user
+ Given I am a non-admin
+ And an 'environment' named 'cucumber' exists
+ And sending the method 'description' to the 'environment' with 'This will not work'
+ When I 'PUT' the 'environment' to the path '/environments/cucumber'
+ Then I should get a '403 "Forbidden"' exception
diff --git a/features/steps/fixture_steps.rb b/features/steps/fixture_steps.rb
index 433826b1b5..9a30e7ae35 100644
--- a/features/steps/fixture_steps.rb
+++ b/features/steps/fixture_steps.rb
@@ -197,6 +197,20 @@ Before do
'nothing' => Hash.new,
'name only' => { :name => 'test_cookbook' }
},
+ 'environment' => {
+ 'cucumber' => Proc.new do
+ e = Chef::Environment.new
+ e.name 'cucumber'
+ e.description 'I like to run tests'
+ e
+ end,
+ 'production' => Proc.new do
+ e = Chef::Environment.new
+ e.name 'production'
+ e.description 'The real deal'
+ e
+ end
+ }
}
@stash = {}
end