diff --git a/devops-service/features/api_v2/10_create/00_filter.feature b/devops-service/features/api_v2/10_create/00_filter.feature index a196a93..fa109f8 100644 --- a/devops-service/features/api_v2/10_create/00_filter.feature +++ b/devops-service/features/api_v2/10_create/00_filter.feature @@ -26,6 +26,53 @@ Feature: Filters """ Then response should be '406' + @openstack + Scenario: Add openstack image filter, invalid body: empty + When I send PUT '/v2.0/filter/openstack/image' query with JSON body + """ + """ + Then response should be '400' + + @openstack + Scenario: Add openstack image filter, invalid body: hash + When I send PUT '/v2.0/filter/openstack/image' query with JSON body + """ + { + "foo": "foo" + } + """ + Then response should be '400' + + @openstack + Scenario: Add openstack image filter, invalid body: element is hash + When I send PUT '/v2.0/filter/openstack/image' query with JSON body + """ + [{ + "foo": "foo" + }] + """ + Then response should be '400' + + @openstack + Scenario: Add openstack image filter, invalid body: element is array + When I send PUT '/v2.0/filter/openstack/image' query with JSON body + """ + [ + [] + ] + """ + Then response should be '400' + + @openstack + Scenario: Add openstack image filter, invalid body: element is null + When I send PUT '/v2.0/filter/openstack/image' query with JSON body + """ + [ + null + ] + """ + Then response should be '400' + @openstack Scenario: Add openstack image filter When I send PUT '/v2.0/filter/openstack/image' query with JSON body @@ -64,6 +111,53 @@ Feature: Filters """ Then response should be '406' + @ec2 + Scenario: Add ec2 image filter, invalid body: empty + When I send PUT '/v2.0/filter/ec2/image' query with JSON body + """ + """ + Then response should be '400' + + @ec2 + Scenario: Add ec2 image filter, invalid body: hash + When I send PUT '/v2.0/filter/ec2/image' query with JSON body + """ + { + "foo": "foo" + } + """ + Then response should be '400' + + @ec2 + Scenario: Add ec2 image filter, invalid body: element is hash + When I send PUT '/v2.0/filter/ec2/image' query with JSON body + """ + [{ + "foo": "foo" + }] + """ + Then response should be '400' + + @ec2 + Scenario: Add ec2 image filter, invalid body: element is array + When I send PUT '/v2.0/filter/ec2/image' query with JSON body + """ + [ + [] + ] + """ + Then response should be '400' + + @ec2 + Scenario: Add ec2 image filter, invalid body: element is null + When I send PUT '/v2.0/filter/ec2/image' query with JSON body + """ + [ + null + ] + """ + Then response should be '400' + @ec2 Scenario: Add ec2 image filter When I send PUT '/v2.0/filter/ec2/image' query with JSON body diff --git a/devops-service/features/api_v2/20_delete/99_filter.feature b/devops-service/features/api_v2/20_delete/99_filter.feature index eab631d..f3b0969 100644 --- a/devops-service/features/api_v2/20_delete/99_filter.feature +++ b/devops-service/features/api_v2/20_delete/99_filter.feature @@ -26,6 +26,53 @@ Feature: Filters """ Then response should be '406' + @openstack + Scenario: Delete openstack image filter, invalid body: empty + When I send DELETE '/v2.0/filter/openstack/image' query with JSON body + """ + """ + Then response should be '400' + + @openstack + Scenario: Delete openstack image filter, invalid body: hash + When I send DELETE '/v2.0/filter/openstack/image' query with JSON body + """ + { + "foo": "foo" + } + """ + Then response should be '400' + + @openstack + Scenario: Delete openstack image filter, invalid body: element is hash + When I send DELETE '/v2.0/filter/openstack/image' query with JSON body + """ + [{ + "foo": "foo" + }] + """ + Then response should be '400' + + @openstack + Scenario: Delete openstack image filter, invalid body: element is array + When I send DELETE '/v2.0/filter/openstack/image' query with JSON body + """ + [ + [] + ] + """ + Then response should be '400' + + @openstack + Scenario: Delete openstack image filter, invalid body: element is null + When I send DELETE '/v2.0/filter/openstack/image' query with JSON body + """ + [ + null + ] + """ + Then response should be '400' + @openstack Scenario: Delete openstack image filter When I send DELETE '/v2.0/filter/openstack/image' query with JSON body @@ -64,6 +111,53 @@ Feature: Filters """ Then response should be '406' + @ec2 + Scenario: Delete ec2 image filter, invalid body: empty + When I send DELETE '/v2.0/filter/ec2/image' query with JSON body + """ + """ + Then response should be '400' + + @ec2 + Scenario: Delete ec2 image filter, invalid body: hash + When I send DELETE '/v2.0/filter/ec2/image' query with JSON body + """ + { + "foo": "foo" + } + """ + Then response should be '400' + + @ec2 + Scenario: Delete ec2 image filter, invalid body: element is hash + When I send DELETE '/v2.0/filter/ec2/image' query with JSON body + """ + [{ + "foo": "foo" + }] + """ + Then response should be '400' + + @ec2 + Scenario: Delete ec2 image filter, invalid body: element is array + When I send DELETE '/v2.0/filter/ec2/image' query with JSON body + """ + [ + [] + ] + """ + Then response should be '400' + + @ec2 + Scenario: Delete ec2 image filter, invalid body: element is null + When I send DELETE '/v2.0/filter/ec2/image' query with JSON body + """ + [ + null + ] + """ + Then response should be '400' + @ec2 Scenario: Delete ec2 image filter When I send DELETE '/v2.0/filter/ec2/image' query with JSON body diff --git a/devops-service/routes/v2.0/filter.rb b/devops-service/routes/v2.0/filter.rb index ca58534..3be037e 100644 --- a/devops-service/routes/v2.0/filter.rb +++ b/devops-service/routes/v2.0/filter.rb @@ -14,6 +14,7 @@ module Version2_0 check_provider(params[:provider]) @images = create_object_from_json_body(Array) halt_response("Request body should not be an empty array") if @images.empty? + check_array(@images, "Request body should contains an array with strings") end after "/filter/:provider/image" do