diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java index d368c0fffff..a9270cf6880 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CommandGeneratorTest.java @@ -11,39 +11,7 @@ import software.amazon.smithy.model.node.Node; public class CommandGeneratorTest { - @Test - public void addsCommandSpecificPlugins() { - testCommandCodegen( - "output-structure.smithy", - new String[] {"getSerdePlugin(config, this.serialize, this.deserialize)"} - ); - } - - /** - * todo(schema) remove when switched over. - */ - @Test - public void writesSerializer() { - testCommandCodegen( - "output-structure.smithy", - new String[] {".ser("} - ); - } - - /** - * todo(schema) remove when switched over. - */ - @Test - public void writesDeserializer() { - testCommandCodegen( - "output-structure.smithy", - new String[] {".de("} - ); - } - - /** - * todo(schema) enable when switched over. - */ + // todo(schema) enable when on by default. @Disabled @Test public void writesOperationSchemaRef() { diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java index 9ce6432a8fb..6a0da01c9b2 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java @@ -164,293 +164,6 @@ public void generatesRetryableTraitWithThrottling() { + "}\n"); } - @Test - public void filtersSensitiveSimpleShape() { - testStructureCodegen("test-sensitive-simple-shape.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.password && { password:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})\n"); - } - - @Test - public void skipsFilterForInsensitiveSimpleShape() { - testStructureCodegenExcludes("test-insensitive-simple-shape.smithy", - "GetFooInputFilterSensitiveLog"); - } - - @Test - public void callsFilterForStructureWithSensitiveData() { - testStructureCodegen("test-structure-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " UserFilterSensitiveLog(obj.foo)\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInStructureWithSensitiveData() { - testStructureCodegen("test-structure-with-sensitive-data.smithy", - "export const UserFilterSensitiveLog = (obj: User): any => ({\n" - + " ...obj,\n" - + " ...(obj.password && { password:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void filtersSensitiveStructure() { - testStructureCodegen("test-sensitive-structure.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void skipsFilterForStructureWithoutSensitiveData() { - testStructureCodegenExcludes("test-structure-without-sensitive-data.smithy", - "GetFooInputFilterSensitiveLog"); - } - - @Test - public void callsFilterForUnionWithSensitiveData() { - testStructureCodegen("test-union-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " TestUnionFilterSensitiveLog(obj.foo)\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInUnionWithSensitiveData() { - testStructureCodegen("test-union-with-sensitive-data.smithy", - "export const TestUnionFilterSensitiveLog = (obj: TestUnion): any => {\n" - + " if (obj.bar !== undefined) return {bar:\n" - + " obj.bar\n" - + " };\n" - + " if (obj.sensitiveBar !== undefined) return {sensitiveBar:\n" - + " SENSITIVE_STRING\n" - + " };\n" - + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n" - + "}"); - } - - @Test - public void callsFilterForUnionWithoutSensitiveData() { - testStructureCodegenExcludes("test-union-without-sensitive-data.smithy", - "GetFooInputFilterSensitiveLog"); - } - - @Test - public void skipsFilterInUnionWithoutSensitiveData() { - testStructureCodegenExcludes("test-union-without-sensitive-data.smithy", - "TestUnionFilterSensitiveLog"); - } - - @Test - public void filtersStreamingUnion() { - testStructureCodegen("test-streaming-union.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " 'STREAMING_CONTENT'\n" - + " }),\n" - + "})"); - } - - @Test - public void filtersSensitiveUnion() { - testStructureCodegen("test-sensitive-union.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterForListWithStructureWithSensitiveData() { - testStructureCodegen("test-list-with-structure-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " obj.foo.map(\n" - + " item =>\n" - + " UserFilterSensitiveLog(item)\n" - + " )\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInListWithStructureWithSensitiveData() { - testStructureCodegen("test-list-with-structure-with-sensitive-data.smithy", - "export const UserFilterSensitiveLog = (obj: User): any => ({\n" - + " ...obj,\n" - + " ...(obj.password && { password:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterForListWithUnionWithSensitiveData() { - testStructureCodegen("test-list-with-union-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " obj.foo.map(\n" - + " item =>\n" - + " TestUnionFilterSensitiveLog(item)\n" - + " )\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInListWithUnionWithSensitiveData() { - testStructureCodegen("test-list-with-union-with-sensitive-data.smithy", - "export const TestUnionFilterSensitiveLog = (obj: TestUnion): any => {\n" - + " if (obj.bar !== undefined) return {bar:\n" - + " obj.bar\n" - + " };\n" - + " if (obj.sensitiveBar !== undefined) return {sensitiveBar:\n" - + " SENSITIVE_STRING\n" - + " };\n" - + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n" - + "}\n"); - } - - @Test - public void callsFilterForListWithSensitiveMember() { - testStructureCodegen("test-list-with-sensitive-member.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void filtersSensitiveList() { - testStructureCodegen("test-sensitive-list.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void skipsFilterForInsensitiveList() { - testStructureCodegenExcludes("test-insensitive-list.smithy", - "GetFooInputFilterSensitiveLog"); - } - - @Test - public void callsFilterForMapWithStructureWithSensitiveData() { - testStructureCodegen("test-map-with-structure-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " Object.entries(obj.foo).reduce((acc: any, [key, value]: [string, User]) => (\n" - + " acc[key] =\n" - + " UserFilterSensitiveLog(value)\n" - + " ,\n" - + " acc\n" - + " ), {})\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInMapWithStructureWithSensitiveData() { - testStructureCodegen("test-map-with-structure-with-sensitive-data.smithy", - "export const UserFilterSensitiveLog = (obj: User): any => ({\n" - + " ...obj,\n" - + " ...(obj.password && { password:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterForMapWithUnionWithSensitiveData() { - testStructureCodegen("test-map-with-union-with-sensitive-data.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " Object.entries(obj.foo).reduce((acc: any, [key, value]: [string, TestUnion]) => (\n" - + " acc[key] =\n" - + " TestUnionFilterSensitiveLog(value)\n" - + " ,\n" - + " acc\n" - + " ), {})\n" - + " }),\n" - + "})"); - } - - @Test - public void callsFilterInMapWithUnionWithSensitiveData() { - testStructureCodegen("test-map-with-union-with-sensitive-data.smithy", - "export const TestUnionFilterSensitiveLog = (obj: TestUnion): any => {\n" - + " if (obj.bar !== undefined) return {bar:\n" - + " obj.bar\n" - + " };\n" - + " if (obj.sensitiveBar !== undefined) return {sensitiveBar:\n" - + " SENSITIVE_STRING\n" - + " };\n" - + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n" - + "}\n"); - } - - @Test - public void callsFilterForMapWithSensitiveMember() { - testStructureCodegen("test-map-with-sensitive-member.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void filtersSensitiveMap() { - testStructureCodegen("test-sensitive-map.smithy", - "export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n" - + " ...obj,\n" - + " ...(obj.foo && { foo:\n" - + " SENSITIVE_STRING\n" - + " }),\n" - + "})"); - } - - @Test - public void skipsFilterForInsensitiveMap() { - testStructureCodegenExcludes("test-insensitive-map.smithy", - "GetFooInputFilterSensitiveLog"); - } - - @Test - public void skipsFilterOnEncounteringRecursiveShapes() { - testStructureCodegenExcludes("test-recursive-shapes.smithy", - "GetFooInputFilterSensitiveLog"); - } - @Test public void properlyGeneratesRequiredMessageMemberNotBackwardCompatible() { testStructureCodegenBase("test-required-member.smithy",