added template for create features

This commit is contained in:
Tim Lianov 2014-07-15 01:36:31 +04:00
parent fa4ac495c9
commit 08667ea83e
6 changed files with 859 additions and 1 deletions

View File

@ -26,10 +26,15 @@ class Generator < OpenStruct
def render(template)
ERB.new(template).result(binding)
end
end
templates = {
"templates/api_v2/00_list/flavor.feature.erb" => "features/api_v2/00_list/flavor.feature"
"templates/api_v2/00_list/flavor.feature.erb" => "features/api_v2/00_list/flavor.feature",
"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",
"templates/api_v2/10_create/30_script.feature.erb" => "features/api_v2/10_create/30_script.feature"
}
generator = Generator.new
generator.make_tests_config

View File

@ -20,3 +20,6 @@ ec2:
project:
name: "test_ec2"
env: "test"
script:
name: "cucumber_test_script"

View File

@ -0,0 +1,192 @@
@filter @image @project
Feature: Filters
@openstack
Scenario: Add openstack image filter with user without privileges
When I send PUT '/v2.0/filter/openstack/image' query with user without privileges
Then response should be '401'
@openstack
Scenario: Add openstack image filter without header 'Accept'
When I send PUT '/v2.0/filter/openstack/image' query with JSON body without header 'Accept'
"""
[
"<%= @config["openstack"]["image"] %>"
]
"""
Then response should be '406'
@openstack
Scenario: Add openstack image filter without header 'Content-Type'
When I send PUT '/v2.0/filter/openstack/image' query with JSON body without header 'Content-Type'
"""
[
"<%= @config["openstack"]["image"] %>"
]
"""
Then response should be '415'
@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
"""
[
"<%= @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 the object should contains key 'images' with array and array should contains strings '<%= @config["openstack"]["image"] %>'
@openstack
Scenario: Add openstack image filter with invalid JSON
When I send PUT '/v2.0/filter/openstack/image' query with body
"""
[
"<%= @config["openstack"]["image"] %>"
]
"""
Then response should be '400'
@ec2
Scenario: Add ec2 image filter with user without privileges
When I send PUT '/v2.0/filter/ec2/image' query with user without privileges
Then response should be '401'
@ec2
Scenario: Add ec2 image filter without header 'Accept'
When I send PUT '/v2.0/filter/ec2/image' query with JSON body without header 'Accept'
"""
[
"<%= @config["ec2"]["image"] %>"
]
"""
Then response should be '406'
@ec2
Scenario: Add ec2 image filter without header 'Content-Type'
When I send PUT '/v2.0/filter/ec2/image' query with JSON body without header 'Content-Type'
"""
[
"<%= @config["ec2"]["image"] %>"
]
"""
Then response should be '415'
@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
"""
[
"<%= @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 the object should contains key 'images' with array and array should contains strings '<%= @config["ec2"]["image"] %>'
@ec2
Scenario: Add ec2 image filter with invalid JSON
When I send PUT '/v2.0/filter/ec2/image' query with body
"""
[
"<%= @config["ec2"]["image"] %>"
]
"""
Then response should be '400'

View File

@ -0,0 +1,579 @@
@image @project
Feature: Manage images
Scenario: Get list of all images
When I send GET '/v2.0/images' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should contains elements like:
"""
[
{
"provider": "foo_provider",
"name": "foo_name",
"remote_user": "foo_user",
"bootstrap_template": "foo_template",
"id": "foo_id"
}
]
"""
Scenario: Get list of all images without header 'Accept'
When I send GET '/v2.0/images' query without headers 'Accept'
Then response should be '406'
Scenario: Get list of all images without privileges
When I send GET '/v2.0/images' query with user without privileges
Then response should be '401'
Scenario: Get list of all images - invalid path
When I send GET '/v2.0/images/foo' query
Then response should be '404'
@openstack
Scenario: Get list of openstack images
When I send GET '/v2.0/images?provider=openstack' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should contains elements like:
"""
[
{
"provider": "foo_provider",
"name": "foo_name",
"remote_user": "foo_user",
"bootstrap_template": "foo_template",
"id": "foo_id"
}
]
"""
@openstack
Scenario: Get list of openstack images (provider)
When I send GET '/v2.0/images/provider/openstack' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
@openstack
Scenario: Get list of openstack images (provider) without header 'Accept'
When I send GET '/v2.0/images/provider/openstack' query without headers 'Accept'
Then response should be '406'
@openstack
Scenario: Get images list of openstack without privileges
When I send GET '/v2.0/images/provider/openstack' query with user without privileges
Then response should be '401'
@ec2
Scenario: Get list of ec2 images
When I send GET '/v2.0/images?provider=ec2' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should contains elements like:
"""
[
{
"provider": "foo_provider",
"name": "foo_name",
"remote_user": "foo_user",
"bootstrap_template": "foo_template",
"id": "foo_id"
}
]
"""
@ec2
Scenario: Get list of ec2 images (provider)
When I send GET '/v2.0/images/provider/ec2' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
@ec2
Scenario: Get list of ec2 images (provider) without header 'Accept'
When I send GET '/v2.0/images/provider/ec2' query without headers 'Accept'
Then response should be '406'
@ec2
Scenario: Get images list of ec2 without privileges
When I send GET '/v2.0/images/provider/ec2' query with user without privileges
Then response should be '401'
Scenario: Get list of images of unknown provider
When I send GET '/v2.0/images/provider/foo' query
Then response should be '404'
Scenario: Get images list without privileges
When I send GET '/v2.0/images' query with user without privileges
Then response should be '401'
Scenario: Get unknown image
When I send GET '/v2.0/image/foo' query
Then response should be '404'
Scenario: Get unknown image without privileges
When I send GET '/v2.0/image/foo' query with user without privileges
Then response should be '401'
@openstack
Scenario: Create openstack image with ec2 provider
When I send POST '/v2.0/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: Create openstack image with invalid provider
When I send POST '/v2.0/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: Create openstack image with invalid provider - array
When I send POST '/v2.0/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: Create openstack image with invalid provider - hash
When I send POST '/v2.0/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: Create openstack image with invalid name - hash
When I send POST '/v2.0/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: Create openstack image with invalid name - array
When I send POST '/v2.0/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: Create openstack image with invalid remote_user - hash
When I send POST '/v2.0/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: Create openstack image with invalid remote_user - array
When I send POST '/v2.0/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: Create openstack image with invalid bootstrap_template - array
When I send POST '/v2.0/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: Create openstack image with invalid bootstrap_template - hash
When I send POST '/v2.0/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: Create openstack image with invalid bootstrap_template - unknown
When I send POST '/v2.0/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: Create openstack image with invalid id - array
When I send POST '/v2.0/image' query with JSON body
"""
{
"provider": "openstack",
"name": "freebsd-10.0",
"remote_user": "root",
"bootstrap_template": "chef_freebsd",
"id": []
}
"""
Then response should be '400'
@openstack
Scenario: Create openstack image with invalid id - hash
When I send POST '/v2.0/image' query with JSON body
"""
{
"provider": "openstack",
"name": "freebsd-10.0",
"remote_user": "root",
"bootstrap_template": "chef_freebsd",
"id": {}
}
"""
Then response should be '400'
@openstack
Scenario: Create openstack image
When I send POST '/v2.0/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 '201'
And the Content-Type header should include 'application/json'
@ec2
Scenario: Create ec2 image with openstack provider
When I send POST '/v2.0/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: Create ec2 image with invalid provider
When I send POST '/v2.0/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: Create ec2 image with invalid provider - array
When I send POST '/v2.0/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: Create ec2 image with invalid provider - hash
When I send POST '/v2.0/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: Create ec2 image with invalid name - hash
When I send POST '/v2.0/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: Create ec2 image with invalid name - array
When I send POST '/v2.0/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: Create ec2 image with invalid remote_user - hash
When I send POST '/v2.0/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: Create ec2 image with invalid remote_user - array
When I send POST '/v2.0/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: Create ec2 image with invalid bootstrap_template - array
When I send POST '/v2.0/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: Create ec2 image with invalid bootstrap_template - hash
When I send POST '/v2.0/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: Create ec2 image with invalid bootstrap_template - unknown
When I send POST '/v2.0/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: Create ec2 image with invalid id - array
When I send POST '/v2.0/image' query with JSON body
"""
{
"provider": "ec2",
"name": "test-ec2",
"remote_user": "ec2-user",
"bootstrap_template": null,
"id": []
}
"""
Then response should be '400'
@ec2
Scenario: Create ec2 image with invalid id - hash
When I send POST '/v2.0/image' query with JSON body
"""
{
"provider": "ec2",
"name": "test-ec2",
"remote_user": "ec2-user",
"bootstrap_template": null,
"id": {}
}
"""
Then response should be '400'
@ec2
Scenario: Create ec2 image
When I send POST '/v2.0/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 '201'
And the Content-Type header should include 'application/json'
@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
And response should be JSON object like:
"""
{
"provider": "ec2",
"name": "test-ec2",
"remote_user": "ec2-user",
"bootstrap_template": null,
"id": "<%= @config["ec2"]["image"] %>"
}
"""
@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
Scenario: Get info for single openstack image
When I send GET '/v2.0/image/<%= @config["openstack"]["image"] %>' query
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:
"""
{
"provider": "openstack",
"name": "freebsd-10.0",
"remote_user": "root",
"bootstrap_template": "chef_freebsd",
"id": "<%= @config["openstack"]["image"] %>"
}
"""
@openstack
Scenario: Get info for single openstack image without headers 'Accept'
When I send GET '/v2.0/image/<%= @config["openstack"]["image"] %>' query without headers 'Accept'
Then response should be '406'
@openstack
Scenario: Get openstack image without privileges
When I send GET '/v2.0/image/<%= @config["openstack"]["image"] %>' query with user without privileges
Then response should be '401'
Scenario: Get info for single unknown image
When I send GET '/v2.0/image/foo' query
Then response should be '404'
Scenario: Get image path
When I send GET '/v2.0/image' query
Then response should be '404'

View File

@ -0,0 +1,59 @@
@project
Feature: create project
@openstack
Scenario: Create project <%= @config["openstack"]["project"]["name"] %>
When I send POST '/v2.0/project' query with JSON body
"""
{
"deploy_envs": [
{
"identifier": "<%= @config["openstack"]["project"]["env"] %>",
"run_list": [],
"expires": null,
"provider": "openstack",
"users": [
"<%= @config["user"] %>"
],
"flavor": "<%= @config["openstack"]["flavor"] %>",
"image": "<%= @config["openstack"]["image"] %>",
"subnets": [
"private"
],
"groups": [
"default"
]
}
],
"name": "<%= @config["openstack"]["project"]["name"] %>"
}
"""
Then response should be '201'
@ec2
Scenario: Create project <%= @config["ec2"]["project"]["name"] %>
When I send POST '/v2.0/project' query with JSON body
"""
{
"deploy_envs": [
{
"identifier": "<%= @config["ec2"]["project"]["env"] %>",
"run_list": [],
"expires": null,
"provider": "ec2",
"users": [
"<%= @config["user"] %>"
],
"flavor": "<%= @config["ec2"]["flavor"] %>",
"image": "<%= @config["ec2"]["image"] %>",
"subnets": [],
"groups": [
"default"
]
}
],
"name": "<%= @config["ec2"]["project"]["name"] %>"
}
"""
Then response should be '201'

View File

@ -0,0 +1,20 @@
@script
Feature: Add new script
Scenario: Add new script with user without privileges
When I send PUT '/v2.0/script/<%= @config["script"]["name"] %>' query with user without privileges
Then response should be '401'
Scenario: Add new script without header 'Accept'
When I send PUT '/v2.0/script/<%= @config["script"]["name"] %>' query with body without header 'Accept'
"""
echo "<%= @config["script"]["name"] %>"
"""
Then response should be '406'
Scenario: Add new script with id '<%= @config["script"]["name"] %>'
When I send PUT '/v2.0/script/<%= @config["script"]["name"] %>' query with body
"""
echo "<%= @config["script"]["name"] %>"
"""
Then response should be '201'