diff --git a/devops-service/tests/generate_tests.rb b/devops-service/tests/generate_tests.rb index a095a34..050dbda 100755 --- a/devops-service/tests/generate_tests.rb +++ b/devops-service/tests/generate_tests.rb @@ -30,7 +30,11 @@ class Generator < OpenStruct end templates = { + + #list "templates/api_v2/00_list/flavor.feature.erb" => "features/api_v2/00_list/flavor.feature", + + #create "templates/api_v2/10_create/00_filter.feature.erb" => "features/api_v2/10_create/00_filter.feature", "templates/api_v2/10_create/10_image.feature.erb" => "features/api_v2/10_create/10_image.feature", "templates/api_v2/10_create/20_project.feature.erb" => "features/api_v2/10_create/20_project.feature", diff --git a/devops-service/tests/templates/api_v2/10_create/10_image.feature.erb b/devops-service/tests/templates/api_v2/10_create/10_image.feature.erb index a660624..29932f2 100644 --- a/devops-service/tests/templates/api_v2/10_create/10_image.feature.erb +++ b/devops-service/tests/templates/api_v2/10_create/10_image.feature.erb @@ -516,7 +516,6 @@ Feature: Manage images @ec2 Scenario: Get info for single ec2 image When I send GET '<%= @config["ec2"]["image"] %>' query - "id": "<%= @config["ec2"]["image"] %>" Then response should be '200' And the Content-Type header should include 'application/json' And the JSON response should be an object @@ -534,13 +533,11 @@ Feature: Manage images @ec2 Scenario: Get info for single ec2 image without headers 'Accept' When I send GET '<%= @config["ec2"]["image"] %>' query without headers 'Accept' - "id": "<%= @config["ec2"]["image"] %>" Then response should be '406' @ec2 Scenario: Get ec2 image without privileges When I send GET '<%= @config["ec2"]["image"] %>' query with user without privileges - "id": "<%= @config["ec2"]["image"] %>" Then response should be '401' @openstack diff --git a/devops-service/tests/templates/api_v2/10_create/20_project.feature.erb b/devops-service/tests/templates/api_v2/10_create/20_project.feature.erb index 85f6dcd..b416f2b 100644 --- a/devops-service/tests/templates/api_v2/10_create/20_project.feature.erb +++ b/devops-service/tests/templates/api_v2/10_create/20_project.feature.erb @@ -56,4 +56,3 @@ Feature: create project } """ Then response should be '201' - diff --git a/devops-service/tests/templates/api_v2/20_update/10_image.feature.erb b/devops-service/tests/templates/api_v2/20_update/10_image.feature.erb new file mode 100644 index 0000000..e0b48a9 --- /dev/null +++ b/devops-service/tests/templates/api_v2/20_update/10_image.feature.erb @@ -0,0 +1,442 @@ +@image @project +Feature: Update images + + @openstack + Scenario: Update openstack image with ec2 provider + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid provider + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "foo", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid provider - array + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": ["foo"], + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid provider - hash + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": {}, + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid name - hash + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": {}, + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid name - array + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": [], + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid remote_user - hash + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": {}, + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid remote_user - array + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": [], + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid bootstrap_template - array + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": [], + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid bootstrap_template - hash + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": {}, + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid bootstrap_template - unknown + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "unknown", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '400' + + @openstack + Scenario: Update openstack image with invalid id - array + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": [] + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """ + + @openstack + Scenario: Update openstack image with invalid id - hash + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": {} + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """ + + @openstack + Scenario: Update openstack image + When I send PUT '/v2.0/image/<%= @config["openstack"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "freebsd-10.0", + "remote_user": "root", + "bootstrap_template": "chef_freebsd", + "id": "<%= @config["openstack"]["image"] %>" + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """ + + @ec2 + Scenario: Update ec2 image with openstack provider + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "openstack", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid provider + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "foo", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid provider - array + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": ["foo"], + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid provider - hash + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": {}, + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid name - hash + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": {}, + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid name - array + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": [], + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid remote_user - hash + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": {}, + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid remote_user - array + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": [], + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid bootstrap_template - array + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": [], + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid bootstrap_template - hash + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": {}, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid bootstrap_template - unknown + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": "unknown", + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '400' + + @ec2 + Scenario: Update ec2 image with invalid id - array + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": [] + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """ + + @ec2 + Scenario: Update ec2 image with invalid id - hash + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": {} + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """ + + @ec2 + Scenario: Update ec2 image + When I send PUT '/v2.0/image/<%= @config["ec2"]["image"] %>' query with JSON body + """ + { + "provider": "ec2", + "name": "test-ec2", + "remote_user": "ec2-user", + "bootstrap_template": null, + "id": "<%= @config["ec2"]["image"] %>" + } + """ + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an object + And response should be JSON object like: + """ + { + "message" : "Image '<%= @config["openstack"]["image"] %>' has been updated" + } + """