Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query and xml tests #3087

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
gem 'json'
gem 'nokogiri', '>= 1.6.8.1'
gem 'oga'
gem 'rexml', '= 3.2.6' # Temporary Workaround (https://github.com/ruby/rexml/issues/131)
gem 'rexml'
# These protocol parsers do not have java gems
unless defined?(JRUBY_VERSION)
gem 'libxml-ruby'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,5 @@
"engines": ["nokogiri"]
}
}
},
"query": {
"input": {},
"output": {
"QueryCustomizedError": {
"description": "Under investigation",
"engines": ["ox", "nokogiri", "rexml", "libxml", "oga"]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
]
},
"description": "Parses customized XML errors",
"errorCode": "CustomCodeError",
"errorCode": "Customized",
"errorMessage": "Hi",
"error": {
"Message": "Hi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,13 @@ def match_resp_data(test_case, http_resp, it)
expected_data =
if error_case?(test_case)
error_shape = http_resp.context.operation.errors.find do |err|
err.shape.name == test_case['errorCode']
shape =
if err.shape['error']
err.shape['error']['code']
else
err.shape.name
end
shape == test_case['errorCode']
end
raise "Unable to find #{test_case['errorCode']} in error shapes" if error_shape.nil?

Expand Down Expand Up @@ -380,6 +386,8 @@ def normalize_headers(hash)

def normalize_xml(xml)
REXML::Document.new(xml).to_s.gsub(/>\s+?</, '><').strip
rescue REXML::ParseException
xml # payload
end

def error_case?(test_case)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ def normalize(xml)
operation = api.operation(:get_bucket_policy)
resp = RestXml.new.stub_data(api, operation, params)
expect(resp.status_code).to eq(200)
expect(normalize(resp.body.string)).to eq(normalize(<<-JSON))
{
"Policy": "policy-document"
}
JSON
expect(resp.body.string).to eq('policy-document')
end

it 'can stub errors' do
Expand Down
Loading