diff --git a/devops-service/features/support/config.yml b/devops-service/features/support/config.yml deleted file mode 100644 index cea2dff..0000000 --- a/devops-service/features/support/config.yml +++ /dev/null @@ -1,7 +0,0 @@ -host: "host" -port: port -username: "test" -password: "test" -path_prefix: "" -username_without_privileges: "user_for_testing_" -password_without_privileges: "test" diff --git a/devops-service/tests/features/api_v2/00_list/flavor.feature b/devops-service/tests/features/api_v2/00_list/flavor.feature new file mode 100644 index 0000000..92a5aba --- /dev/null +++ b/devops-service/tests/features/api_v2/00_list/flavor.feature @@ -0,0 +1,64 @@ +@flavor +Feature: Flavors + + @openstack + Scenario: Get list of openstack flavors + When I send GET '/v2.0/flavors/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: + """ + [ + { + "id": "flavor_id", + "v_cpus": "v_cpus", + "ram": "ram", + "disk": "disk" + } + ] + """ + + @ec2 + Scenario: Get list of ec2 flavors + When I send GET '/v2.0/flavors/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: + """ + [ + { + "id": "t1.micro", + "cores": 2, + "disk": 0, + "name": "Micro Instance", + "ram": 613 + } + ] + """ + + @static + Scenario: Get list of static flavors + When I send GET '/v2.0/flavors/static' 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 be empty + + @static + Scenario: Get flavors list of static provider without 'Accept' header + When I send GET '/v2.0/flavors/static' query without headers 'Accept' + Then response should be '406' + + Scenario: Get flavors list of unknown provider + When I send GET '/v2.0/flavors/foo' query + Then response should be '404' + + Scenario: Get flavors list of unknown provider without 'Accept' header + When I send GET '/v2.0/flavors/foo' query without headers 'Accept' + Then response should be '406' + + Scenario: Get flavors list of unknown provider without privileges + When I send GET '/v2.0/flavors/foo' query with user without privileges + Then response should be '401' diff --git a/devops-service/features/step_definitions/group_steps.rb b/devops-service/tests/features/step_definitions/group_steps.rb similarity index 100% rename from devops-service/features/step_definitions/group_steps.rb rename to devops-service/tests/features/step_definitions/group_steps.rb diff --git a/devops-service/features/step_definitions/http_queries_steps.rb b/devops-service/tests/features/step_definitions/http_queries_steps.rb similarity index 100% rename from devops-service/features/step_definitions/http_queries_steps.rb rename to devops-service/tests/features/step_definitions/http_queries_steps.rb diff --git a/devops-service/features/step_definitions/json_steps.rb b/devops-service/tests/features/step_definitions/json_steps.rb similarity index 100% rename from devops-service/features/step_definitions/json_steps.rb rename to devops-service/tests/features/step_definitions/json_steps.rb diff --git a/devops-service/features/step_definitions/network_steps.rb b/devops-service/tests/features/step_definitions/network_steps.rb similarity index 100% rename from devops-service/features/step_definitions/network_steps.rb rename to devops-service/tests/features/step_definitions/network_steps.rb diff --git a/devops-service/features/step_definitions/server_steps.rb b/devops-service/tests/features/step_definitions/server_steps.rb similarity index 100% rename from devops-service/features/step_definitions/server_steps.rb rename to devops-service/tests/features/step_definitions/server_steps.rb diff --git a/devops-service/tests/features/support/config.yml b/devops-service/tests/features/support/config.yml new file mode 100644 index 0000000..2c21267 --- /dev/null +++ b/devops-service/tests/features/support/config.yml @@ -0,0 +1,8 @@ +--- +host: host +port: 7070 +username: test +password: test +path_prefix: '' +username_without_privileges: user_for_testing_ +password_without_privileges: test diff --git a/devops-service/features/support/env.rb b/devops-service/tests/features/support/env.rb similarity index 100% rename from devops-service/features/support/env.rb rename to devops-service/tests/features/support/env.rb diff --git a/devops-service/tests/generate_tests.rb b/devops-service/tests/generate_tests.rb index 8c8a1a6..3241e21 100755 --- a/devops-service/tests/generate_tests.rb +++ b/devops-service/tests/generate_tests.rb @@ -7,10 +7,20 @@ require "fileutils" class Generator < OpenStruct - CONFIG = "config.yml" + CONFIG = "params.yml" + TESTS_CONFIG = "features/support/config.yml" def initialize - super(:config => YAML.load_file(File.new(ENV["CONFIG"] || CONFIG))) + @config = YAML.load_file(File.new(ENV["CONFIG"] || CONFIG)) + super(:config => @config) + end + + def make_tests_config + c = {} + %w{host port username password path_prefix username_without_privileges password_without_privileges}.each do |key| + c[key] = @config[key] + end + File.open(TESTS_CONFIG, "w") {|f| f.write(c.to_yaml) } end def render(template) @@ -22,6 +32,7 @@ templates = { "templates/api_v2/00_list/flavor.feature.erb" => "features/api_v2/00_list/flavor.feature" } generator = Generator.new +generator.make_tests_config templates.each do |input, output| if File.exists?(input) diff --git a/devops-service/tests/config.yml b/devops-service/tests/params.yml similarity index 60% rename from devops-service/tests/config.yml rename to devops-service/tests/params.yml index f6f6cfb..6bac774 100644 --- a/devops-service/tests/config.yml +++ b/devops-service/tests/params.yml @@ -1,4 +1,12 @@ --- +host: "host" +port: 7070 +username: "test" +password: "test" +path_prefix: "" +username_without_privileges: "user_for_testing_" +password_without_privileges: "test" + openstack: flavor: "as_long_as_image" image: "08093b30-8393-42c3-8fb3-c4df56deb967"