summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuo Yan <nuo@opscode.com>2010-11-07 17:15:19 -0800
committerNuo Yan <nuo@opscode.com>2010-11-07 17:15:33 -0800
commitcca4a1015dc8235a02492dd396f8e70f4f35d6c0 (patch)
tree18e4dc2b6153c341cd6fee859372cb100bb5a3cc
parentb2d6008a0b7ece0ef4ef4d142ace135b2492e56e (diff)
downloadchef-cca4a1015dc8235a02492dd396f8e70f4f35d6c0.tar.gz
add @oss_only tag to appropriate tests and refactor some search tests
-rw-r--r--features/api/clients/delete_client_api.feature17
-rw-r--r--features/api/clients/list_clients_api.feature3
-rw-r--r--features/api/nodes/delete_node_api.feature15
-rw-r--r--features/api/nodes/update_node_api.feature21
-rw-r--r--features/api/roles/create_role_api.feature17
-rw-r--r--features/api/roles/delete_role_api.feature17
-rw-r--r--features/api/roles/list_roles_api.feature6
-rw-r--r--features/api/search/show_search.feature74
-rw-r--r--features/steps/response_steps.rb12
-rw-r--r--features/steps/search_steps.rb26
10 files changed, 118 insertions, 90 deletions
diff --git a/features/api/clients/delete_client_api.feature b/features/api/clients/delete_client_api.feature
index 1d857e98fe..62f4b2373b 100644
--- a/features/api/clients/delete_client_api.feature
+++ b/features/api/clients/delete_client_api.feature
@@ -1,27 +1,28 @@
@api @api_clients @clients_delete
-Feature: Delete a client via the REST API
- In order to remove a client
- As a Developer
+Feature: Delete a client via the REST API
+ In order to remove a client
+ As a Developer
I want to delete a client via the REST API
-
- Scenario: Delete a client
+
+ Scenario: Delete a client
Given I am an administrator
And a 'client' named 'isis' exists
When I 'DELETE' the path '/clients/isis'
- Then the inflated responses key 'name' should match '^isis$'
+ Then the inflated responses key 'name' should match '^isis$'
Scenario: Delete a client that does not exist
Given I am an administrator
- And there are no clients
+ And there are no clients
When I 'DELETE' the path '/clients/isis'
Then I should get a '404 "Not Found"' exception
-
+
Scenario: Delete a client with a wrong private key
Given I am an administrator
And a 'client' named 'isis' exists
When I 'DELETE' the path '/clients/isis' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: Delete a client when you are not an admin
Given I am a non-admin
And a 'client' named 'isis' exists
diff --git a/features/api/clients/list_clients_api.feature b/features/api/clients/list_clients_api.feature
index e881d16396..ba8f224990 100644
--- a/features/api/clients/list_clients_api.feature
+++ b/features/api/clients/list_clients_api.feature
@@ -20,10 +20,11 @@ Feature: List clients via the REST API
Scenario: List clients when none have been created with a wrong private key
Given I am an administrator
- And there are no clients
+ And there are no clients
When I 'GET' the path '/clients' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: List clients when one has been created and you are not an admin
Given I am a non-admin
Given a 'client' named 'isis' exists
diff --git a/features/api/nodes/delete_node_api.feature b/features/api/nodes/delete_node_api.feature
index 68d82eae24..b7d585de51 100644
--- a/features/api/nodes/delete_node_api.feature
+++ b/features/api/nodes/delete_node_api.feature
@@ -1,18 +1,18 @@
@api @api_nodes @nodes_delete
-Feature: Delete a node via the REST API
- In order to remove a node
- As a Developer
+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
+
+ Scenario: Delete a node
Given I am an administrator
And a 'node' named 'webserver' exists
When I 'DELETE' the path '/nodes/webserver'
- Then the inflated response should respond to 'name' with 'webserver'
+ Then the inflated response should respond to 'name' with 'webserver'
Scenario: Delete a node that does not exist
Given I am an administrator
- And there are no nodes
+ And there are no nodes
When I 'DELETE' the path '/nodes/webserver'
Then I should get a '404 "Not Found"' exception
@@ -22,6 +22,7 @@ Feature: Delete a node via the REST API
When I 'DELETE' the path '/nodes/webserver' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: Delete a node as a when I am not an admin
Given I am a non-admin
And a 'node' named 'webserver' exists
diff --git a/features/api/nodes/update_node_api.feature b/features/api/nodes/update_node_api.feature
index a370568738..372734f6d3 100644
--- a/features/api/nodes/update_node_api.feature
+++ b/features/api/nodes/update_node_api.feature
@@ -2,21 +2,21 @@
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
+ I want to update my node via the API
- Scenario Outline: Update a node
+ Scenario Outline: Update a node
Given I am an administrator
And a 'node' named 'webserver' exists
And sending the method '<method>' to the 'node' with '<updated_value>'
- When I 'PUT' the 'node' to the path '/nodes/webserver'
- Then the inflated response should respond to '<method>' with '<updated_value>'
+ 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>'
+ 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 |
+ | snakes | really arent so bad |
@PL-493
Scenario: Update a node to include a role which includes another role
@@ -24,7 +24,7 @@ Feature: Update a node
And a 'node' named 'webserver' exists
And sending the method 'run_list' to the 'node' with '[ "role[role1_includes_role2]" ]'
When I 'PUT' the 'node' to the path '/nodes/webserver'
- Then the inflated response should respond to 'run_list' with '[ "role[role1_includes_role2]" ]'
+ Then the inflated response should respond to 'run_list' with '[ "role[role1_includes_role2]" ]'
When I 'GET' the path '/nodes/webserver'
Then the inflated response should respond to 'run_list' with '[ "role[role1_includes_role2]" ]'
@@ -35,19 +35,20 @@ Feature: Update a node
When I 'PUT' the 'node' to the path '/nodes/webserver' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: Update a node when I am not an admin
Given I am a non-admin
And a 'node' named 'webserver' exists
And sending the method 'run_list' to the 'node' with '[ "recipe[one]", "recipe[two]" ]'
When I 'PUT' the 'node' to the path '/nodes/webserver'
Then I should get a '403 "Forbidden"' exception
-
+
Scenario: Update a node with a role that does not exist
Given I am an administrator
And a 'node' named 'webserver' exists
And sending the method 'run_list' to the 'node' with '["role[not_exist]"]'
- When I 'PUT' the 'node' to the path '/nodes/webserver'
- Then the inflated response should respond to 'run_list' with '["role[not_exist]"]'
+ When I 'PUT' the 'node' to the path '/nodes/webserver'
+ Then the inflated response should respond to 'run_list' with '["role[not_exist]"]'
When I 'GET' the path '/nodes/webserver'
Then the inflated response should respond to 'run_list' with '["role[not_exist]"]'
diff --git a/features/api/roles/create_role_api.feature b/features/api/roles/create_role_api.feature
index d74533c3a4..914d37abaf 100644
--- a/features/api/roles/create_role_api.feature
+++ b/features/api/roles/create_role_api.feature
@@ -1,20 +1,20 @@
@api @api_roles @roles_create
Feature: Create a role via the REST API
- In order to create roles programatically
+ In order to create roles programatically
As a Devleoper
I want to create roles via the REST API
-
- Scenario: Create a new role
+
+ Scenario: Create a new role
Given I am an administrator
And a 'role' named 'webserver'
- When I 'POST' the 'role' to the path '/roles'
+ When I 'POST' the 'role' to the path '/roles'
And the inflated responses key 'uri' should match '^http://.+/roles/webserver$'
Scenario: Create a role that already exists
Given I am an administrator
And an 'role' named 'webserver'
- When I 'POST' the 'role' to the path '/roles'
- And I 'POST' the 'role' to the path '/roles'
+ When I 'POST' the 'role' to the path '/roles'
+ And I 'POST' the 'role' to the path '/roles'
Then I should get a '409 "Conflict"' exception
Scenario: Create a new role with a wrong private key
@@ -23,16 +23,17 @@ Feature: Create a role via the REST API
When I 'POST' the 'role' to the path '/roles' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: Create a new role as a non-admin
Given I am a non-admin
And a 'role' named 'webserver'
- When I 'POST' the 'role' to the path '/roles'
+ When I 'POST' the 'role' to the path '/roles'
Then I should get a '403 "Forbidden"' exception
Scenario: Create a role with a role that does not exist
Given I am an administrator
And an 'role' named 'role_not_exist'
- When I 'POST' the 'role' to the path '/roles'
+ When I 'POST' the 'role' to the path '/roles'
Then the inflated responses key 'uri' should match '^http://.+/roles/role_not_exist$'
When I 'GET' the path '/roles/role_not_exist'
Then the stringified response should be the stringified 'role' \ No newline at end of file
diff --git a/features/api/roles/delete_role_api.feature b/features/api/roles/delete_role_api.feature
index c7bd9f05c0..d1e28c15f0 100644
--- a/features/api/roles/delete_role_api.feature
+++ b/features/api/roles/delete_role_api.feature
@@ -1,27 +1,28 @@
@api @api_roles @roles_delete
-Feature: Delete a Role via the REST API
- In order to remove a role
- As a Developer
+Feature: Delete a Role via the REST API
+ In order to remove a role
+ As a Developer
I want to delete a role via the REST API
-
- Scenario: Delete a Role
+
+ Scenario: Delete a Role
Given I am an administrator
And a 'role' named 'webserver' exists
When I 'DELETE' the path '/roles/webserver'
- Then the inflated response should respond to 'name' with 'webserver'
+ Then the inflated response should respond to 'name' with 'webserver'
Scenario: Delete a Role that does not exist
Given I am an administrator
- And there are no roles
+ And there are no roles
When I 'DELETE' the path '/roles/webserver'
Then I should get a '404 "Not Found"' exception
-
+
Scenario: Delete a Role with a wrong private key
Given I am an administrator
And a 'role' named 'webserver' exists
When I 'DELETE' the path '/roles/webserver' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
+ @oss_only
Scenario: Delete a Role as a non-admin
Given I am a non-admin
And a 'role' named 'webserver' exists
diff --git a/features/api/roles/list_roles_api.feature b/features/api/roles/list_roles_api.feature
index 2a952fe5ba..29881e905a 100644
--- a/features/api/roles/list_roles_api.feature
+++ b/features/api/roles/list_roles_api.feature
@@ -15,13 +15,13 @@ Feature: List roles via the REST API
And a 'role' named 'webserver' exists
And a 'role' named 'db' exists
When I 'GET' the path '/roles'
- Then the inflated responses key 'role_test' should match '^http://.+/roles/role_test$'
- And the inflated responses key 'webserver' should match '^http://.+/roles/webserver$'
+# Then the inflated responses key 'role_test' should match '^http://.+/roles/role_test$'
+ Then the inflated responses key 'webserver' should match '^http://.+/roles/webserver$'
And the inflated responses key 'db' should match '^http://.+/roles/db$'
Scenario: List roles when none have been created with a wrong private key
Given I am an administrator
- And there are no roles
+ And there are no roles
When I 'GET' the path '/roles' using a wrong private key
Then I should get a '401 "Unauthorized"' exception
diff --git a/features/api/search/show_search.feature b/features/api/search/show_search.feature
index 74dc011d96..3612907f0b 100644
--- a/features/api/search/show_search.feature
+++ b/features/api/search/show_search.feature
@@ -2,13 +2,13 @@
Feature: Search data via the REST API
In order to know about objects in the system
As a Developer
- I want to search the objects
+ I want to search the objects
Scenario: Search for objects when none have been created
Given I am an administrator
And a 'data_bag' named 'users' exists
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users'
+ And I 'GET' the path '/search/users'
Then the inflated responses key 'rows' should be '0' items long
And the inflated responses key 'start' should be the integer '0'
And the inflated responses key 'total' should be the integer '0'
@@ -17,96 +17,92 @@ Feature: Search data via the REST API
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users'
- Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
- And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
- And the inflated responses key 'start' should be the integer '0'
- And the inflated responses key 'total' should be the integer '1'
+ And I 'GET' the path '/search/users'
+ Then a 'Chef::DataBagItem' with id 'francis' should be in the search result
+ And there should be '1' total search results
Scenario: Search for objects when two have been created
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
And a 'data_bag_item' named 'axl_rose' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users'
- Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
- And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
- And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
- And the inflated responses key 'rows' item '1' key 'id' should be 'axl_rose'
- And the inflated responses key 'start' should be the integer '0'
- And the inflated responses key 'total' should be the integer '2'
+ And I 'GET' the path '/search/users'
+ Then a 'Chef::DataBagItem' with id 'francis' should be in the search result
+ And a 'Chef::DataBagItem' with id 'axl_rose' should be in the search result
+ And there should be '2' total search results
- Scenario: Search for objects with a manual ascending sort order
+ @oss_only
+ Scenario: Search for objects with a manual ascending sort order
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
And a 'data_bag_item' named 'axl_rose' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users?sort=id+asc'
+ And I 'GET' the path '/search/users?sort=id+asc'
Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '1' key 'id' should be 'francis'
And the inflated responses key 'start' should be the integer '0'
- And the inflated responses key 'total' should be the integer '2'
+ And the inflated responses key 'total' should be the integer '2'
- Scenario: Search for objects with a manual descending sort order
+ @oss_only
+ Scenario: Search for objects with a manual descending sort order
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
And a 'data_bag_item' named 'axl_rose' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users?sort=id+desc'
+ And I 'GET' the path '/search/users?sort=id+desc'
Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '1' key 'id' should be 'axl_rose'
And the inflated responses key 'start' should be the integer '0'
- And the inflated responses key 'total' should be the integer '2'
+ And the inflated responses key 'total' should be the integer '2'
+ @oss_only
Scenario: Search for objects and page through the results
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
And a 'data_bag_item' named 'axl_rose' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users?rows=1&sort=id+asc'
+ And I 'GET' the path '/search/users?rows=1&sort=id+asc'
Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
And the inflated responses key 'rows' should be '1' items long
And the inflated responses key 'start' should be the integer '0'
And the inflated responses key 'total' should be the integer '2'
- When I 'GET' the path '/search/users?rows=1&start=1&sort=id+asc'
+ When I 'GET' the path '/search/users?rows=1&start=1&sort=id+asc'
Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
And the inflated responses key 'rows' should be '1' items long
And the inflated responses key 'start' should be the integer '1'
And the inflated responses key 'total' should be the integer '2'
- Scenario: Search for a subset of objects
+ Scenario: Search for a subset of objects
Given I am an administrator
And a 'data_bag' named 'users' exists
And a 'data_bag_item' named 'francis' exists
And a 'data_bag_item' named 'axl_rose' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
- And I 'GET' the path '/search/users?q=id:axl_rose'
- Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
- And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
- And the inflated responses key 'start' should be the integer '0'
- And the inflated responses key 'total' should be the integer '1'
+ And I 'GET' the path '/search/users?q=id:axl_rose'
+ Then a 'Chef::DataBagItem' with id 'axl_rose' should be in the search result
+ And there should be '1' total search results
- Scenario: Search for a node
+ Scenario: Search for a node
Given I am an administrator
And a 'node' named 'searchman' exists
- And I wait for '15' seconds
+ And the search index has been committed
When I authenticate as 'bobo'
And I 'GET' the path '/search/node?q=recipe:oracle'
Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::Node'
@@ -114,13 +110,13 @@ Feature: Search data via the REST API
And the inflated responses key 'rows' item '0' key 'three' should be 'four'
And the inflated responses key 'rows' item '0' key 'walking' should be 'tall'
- Scenario: Search for a type of object that does not exist
+ Scenario: Search for a type of object that does not exist
Given I am an administrator
When I authenticate as 'bobo'
And I 'GET' the path '/search/funkensteins'
Then I should get a '404 "Not Found"' exception
- Scenario: Search for objects when you are not authenticated
- When I 'GET' the path '/search/users'
+ Scenario: Search for objects when you are not authenticated
+ When I 'GET' the path '/search/users'
Then I should get a '401 "Unauthorized"' exception
diff --git a/features/steps/response_steps.rb b/features/steps/response_steps.rb
index 3e2813d3dc..37480b7108 100644
--- a/features/steps/response_steps.rb
+++ b/features/steps/response_steps.rb
@@ -23,7 +23,7 @@ end
Then /^the inflated responses key '(.+)' should match '(.+)'$/ do |key, regex|
puts self.inflated_response.inspect if ENV['DEBUG']
- self.inflated_response[key].should =~ /#{regex}/m
+ self.inflated_response[key].should =~ /#{regex}/m
end
Then /^the inflated responses key '(.+)' should be literally '(.+)'$/ do |key, literal|
@@ -35,7 +35,7 @@ Then /^the inflated responses key '(.+)' should be literally '(.+)'$/ do |key, l
false
end
- self.inflated_response[key].should == to_check
+ self.inflated_response[key].should == to_check
end
Then /^the inflated response should match '(.+)' as json$/ do |regex|
@@ -64,7 +64,7 @@ Then /^the inflated responses key '(.+)' sub-key '(.+)' should be an empty hash$
inflated_response[key][sub_key].should == {}
end
-Then /^the inflated responses key '(.+)' should be '(\d+)' items long$/ do |key, length|
+Then /^the inflated responses key '(.+)' should be '(\d+)' items long$/ do |key, length|
inflated_response[key].length.should == length.to_i
end
@@ -73,7 +73,7 @@ Then /^the inflated responses key '(.+)' should not exist$/ do |key|
end
Then /^the inflated responses key '(.+)' should exist$/ do |key|
- self.inflated_response.has_key?(key).should == true
+ self.inflated_response.has_key?(key).should == true
end
Then /^the inflated responses key '(.+)'.to_s should be '(.+)'$/ do |key, expected_value|
@@ -85,7 +85,7 @@ Then /^the inflated response should be an empty array$/ do
end
Then /^the inflated response should be an empty hash$/ do
- self.inflated_response.should == {}
+ self.inflated_response.should == {}
end
Then /^the inflated response should include '(.+)'$/ do |entry|
@@ -138,7 +138,7 @@ Then /^the inflated response should respond to '(.+)' with '(.+)'$/ do |method,
to_match = JSON.parse(to_match) if to_match =~ /^\[|\{/
to_match = true if to_match == 'true'
to_match = false if to_match == 'false'
- self.inflated_response.to_hash[method].should == to_match
+ self.inflated_response.to_hash[method].should == to_match
end
Then /^the inflated response should respond to '(.+)' and match '(.+)'$/ do |method, to_match|
diff --git a/features/steps/search_steps.rb b/features/steps/search_steps.rb
new file mode 100644
index 0000000000..1d165abc97
--- /dev/null
+++ b/features/steps/search_steps.rb
@@ -0,0 +1,26 @@
+Given "the search index has been committed" do
+ sleep 1 # allow time for the objects to transit rabbitmq and opscode-expander.
+ RestClient.get("http://localhost:8983/solr/update?commit=true&waitFlush=true")
+end
+
+Then "there should be '$expected_count' total search results" do |expected_count|
+ expected_count = expected_count.to_i
+ inflated_response.should respond_to(:[])
+ inflated_response.should have_key("total")
+ inflated_response["total"].should == expected_count
+end
+
+Then "a '$result_item_klass' with id '$result_item_id' should be in the search result" do |result_item_klass, result_item_id|
+ inflated_response.should respond_to(:[])
+ inflated_response.should have_key("rows")
+
+ result_item = inflated_response["rows"].find {|item| item["id"] == result_item_id }
+ unless result_item
+ msg = "expected to find a #{result_item_klass} with 'id' #{result_item_id} in the inflated response but it's not there\n"
+ msg << "actual inflated response is #{inflated_response.inspect}"
+ raise msg
+ end
+ expected_klass = eval(result_item_klass)
+
+ result_item.should be_a_kind_of(expected_klass)
+end \ No newline at end of file