filters tests
This commit is contained in:
parent
92a43ed67c
commit
863480899a
@ -36,7 +36,7 @@ module Connectors
|
||||
def check_user_privileges(id, cmd, required_privelege)
|
||||
user = show(id)
|
||||
|
||||
unless %w(r w x).include?(required_privelege)
|
||||
unless Devops::Model::User::PRIVILEGES.include?(required_privelege)
|
||||
raise InvalidPrivileges.new("Access internal problem with privilege '#{required_privelege}'")
|
||||
end
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ module Sinatra
|
||||
# Can client works with JSON?
|
||||
def accept_json
|
||||
types = request.accept_media_types
|
||||
unless types.include?('application/json')# or types.include?("*/*")
|
||||
unless types.include?('application/json') or types.include?("*/*")
|
||||
response.headers['Accept'] = 'application/json'
|
||||
halt_response("Accept header should contains 'application/json' type", 406)
|
||||
end
|
||||
|
||||
@ -31,9 +31,16 @@ When(/^I send POST '(.*)' query with JSON body$/) do |path, body|
|
||||
res = post_body(path, body, DEFAULT_HEADERS)
|
||||
end
|
||||
|
||||
When(/^I send POST '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||
When(/^I send POST '(.*)' query with body with header 'Accept' value '(.*)'$/) do |path, hv, body|
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers["Accept"] = hv
|
||||
res = post_body(path, body, headers)
|
||||
end
|
||||
|
||||
When(/^I send POST '(.*)' query with JSON body without header 'Content-Type'$/) do |path, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers.delete("Content-Type")
|
||||
res = post_body(path, body, headers)
|
||||
end
|
||||
|
||||
@ -46,20 +53,28 @@ When(/^I send DELETE '(.*)' query$/) do |path|
|
||||
delete(path, {}, DEFAULT_HEADERS)
|
||||
end
|
||||
|
||||
When(/^I send DELETE '(.*)' query with JSON body with header 'Accept' value '(.*)'$/) do |path, hv, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers["Accept"] = hv
|
||||
res = delete_body(path, body, headers)
|
||||
end
|
||||
|
||||
When(/^I send DELETE '(.*)' query with JSON body$/) do |path, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
res = delete_body(path, body, DEFAULT_HEADERS)
|
||||
end
|
||||
|
||||
When(/^I send DELETE '(.*)' query without header '(.*)'$/) do |path, hs|
|
||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||
puts headers
|
||||
When(/^I send DELETE '(.*)' query without header 'Content-Type'$/) do |path, hs|
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers.delete("Content-Type")
|
||||
res = delete_body(path, nil, headers)
|
||||
end
|
||||
|
||||
When(/^I send DELETE '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||
When(/^I send DELETE '(.*)' query with JSON body without header 'Content-Type'$/) do |path, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers.delete("Content-Type")
|
||||
res = delete_body(path, body, headers)
|
||||
end
|
||||
|
||||
@ -80,14 +95,23 @@ When(/^I send PUT '(.*)' query with user without privileges$/) do |path|
|
||||
put_without_privileges(path, {}, DEFAULT_HEADERS)
|
||||
end
|
||||
|
||||
When(/^I send PUT '(.*)' query with body without header '(.*)'$/) do |path, hs, body|
|
||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||
When(/^I send PUT '(.*)' query with JSON body with header 'Accept' value '(.*)'$/) do |path, hv, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers["Accept"] = hv
|
||||
res = put_body(path, body, headers)
|
||||
end
|
||||
|
||||
When(/^I send PUT '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||
When(/^I send PUT '(.*)' query with body without header 'Content-Type'$/) do |path, body|
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers.delete("Content-Type")
|
||||
res = put_body(path, body, headers)
|
||||
end
|
||||
|
||||
When(/^I send PUT '(.*)' query with JSON body without header 'Content-Type'$/) do |path, body|
|
||||
JSON.parse(body) unless body.strip.empty?
|
||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||
headers = DEFAULT_HEADERS.clone
|
||||
headers.delete("Content-Type")
|
||||
res = put_body(path, body, headers)
|
||||
end
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ class Generator < OpenStruct
|
||||
config_file = ENV["DEVOPS_FEATURES_GENERATOR_CONFIG"] || ENV["CONFIG"] || CONFIG
|
||||
@config = YAML.load_file(File.new(config_file))
|
||||
load_fixtures()
|
||||
super(:config => @config)
|
||||
super(:config => @config, :formatter => @formatter, :fixtures => @fixtures)
|
||||
end
|
||||
|
||||
def configure!
|
||||
|
||||
@ -7,8 +7,8 @@ Feature: Filters
|
||||
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'
|
||||
Scenario: Add openstack image filter with header 'Accept' value 'text/*'
|
||||
When I send PUT '/v2.0/filter/openstack/image' query with JSON body with header 'Accept' value 'text/*'
|
||||
"""
|
||||
[
|
||||
"<%= @config["openstack"]["image"] %>"
|
||||
@ -102,8 +102,8 @@ Feature: Filters
|
||||
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'
|
||||
Scenario: Add ec2 image filter with header 'Accept' value 'text/*'
|
||||
When I send PUT '/v2.0/filter/ec2/image' query with JSON body with header 'Accept' value 'text/*'
|
||||
"""
|
||||
[
|
||||
"<%= @config["ec2"]["image"] %>"
|
||||
|
||||
@ -7,8 +7,8 @@ Feature: Filters
|
||||
Then response should be '401'
|
||||
|
||||
@openstack
|
||||
Scenario: Delete openstack image filter without header 'Accept'
|
||||
When I send DELETE '/v2.0/filter/openstack/image' query with JSON body without header 'Accept'
|
||||
Scenario: Delete openstack image filter with header 'Accept' value 'text/*'
|
||||
When I send DELETE '/v2.0/filter/openstack/image' query with JSON body with header 'Accept' value 'text/*'
|
||||
"""
|
||||
[
|
||||
"<%= @config["openstack"]["image"] %>"
|
||||
@ -92,8 +92,8 @@ Feature: Filters
|
||||
Then response should be '401'
|
||||
|
||||
@ec2
|
||||
Scenario: Delete ec2 image filter without header 'Accept'
|
||||
When I send DELETE '/v2.0/filter/ec2/image' query with JSON body without header 'Accept'
|
||||
Scenario: Delete ec2 image filter with header 'Accept' value 'text/*'
|
||||
When I send DELETE '/v2.0/filter/ec2/image' query with JSON body with header 'Accept' value 'text/*'
|
||||
"""
|
||||
[
|
||||
"<%= @config["ec2"]["image"] %>"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user