Skip to content

Commit d8b3d2f

Browse files
committed
Test callsFilterForMapWithUnionWithSensitiveData
1 parent 0ff0527 commit d8b3d2f

File tree

3 files changed

+55
-13
lines changed

3 files changed

+55
-13
lines changed

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,8 @@ public void filtersSensitiveMemberPointingToList() {
292292
}
293293

294294
@Test
295-
public void callsFilterForMapWithSensitiveData() {
296-
testStructureCodegen("test-map-with-sensitive-data.smithy",
297-
" export const filterSensitiveLog = (obj: User): any => ({\n"
298-
+ " ...obj,\n"
299-
+ " ...(obj.password && { password:\n"
300-
+ " SENSITIVE_STRING\n"
301-
+ " }),\n"
302-
+ " })\n");
303-
}
304-
305-
@Test
306-
public void callsFilterInMapWithSensitiveData() {
307-
testStructureCodegen("test-map-with-sensitive-data.smithy",
295+
public void callsFilterForMapWithStructureWithSensitiveData() {
296+
testStructureCodegen("test-map-with-structure-with-sensitive-data.smithy",
308297
" export const filterSensitiveLog = (obj: GetFooInput): any => ({\n"
309298
+ " ...obj,\n"
310299
+ " ...(obj.foo && { foo:\n"
@@ -318,6 +307,33 @@ public void callsFilterInMapWithSensitiveData() {
318307
+ " })\n");
319308
}
320309

310+
@Test
311+
public void callsFilterInMapWithStructureWithSensitiveData() {
312+
testStructureCodegen("test-map-with-structure-with-sensitive-data.smithy",
313+
" export const filterSensitiveLog = (obj: User): any => ({\n"
314+
+ " ...obj,\n"
315+
+ " ...(obj.password && { password:\n"
316+
+ " SENSITIVE_STRING\n"
317+
+ " }),\n"
318+
+ " })\n");
319+
}
320+
321+
@Test
322+
public void callsFilterForMapWithUnionWithSensitiveData() {
323+
testStructureCodegen("test-map-with-union-with-sensitive-data.smithy",
324+
" export const filterSensitiveLog = (obj: GetFooInput): any => ({\n"
325+
+ " ...obj,\n"
326+
+ " ...(obj.foo && { foo:\n"
327+
+ " Object.entries(obj.foo).reduce((acc: any, [key, value]: [string, TestUnion]) => ({\n"
328+
+ " ...acc,\n"
329+
+ " [key]:\n"
330+
+ " TestUnion.filterSensitiveLog(value)\n"
331+
+ " ,\n"
332+
+ " }), {})\n"
333+
+ " }),\n"
334+
+ " })\n");
335+
}
336+
321337
@Test
322338
public void callsFilterForMapWithSensitiveMember() {
323339
testStructureCodegen("test-map-with-sensitive-member.smithy",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace smithy.example
2+
3+
service Example {
4+
version: "1.0.0",
5+
operations: [GetFoo]
6+
}
7+
8+
operation GetFoo {
9+
input: GetFooInput
10+
}
11+
12+
structure GetFooInput {
13+
foo: UserMap
14+
}
15+
16+
map UserMap {
17+
key: String,
18+
value: TestUnion
19+
}
20+
21+
union TestUnion {
22+
bar: String,
23+
24+
@sensitive
25+
sensitiveBar: String
26+
}

0 commit comments

Comments
 (0)