summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorAdam Jacob <adam@opscode.com>2009-05-21 18:22:51 -0700
committerAdam Jacob <adam@opscode.com>2009-05-21 18:22:51 -0700
commit0d0f11c483869672585920042a353168a295a068 (patch)
tree1a9942fbde56f393221f0a0b2eae511dc576e1f0 /features
parentc86fb0c54b9cfbe49a3ce0c305aac04d8bf2e7b1 (diff)
downloadchef-0d0f11c483869672585920042a353168a295a068.tar.gz
Adding integration tests for the nodes REST API
Diffstat (limited to 'features')
-rw-r--r--features/api/nodes/create_node_api.feature24
-rw-r--r--features/api/nodes/delete_node_api.feature24
-rw-r--r--features/api/nodes/list_nodes_api.feature33
-rw-r--r--features/api/nodes/show_node_api.feature24
-rw-r--r--features/api/nodes/update_node_api.feature26
-rw-r--r--features/steps/fixture_steps.rb17
6 files changed, 148 insertions, 0 deletions
diff --git a/features/api/nodes/create_node_api.feature b/features/api/nodes/create_node_api.feature
new file mode 100644
index 0000000000..754c97458e
--- /dev/null
+++ b/features/api/nodes/create_node_api.feature
@@ -0,0 +1,24 @@
+Feature: Create a node via the REST API
+ In order to create nodes programatically
+ As a Devleoper
+ I want to create nodes via the REST API
+
+ Scenario: Create a new node
+ Given a 'registration' named 'bobo' exists
+ And a 'node' named 'webserver'
+ When I authenticate as 'bobo'
+ And I 'POST' the 'node' to the path '/nodes'
+ And the inflated responses key 'uri' should match '^http://.+/nodes/webserver$'
+
+ Scenario: Create a node that already exists
+ Given a 'registration' named 'bobo' exists
+ And an 'node' named 'webserver'
+ When I authenticate as 'bobo'
+ And I 'POST' the 'node' to the path '/nodes'
+ And I 'POST' the 'node' to the path '/nodes'
+ Then I should get a '403 "Forbidden"' exception
+
+ Scenario: Create a new node without authenticating
+ Given a 'node' named 'webserver'
+ When I 'POST' the 'node' to the path '/nodes'
+ Then I should get a '401 "Unauthorized"' exception
diff --git a/features/api/nodes/delete_node_api.feature b/features/api/nodes/delete_node_api.feature
new file mode 100644
index 0000000000..aea5a36d42
--- /dev/null
+++ b/features/api/nodes/delete_node_api.feature
@@ -0,0 +1,24 @@
+Feature: Delete a node via the REST API
+ In order to remove a node
+ As a Developer
+ I want to delete a node via the REST API
+
+ Scenario: Delete a node
+ Given a 'registration' named 'bobo' exists
+ And a 'node' named 'webserver' exists
+ When I authenticate as 'bobo'
+ And I 'DELETE' the path '/nodes/webserver'
+ Then the inflated response should respond to 'name' with 'webserver'
+
+ Scenario: Delete a node that does not exist
+ Given a 'registration' named 'bobo' exists
+ And there are no nodes
+ When I authenticate as 'bobo'
+ When I 'DELETE' the path '/nodes/webserver'
+ Then I should get a '404 "Not Found"' exception
+
+ Scenario: Delete a node without authenticating
+ Given a 'node' named 'webserver'
+ When I 'DELETE' the path '/nodes/webserver'
+ Then I should get a '401 "Unauthorized"' exception
+
diff --git a/features/api/nodes/list_nodes_api.feature b/features/api/nodes/list_nodes_api.feature
new file mode 100644
index 0000000000..1b13d70bec
--- /dev/null
+++ b/features/api/nodes/list_nodes_api.feature
@@ -0,0 +1,33 @@
+Feature: List nodes via the REST API
+ In order to know what nodes exists programatically
+ As a Developer
+ I want to list all the nodes
+
+ Scenario: List nodes when none have been created
+ Given a 'registration' named 'bobo' exists
+ And there are no nodes
+ When I authenticate as 'bobo'
+ And I 'GET' the path '/nodes'
+ Then the inflated response should be an empty array
+
+ Scenario: List nodes when one has been created
+ Given a 'registration' named 'bobo' exists
+ Given a 'node' named 'webserver' exists
+ When I authenticate as 'bobo'
+ And I 'GET' the path '/nodes'
+ Then the inflated response should include '^http://.+/nodes/webserver$'
+
+ Scenario: List nodes when two have been created
+ Given a 'registration' named 'bobo' exists
+ And a 'node' named 'webserver' exists
+ And a 'node' named 'dbserver' exists
+ When I authenticate as 'bobo'
+ And I 'GET' the path '/nodes'
+ Then the inflated response should be '2' items long
+ And the inflated response should include '^http://.+/nodes/webserver$'
+ And the inflated response should include '^http://.+/nodes/dbserver$'
+
+ Scenario: List nodes when you are not authenticated
+ When I 'GET' the path '/nodes'
+ Then I should get a '401 "Unauthorized"' exception
+
diff --git a/features/api/nodes/show_node_api.feature b/features/api/nodes/show_node_api.feature
new file mode 100644
index 0000000000..ca0ebf8e06
--- /dev/null
+++ b/features/api/nodes/show_node_api.feature
@@ -0,0 +1,24 @@
+Feature: Show a node via the REST API
+ In order to know what the details are for a node
+ As a Developer
+ I want to show the details for a specific node
+
+ Scenario: Show a node
+ Given a 'registration' named 'bobo' exists
+ And a 'node' named 'webserver' exists
+ When I authenticate as 'bobo'
+ And I 'GET' the path '/nodes/webserver'
+ Then the inflated response should respond to 'name' with 'webserver'
+
+ Scenario: Show a missing node
+ Given a 'registration' named 'bobo' exists
+ And there are no nodes
+ When I authenticate as 'bobo'
+ And I 'GET' the path '/nodes/bobo'
+ Then I should get a '404 "Not Found"' exception
+
+ Scenario: Show a node without authenticating
+ Given a 'node' named 'webserver' exists
+ And I 'GET' the path '/nodes/webserver'
+ Then I should get a '401 "Unauthorized"' exception
+
diff --git a/features/api/nodes/update_node_api.feature b/features/api/nodes/update_node_api.feature
new file mode 100644
index 0000000000..120335968e
--- /dev/null
+++ b/features/api/nodes/update_node_api.feature
@@ -0,0 +1,26 @@
+Feature: Update a node
+ In order to keep my node data up-to-date
+ As a Developer
+ I want to update my node via the API
+
+ Scenario Outline: Update a node
+ Given a 'registration' named 'bobo' exists
+ And a 'node' named 'webserver' exists
+ And sending the method '<method>' to the 'node' with '<updated_value>'
+ When I authenticate as 'bobo'
+ When I 'PUT' the 'node' to the path '/nodes/webserver'
+ Then the inflated response should respond to '<method>' with '<updated_value>'
+ When I 'GET' the path '/nodes/webserver'
+ Then the inflated response should respond to '<method>' with '<updated_value>'
+
+ Examples:
+ | method | updated_value |
+ | run_list | [ "recipe[one]", "recipe[two]" ] |
+ | snakes | really arent so bad |
+
+ Scenario: Update a node without authenticating
+ Given a 'node' named 'webserver'
+ And sending the method 'snakes' to the 'node' with 'night train'
+ When I 'PUT' the 'node' to the path '/nodes/webserver'
+ Then I should get a '401 "Unauthorized"' exception
+
diff --git a/features/steps/fixture_steps.rb b/features/steps/fixture_steps.rb
index 06e0aa06a6..7edf2da51b 100644
--- a/features/steps/fixture_steps.rb
+++ b/features/steps/fixture_steps.rb
@@ -30,6 +30,23 @@ Before do
r.override_attributes({ 'c' => 'down' })
r
end
+ },
+ 'node' => {
+ 'webserver' => Proc.new do
+ n = Chef::Node.new
+ n.name 'webserver'
+ n.run_list << "tacos"
+ n.snakes "on a plane"
+ n.zombie "we're not unreasonable, I mean no-ones gonna eat your eyes"
+ n
+ end,
+ 'dbserver' => Proc.new do
+ n = Chef::Node.new
+ n.name 'dbserver'
+ n.run_list << "oracle"
+ n.just "kidding - who uses oracle?"
+ n
+ end
}
}
@stash = {}