tests: check filter queries body

This commit is contained in:
amartynov 2014-07-04 14:19:49 +04:00
parent cb4e8d13b5
commit 8f6978e334
3 changed files with 189 additions and 0 deletions

View File

@ -26,6 +26,53 @@ Feature: Filters
""" """
Then response should be '406' 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 @openstack
Scenario: Add openstack image filter Scenario: Add openstack image filter
When I send PUT '/v2.0/filter/openstack/image' query with JSON body When I send PUT '/v2.0/filter/openstack/image' query with JSON body
@ -64,6 +111,53 @@ Feature: Filters
""" """
Then response should be '406' 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 @ec2
Scenario: Add ec2 image filter Scenario: Add ec2 image filter
When I send PUT '/v2.0/filter/ec2/image' query with JSON body When I send PUT '/v2.0/filter/ec2/image' query with JSON body

View File

@ -26,6 +26,53 @@ Feature: Filters
""" """
Then response should be '406' 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 @openstack
Scenario: Delete openstack image filter Scenario: Delete openstack image filter
When I send DELETE '/v2.0/filter/openstack/image' query with JSON body When I send DELETE '/v2.0/filter/openstack/image' query with JSON body
@ -64,6 +111,53 @@ Feature: Filters
""" """
Then response should be '406' 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 @ec2
Scenario: Delete ec2 image filter Scenario: Delete ec2 image filter
When I send DELETE '/v2.0/filter/ec2/image' query with JSON body When I send DELETE '/v2.0/filter/ec2/image' query with JSON body

View File

@ -14,6 +14,7 @@ module Version2_0
check_provider(params[:provider]) check_provider(params[:provider])
@images = create_object_from_json_body(Array) @images = create_object_from_json_body(Array)
halt_response("Request body should not be an empty array") if @images.empty? 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 end
after "/filter/:provider/image" do after "/filter/:provider/image" do