From c63c643ca390181b504eafc18bb6acd437ff99e8 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 15 Jul 2024 12:46:26 -0700 Subject: [PATCH] Add kitchen sink sensitive test --- .../fixtures/interfaces/sensitive/api.json | 211 ++++++++++++++++++ .../spec/interfaces/sensitive_spec.rb | 35 +++ 2 files changed, 246 insertions(+) create mode 100644 build_tools/aws-sdk-code-generator/spec/fixtures/interfaces/sensitive/api.json create mode 100644 build_tools/aws-sdk-code-generator/spec/interfaces/sensitive_spec.rb diff --git a/build_tools/aws-sdk-code-generator/spec/fixtures/interfaces/sensitive/api.json b/build_tools/aws-sdk-code-generator/spec/fixtures/interfaces/sensitive/api.json new file mode 100644 index 00000000000..82bc9b0d5c7 --- /dev/null +++ b/build_tools/aws-sdk-code-generator/spec/fixtures/interfaces/sensitive/api.json @@ -0,0 +1,211 @@ +{ + "metadata": { + "endpointPrefix": "svc", + "serviceId": "sensitive_svc", + "protocol": "rest-json" + }, + "operations":{ + "KitchenSinkOperation": { + "name":"KitchenSinkOperation", + "http":{ + "method":"POST", + "requestUri":"/KitchenSinkOperation" + }, + "input":{"shape":"KitchenSink"}, + "output":{"shape":"KitchenSink"} + } + }, + "shapes": { + "KitchenSink": { + "type": "structure", + "members": { + "Blob": { + "shape": "Blob" + }, + "Boolean": { + "shape": "Boolean" + }, + "Double": { + "shape": "Double" + }, + "EmptyStruct": { + "shape": "EmptyStruct" + }, + "Float": { + "shape": "Float" + }, + "Integer": { + "shape": "Integer" + }, + "JsonValue": { + "shape": "JsonValue", + "jsonvalue": true + }, + "ListOfStrings": { + "shape": "ListOfStrings" + }, + "ListOfStructs": { + "shape": "ListOfStructs" + }, + "Long": { + "shape": "Long" + }, + "MapOfListsOfStrings": { + "shape": "MapOfListsOfStrings" + }, + "MapOfMaps": { + "shape": "MapOfMapOfStrings" + }, + "MapOfStrings": { + "shape": "MapOfStrings" + }, + "MapOfStructs": { + "shape": "MapOfStructs" + }, + "SimpleStruct": { + "shape": "SimpleStruct" + }, + "String": { + "shape": "String" + }, + "StructWithJsonName": { + "shape": "StructWithJsonName" + }, + "Timestamp": { + "shape": "Timestamp" + } + } + }, + "Blob": { + "type": "blob", + "sensitive": true + }, + "Boolean": { + "type": "boolean", + "box": true, + "sensitive": true + }, + "Double": { + "type": "double", + "box": true, + "sensitive": true + }, + "EmptyStruct": { + "type": "structure", + "members": {} + }, + "Float": { + "type": "float", + "box": true, + "sensitive": true + }, + "Integer": { + "type": "integer", + "box": true, + "sensitive": true + }, + "JsonValue": { + "type": "string", + "sensitive": true + }, + "ListOfListOfStrings": { + "type": "list", + "member": { + "shape": "ListOfStrings" + } + }, + "ListOfStrings": { + "type": "list", + "member": { + "shape": "String" + } + }, + "ListOfStructs": { + "type": "list", + "member": { + "shape": "SimpleStruct" + } + }, + "Long": { + "type": "long", + "box": true, + "sensitive": true + }, + "MapOfListsOfStrings": { + "type": "map", + "key": { + "shape": "String" + }, + "value": { + "shape": "ListOfStrings" + } + }, + "MapOfMapOfStrings": { + "type": "map", + "key": { + "shape": "String" + }, + "value": { + "shape": "MapOfStrings" + } + }, + "MapOfStrings": { + "type": "map", + "key": { + "shape": "String" + }, + "value": { + "shape": "String" + } + }, + "MapOfStructs": { + "type": "map", + "key": { + "shape": "String" + }, + "value": { + "shape": "SimpleStruct" + } + }, + "ListOfKitchenSinks": { + "type": "list", + "member": { + "shape": "KitchenSink" + } + }, + "MapOfKitchenSinks": { + "type": "map", + "key": { + "shape": "String" + }, + "value": { + "shape": "KitchenSink" + } + }, + "SimpleStruct": { + "type": "structure", + "members": { + "Value": { + "shape": "String" + } + }, + "sensitive": true + }, + "String": { + "type": "string", + "sensitive": true + }, + "StructWithJsonName": { + "type": "structure", + "members": { + "Value": { + "shape": "String" + } + } + }, + "Timestamp": { + "type": "timestamp", + "sensitive": true + } + } +} diff --git a/build_tools/aws-sdk-code-generator/spec/interfaces/sensitive_spec.rb b/build_tools/aws-sdk-code-generator/spec/interfaces/sensitive_spec.rb new file mode 100644 index 00000000000..2d997af71e1 --- /dev/null +++ b/build_tools/aws-sdk-code-generator/spec/interfaces/sensitive_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require_relative '../spec_helper' + +describe 'Types Interface:' do + describe 'Sensitive members' do + before(:all) do + SpecHelper.generate_service(['Sensitive'], multiple_files: false) + end + + let(:token) { 'token' } + + let(:token_provider) { Aws::StaticTokenProvider.new(token) } + + let(:client) do + Sensitive::Client.new( + stub_responses: true, + ) + end + + describe '#kitchen_sink' do + it 'filters all sensitive members' do + resp = client.kitchen_sink_operation + puts resp + expect(resp.to_s).to eq( + (<<-OUTPUT +{:blob=>"[FILTERED]", :boolean=>"[FILTERED]", :double=>"[FILTERED]", :empty_struct=>{}, :float=>"[FILTERED]", :integer=>"[FILTERED]", :json_value=>"[FILTERED]", :list_of_strings=>"[FILTERED]", :list_of_structs=>"[FILTERED]", :long=>"[FILTERED]", :map_of_lists_of_strings=>"[FILTERED]", :map_of_maps=>"[FILTERED]", :map_of_strings=>"[FILTERED]", :map_of_structs=>"[FILTERED]", :simple_struct=>"[FILTERED]", :string=>"[FILTERED]", :struct_with_json_name=>{:value=>"[FILTERED]"}, :timestamp=>"[FILTERED]"} + OUTPUT + ).strip + ) + end + end + + end +end