File tree Expand file tree Collapse file tree
Sources/SmithyCodegenCore/Serialize
Tests/SmithySerializationTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,11 +30,15 @@ package struct SerializeCodegen {
3030 writer. write ( " import typealias SmithySerialization.WriteStructConsumer " )
3131 writer. write ( " " )
3232
33- let inputStructsAndUnions = try ctx. service. inputDescendants
33+ // Must generate SerializableStruct conformance for all of a service's
34+ // structs & unions, not just those that are serialized as part of operation
35+ // inputs, so that all structs & unions get the CustomDebugStringConvertible
36+ // conformance that hides sensitive data
37+ let serviceStructsAndUnions = try ctx. service. descendants
3438 . filter { $0. type == . structure || $0. type == . union }
3539 . smithySorted ( )
3640
37- for shape in inputStructsAndUnions {
41+ for shape in serviceStructsAndUnions {
3842 let swiftType = try ctx. symbolProvider. swiftType ( shape: shape)
3943 let varName = shape. type == . structure ? " structure " : " union "
4044 writer. write ( " @_spi(SchemaBasedSerde) " )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import enum Smithy.Prelude
1414import struct Smithy. Schema
1515@_spi ( SchemaBasedSerde)
1616import struct Smithy. SensitiveTrait
17+ import struct RPCv2CBORTestSDK. GetWidgetOutput
1718import enum RPCv2CBORTestSDK. RPCv2CBORServiceClientTypes
1819
1920final class StringSerializerTests : XCTestCase {
@@ -99,5 +100,11 @@ final class StringSerializerTests: XCTestCase {
99100 " actual: \( subject. debugDescription) "
100101 )
101102 }
103+
104+ func test_outputFieldsAreRedacted( ) throws {
105+ let sensitiveString = " abcxyz "
106+ let subject = GetWidgetOutput ( privateString: sensitiveString)
107+ XCTAssertFalse ( String ( reflecting: subject) . contains ( sensitiveString) )
108+ }
102109}
103110
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ structure GetWidgetInput {
2929
3030@output
3131structure GetWidgetOutput {
32+ privateString : PrivateString
3233}
3334
3435structure SensitiveType {
You can’t perform that action at this time.
0 commit comments