From 56e4031eb2b137133abececf7c869ff4103bf41b Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Fri, 9 Aug 2024 12:40:15 -0400 Subject: [PATCH 1/2] Fix query and xml tests --- Gemfile | 2 +- .../spec/protocol-tests-ignore-list.json | 9 --------- .../spec/protocol-tests/output/query.json | 2 +- .../spec/protocol_tests_spec_helper.rb | 10 +++++++++- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 8a94e26987a..f2b27131c56 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/build_tools/aws-sdk-code-generator/spec/protocol-tests-ignore-list.json b/build_tools/aws-sdk-code-generator/spec/protocol-tests-ignore-list.json index b34b4d6b766..06f1010edb6 100644 --- a/build_tools/aws-sdk-code-generator/spec/protocol-tests-ignore-list.json +++ b/build_tools/aws-sdk-code-generator/spec/protocol-tests-ignore-list.json @@ -11,14 +11,5 @@ "engines": ["nokogiri"] } } - }, - "query": { - "input": {}, - "output": { - "QueryCustomizedError": { - "description": "Under investigation", - "engines": ["ox", "nokogiri", "rexml", "libxml", "oga"] - } - } } } \ No newline at end of file diff --git a/build_tools/aws-sdk-code-generator/spec/protocol-tests/output/query.json b/build_tools/aws-sdk-code-generator/spec/protocol-tests/output/query.json index d492d0cf6e4..8195a44957c 100644 --- a/build_tools/aws-sdk-code-generator/spec/protocol-tests/output/query.json +++ b/build_tools/aws-sdk-code-generator/spec/protocol-tests/output/query.json @@ -519,7 +519,7 @@ ] }, "description": "Parses customized XML errors", - "errorCode": "CustomCodeError", + "errorCode": "Customized", "errorMessage": "Hi", "error": { "Message": "Hi" diff --git a/build_tools/aws-sdk-code-generator/spec/protocol_tests_spec_helper.rb b/build_tools/aws-sdk-code-generator/spec/protocol_tests_spec_helper.rb index 095cbac57f2..84da256b79e 100644 --- a/build_tools/aws-sdk-code-generator/spec/protocol_tests_spec_helper.rb +++ b/build_tools/aws-sdk-code-generator/spec/protocol_tests_spec_helper.rb @@ -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? @@ -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) From dca48d7ed6377b9a7cb40c037f98204c50522a7b Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Fri, 9 Aug 2024 12:59:34 -0400 Subject: [PATCH 2/2] Fix stubbing xml spec --- .../spec/aws/stubbing/protocols/rest_xml_spec.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gems/aws-sdk-core/spec/aws/stubbing/protocols/rest_xml_spec.rb b/gems/aws-sdk-core/spec/aws/stubbing/protocols/rest_xml_spec.rb index 7e6938795b9..f70727190c2 100644 --- a/gems/aws-sdk-core/spec/aws/stubbing/protocols/rest_xml_spec.rb +++ b/gems/aws-sdk-core/spec/aws/stubbing/protocols/rest_xml_spec.rb @@ -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