From 93efca2b0a24ac2f3d63eab378d8769b95a9e03c Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 13 Jun 2023 11:06:41 -0600 Subject: [PATCH 01/11] Add validator to check consistency of resource name used for IamResource --- .../iam/traits/IamResourceTraitValidator.java | 62 +++++++++++++++++++ ...e.amazon.smithy.model.validation.Validator | 1 + .../iam/traits/IamResourceValidatorTest.java | 44 +++++++++++++ .../iam/traits/invalid-iam-resources.smithy | 44 +++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java create mode 100644 smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java create mode 100644 smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java new file mode 100644 index 00000000000..85fb655384f --- /dev/null +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -0,0 +1,62 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.smithy.aws.iam.traits; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import software.amazon.smithy.aws.traits.ArnTrait; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ResourceShape; +import software.amazon.smithy.model.validation.AbstractValidator; +import software.amazon.smithy.model.validation.ValidationEvent; +import software.amazon.smithy.utils.SmithyInternalApi; +import software.amazon.smithy.utils.StringUtils; + +/** + * Ensures that any resource name defined in the {@link IamResourceTrait} is + * consistent with the resource name used in any {@link ArnTrait} definition + * applied to the resource. + */ +@SmithyInternalApi +public class IamResourceTraitValidator extends AbstractValidator { + @Override + public List validate(Model model) { + List results = new ArrayList<>(); + for (ResourceShape resource : model.getResourceShapesWithTrait(IamResourceTrait.class)) { + // If the resource has both the IamResourceTrait and Arn trait, + // check that the resource name is consistent between the two traits + if (resource.hasTrait(ArnTrait.class)) { + String resourceName = resource.expectTrait(IamResourceTrait.class).getName() + .orElse(StringUtils.lowerCase(resource.getId().getName())); + ArnTrait arnTrait = resource.expectTrait(ArnTrait.class); + List arnComponents = parseArnComponents(arnTrait.getTemplate()); + if (!arnComponents.contains(resourceName)) { + results.add(danger(resource, String.format( + "The `@aws.iam#iamResource trait applied to the resource " + + "defines a resource name, `%s`, that does not match the `@arn` template, " + + "`%s`, for that same resource.", + resourceName, arnTrait.getTemplate()))); + } + } + } + return results; + } + + List parseArnComponents(String arnTemplate) { + return new ArrayList<>(Arrays.asList(arnTemplate.split("/"))); + } +} diff --git a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator index c77a40ad52b..68fa9892a8d 100644 --- a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator +++ b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -1 +1,2 @@ software.amazon.smithy.aws.iam.traits.ConditionKeysValidator +software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator \ No newline at end of file diff --git a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java new file mode 100644 index 00000000000..9effedf33c9 --- /dev/null +++ b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java @@ -0,0 +1,44 @@ +package software.amazon.smithy.aws.iam.traits; + +import org.junit.jupiter.api.Test; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.validation.Severity; +import software.amazon.smithy.model.validation.ValidatedResult; +import software.amazon.smithy.model.validation.ValidationEvent; + +import java.util.Optional; +import java.util.stream.Collectors; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class IamResourceValidatorTest { + @Test + public void detectsUnknownConditionKeys() { + ValidatedResult result = Model.assembler() + .addImport(getClass().getResource("invalid-iam-resources.smithy")) + .discoverModels(getClass().getClassLoader()) + .assemble(); + + assertTrue(result.isBroken()); + assertEquals(result.getValidationEvents().size(), 3); + assertThat(result.getValidationEvents(Severity.DANGER).stream() + .map(ValidationEvent::getId) + .collect(Collectors.toSet()), + contains("IamResourceTrait")); + assertThat(result.getValidationEvents(Severity.DANGER).stream() + .map(ValidationEvent::getShapeId) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toSet()), + containsInAnyOrder( + ShapeId.from("smithy.example#IncompatibleResourceName"), + ShapeId.from("smithy.example#InvalidResource"), + ShapeId.from("smithy.example#BadIamResourceName") + )); + } +} diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy new file mode 100644 index 00000000000..d2306354107 --- /dev/null +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy @@ -0,0 +1,44 @@ +$version: "2" +namespace smithy.example + +use aws.api#arn + +@aws.api#service(sdkId: "My") +@aws.iam#defineConditionKeys("foo:baz": {type: "String", documentation: "Foo baz"}) +service MyService { + version: "2019-02-20", + resources: [ + BadIamResourceName, + Beer, + InvalidResource + ] +} + +@aws.iam#iamResource(name: "bad-iam-resourceName") +@arn(template: "bad-iam-resource-name/{id}") +resource BadIamResourceName { + identifiers: { + id: String + } +} + +@aws.iam#iamResource(name: "beer") +@arn(template: "beer/{beerId}") +resource Beer { + identifiers: { + beerId: String + } + resources: [IncompatibleResourceName] +} + +@arn(template: "beer/{beerId}/incompatible-resource-name") +@aws.iam#iamResource(name: "IncompatibleResourceName") +resource IncompatibleResourceName { + identifiers: { + beerId: String + } +} + +@aws.iam#iamResource(name: "invalidResource") +@arn(template: "invalid-resource") +resource InvalidResource {} From 6bb162cdfd3c4fd5eedf30d5e2f3437f4f3959da Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 13 Jun 2023 11:31:48 -0600 Subject: [PATCH 02/11] Update arn parsing method to be private --- .../amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 85fb655384f..03452ec433d 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -56,7 +56,7 @@ public List validate(Model model) { return results; } - List parseArnComponents(String arnTemplate) { + private List parseArnComponents(String arnTemplate) { return new ArrayList<>(Arrays.asList(arnTemplate.split("/"))); } } From ae8951cdf3a4187dd4a6bc9366af21c2d65ee95f Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:13:52 -0600 Subject: [PATCH 03/11] Update smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java Co-authored-by: Michael Dowling --- .../amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 03452ec433d..880294082de 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -48,7 +48,7 @@ public List validate(Model model) { results.add(danger(resource, String.format( "The `@aws.iam#iamResource trait applied to the resource " + "defines a resource name, `%s`, that does not match the `@arn` template, " - + "`%s`, for that same resource.", + + "`%s`, of the resource.", resourceName, arnTrait.getTemplate()))); } } From 0a0f3c970c45fca819a1c6ac9139ee40e46c451c Mon Sep 17 00:00:00 2001 From: Hunter Mellema <124718352+hpmellema@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:14:00 -0600 Subject: [PATCH 04/11] Update smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java Co-authored-by: Michael Dowling --- .../amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 880294082de..2b8911570fc 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -46,7 +46,7 @@ public List validate(Model model) { List arnComponents = parseArnComponents(arnTrait.getTemplate()); if (!arnComponents.contains(resourceName)) { results.add(danger(resource, String.format( - "The `@aws.iam#iamResource trait applied to the resource " + "The `@aws.iam#iamResource` trait applied to this resource " + "defines a resource name, `%s`, that does not match the `@arn` template, " + "`%s`, of the resource.", resourceName, arnTrait.getTemplate()))); From 3753ac25490074ccdb09eb3079489eb2874a95bd Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 09:07:49 -0600 Subject: [PATCH 05/11] Address PR comments --- .../iam/traits/IamResourceTraitValidator.java | 10 +- ...e.amazon.smithy.model.validation.Validator | 2 +- smithy-cli/clone-template.sh | 35 ++++++ .../smithy/cli/commands/InitCommand.java | 112 ++++++++++++++++++ 4 files changed, 153 insertions(+), 6 deletions(-) create mode 100755 smithy-cli/clone-template.sh create mode 100644 smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 2b8911570fc..e236b649ce0 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -41,14 +41,14 @@ public List validate(Model model) { // check that the resource name is consistent between the two traits if (resource.hasTrait(ArnTrait.class)) { String resourceName = resource.expectTrait(IamResourceTrait.class).getName() - .orElse(StringUtils.lowerCase(resource.getId().getName())); + .orElseGet(() -> StringUtils.lowerCase(resource.getId().getName())); ArnTrait arnTrait = resource.expectTrait(ArnTrait.class); List arnComponents = parseArnComponents(arnTrait.getTemplate()); if (!arnComponents.contains(resourceName)) { results.add(danger(resource, String.format( - "The `@aws.iam#iamResource` trait applied to this resource " - + "defines a resource name, `%s`, that does not match the `@arn` template, " - + "`%s`, of the resource.", + "The `@aws.iam#iamResource trait applied to the resource " + + "defines an IAM resource name, `%s`, that does not match the `@arn` template, " + + "`%s`, for that same resource.", resourceName, arnTrait.getTemplate()))); } } @@ -57,6 +57,6 @@ public List validate(Model model) { } private List parseArnComponents(String arnTemplate) { - return new ArrayList<>(Arrays.asList(arnTemplate.split("/"))); + return Arrays.asList(arnTemplate.split("/")); } } diff --git a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator index 68fa9892a8d..d03291f5128 100644 --- a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator +++ b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -1,2 +1,2 @@ software.amazon.smithy.aws.iam.traits.ConditionKeysValidator -software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator \ No newline at end of file +software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator diff --git a/smithy-cli/clone-template.sh b/smithy-cli/clone-template.sh new file mode 100755 index 00000000000..dc9f750814b --- /dev/null +++ b/smithy-cli/clone-template.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +#REPO=ssh://git.amazon.com/pkg/Smithy-Examples +#TEMPLATE_PATH=templates/common-shapes + +REPO=$1 +TEMPLATE=$2 +TEMPLATE_PATH="templates/$TEMPLATE" +RELATIVE_PREFIX=../ + +# Check whether current directory is a Git repo +if git rev-parse --is-inside-work-tree >& /dev/null; then + printf '%s\n' "Cannot clone template into an existing Git repository" >&2 + exit 1 +fi + +rm -rf Smithy-Examples +git clone --filter=blob:none --no-checkout --depth 1 --sparse $REPO +cd Smithy-Examples +git sparse-checkout set --no-cone $TEMPLATE_PATH +git checkout + +SYMLINK_PATH=$(readlink $TEMPLATE_PATH) +if [ -z ${SYMLINK_PATH+x} ]; then + echo "no symlink found. continuing"; +else + echo "symlink found: '$SYMLINK_PATH'"; + TEMPLATE_PATH=${SYMLINK_PATH#$RELATIVE_PREFIX} + git sparse-checkout set --no-cone $TEMPLATE_PATH + git checkout +fi + +rm -rf "../$TEMPLATE" +mv $TEMPLATE_PATH "../$TEMPLATE" +rm -rf ../Smithy-Examples diff --git a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java new file mode 100644 index 00000000000..d11f5a51158 --- /dev/null +++ b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java @@ -0,0 +1,112 @@ +/* + * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.smithy.cli.commands; + +import software.amazon.smithy.cli.ArgumentReceiver; +import software.amazon.smithy.cli.Arguments; +import software.amazon.smithy.cli.Command; +import software.amazon.smithy.cli.HelpPrinter; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class InitCommand implements Command { + + private static final Logger LOGGER = Logger.getLogger(InitCommand.class.getName()); + + private final String parentCommandName; + + public InitCommand(String parentCommandName) { + this.parentCommandName = parentCommandName; + } + + @Override + public String getName() { + return "init"; + } + + @Override + public String getSummary() { + return "Init a smithy workspace by template"; + } + + @Override + public int execute(Arguments arguments, Env env) { + arguments.addReceiver(new Options()); + CommandAction action = HelpActionWrapper.fromCommand(this, parentCommandName, this::run); + return action.apply(arguments, env); + } + + public void executeScript(String repoUrl, String template) throws IOException, InterruptedException { + String command = String.format("sh /Volumes/workplace/smithy/smithy-cli/clone-template.sh %s %s", repoUrl, template); + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + + BufferedReader errorReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); + + String line = ""; + while ((line = errorReader.readLine()) != null) { + LOGGER.log(Level.INFO, line); + } + } + + private int run(Arguments arguments, Env env) { + Options options = arguments.getReceiver(Options.class); + try { + this.executeScript(options.repoUrl, options.template); + } catch (IOException | InterruptedException e) { + throw new RuntimeException(e); + } + + return 0; + } + + private static final class Options implements ArgumentReceiver { + private String template; + + private String repoUrl = "ssh://git.amazon.com/pkg/Smithy-Examples"; + + @Override + public boolean testOption(String name) { + return false; + } + + @Override + public Consumer testParameter(String name) { + switch (name) { + case "--template": + return value -> template = value; + case "--url": + return value -> repoUrl = value; + default: + return value -> { + }; + } + } + + @Override + public void registerHelp(HelpPrinter printer) { + printer.param("--template", null, "", + "template name"); + printer.param("--url", null, "", + "repo url"); + } + } +} From 78ab86339cc11eafb748b72450b434a872dd65af Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:25:37 -0600 Subject: [PATCH 06/11] Add errorfiles test runner --- .../iam/traits/ConditionKeysIndexTest.java | 14 ------ .../iam/traits/IamResourceValidatorTest.java | 44 ------------------- .../smithy/aws/iam/traits/TestRunnerTest.java | 21 +++++++++ .../invalid-condition-keys.errors | 1 + .../invalid-condition-keys.smithy | 0 .../invalid-iam-resources.errors | 3 ++ .../invalid-iam-resources.smithy | 0 .../smithy/aws/iam/traits/iam-resource.smithy | 3 ++ 8 files changed, 28 insertions(+), 58 deletions(-) delete mode 100644 smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java create mode 100644 smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/TestRunnerTest.java create mode 100644 smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors rename smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/{ => errorfiles/condition-keys}/invalid-condition-keys.smithy (100%) create mode 100644 smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors rename smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/{ => errorfiles/iam-resources}/invalid-iam-resources.smithy (100%) diff --git a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/ConditionKeysIndexTest.java b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/ConditionKeysIndexTest.java index d649fe1baf2..5f5842f604f 100644 --- a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/ConditionKeysIndexTest.java +++ b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/ConditionKeysIndexTest.java @@ -65,18 +65,4 @@ public void successfullyLoadsConditionKeys() { assertThat(index.getDefinedConditionKeys(service, ShapeId.from("smithy.example#GetResource2")).keySet(), is(empty())); } - - @Test - public void detectsUnknownConditionKeys() { - ValidatedResult result = Model.assembler() - .addImport(getClass().getResource("invalid-condition-keys.smithy")) - .discoverModels(getClass().getClassLoader()) - .assemble(); - - assertTrue(result.isBroken()); - assertThat(result.getValidationEvents(Severity.ERROR).stream() - .map(ValidationEvent::getId) - .collect(Collectors.toSet()), - contains("ConditionKeys")); - } } diff --git a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java deleted file mode 100644 index 9effedf33c9..00000000000 --- a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/IamResourceValidatorTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package software.amazon.smithy.aws.iam.traits; - -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.validation.Severity; -import software.amazon.smithy.model.validation.ValidatedResult; -import software.amazon.smithy.model.validation.ValidationEvent; - -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class IamResourceValidatorTest { - @Test - public void detectsUnknownConditionKeys() { - ValidatedResult result = Model.assembler() - .addImport(getClass().getResource("invalid-iam-resources.smithy")) - .discoverModels(getClass().getClassLoader()) - .assemble(); - - assertTrue(result.isBroken()); - assertEquals(result.getValidationEvents().size(), 3); - assertThat(result.getValidationEvents(Severity.DANGER).stream() - .map(ValidationEvent::getId) - .collect(Collectors.toSet()), - contains("IamResourceTrait")); - assertThat(result.getValidationEvents(Severity.DANGER).stream() - .map(ValidationEvent::getShapeId) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toSet()), - containsInAnyOrder( - ShapeId.from("smithy.example#IncompatibleResourceName"), - ShapeId.from("smithy.example#InvalidResource"), - ShapeId.from("smithy.example#BadIamResourceName") - )); - } -} diff --git a/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/TestRunnerTest.java b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/TestRunnerTest.java new file mode 100644 index 00000000000..aa2c66b47c2 --- /dev/null +++ b/smithy-aws-iam-traits/src/test/java/software/amazon/smithy/aws/iam/traits/TestRunnerTest.java @@ -0,0 +1,21 @@ +package software.amazon.smithy.aws.iam.traits; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import software.amazon.smithy.model.validation.testrunner.SmithyTestCase; +import software.amazon.smithy.model.validation.testrunner.SmithyTestSuite; + +import java.util.concurrent.Callable; +import java.util.stream.Stream; + +public class TestRunnerTest { + @ParameterizedTest(name = "{0}") + @MethodSource("source") + public void testRunner(String filename, Callable callable) throws Exception { + callable.call(); + } + + public static Stream source() { + return SmithyTestSuite.defaultParameterizedTestSource(TestRunnerTest.class); + } +} diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors new file mode 100644 index 00000000000..80db3255752 --- /dev/null +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors @@ -0,0 +1 @@ +[ERROR] smithy.example#Operation: This operation scoped within the `smithy.example#MyService` service refers to an undefined condition key `foo:qux`. Expected one of the following defined condition keys: [`foo:baz`] | ConditionKeys \ No newline at end of file diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-condition-keys.smithy b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.smithy similarity index 100% rename from smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-condition-keys.smithy rename to smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.smithy diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors new file mode 100644 index 00000000000..16bc16b66ea --- /dev/null +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors @@ -0,0 +1,3 @@ +[DANGER] smithy.example#BadIamResourceName: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `bad-iam-resourceName`, that does not match the `@arn` template, `bad-iam-resource-name/{id}`, for that same resource. | IamResourceTrait +[DANGER] smithy.example#IncompatibleResourceName: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `IncompatibleResourceName`, that does not match the `@arn` template, `beer/{beerId}/incompatible-resource-name`, for that same resource. | IamResourceTrait +[DANGER] smithy.example#InvalidResource: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `invalidResource`, that does not match the `@arn` template, `invalid-resource`, for that same resource. | IamResourceTrait \ No newline at end of file diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.smithy similarity index 100% rename from smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/invalid-iam-resources.smithy rename to smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.smithy diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/iam-resource.smithy b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/iam-resource.smithy index b7fb78baad3..76bfb1e2df7 100644 --- a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/iam-resource.smithy +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/iam-resource.smithy @@ -2,6 +2,8 @@ $version: "1.0" namespace smithy.example +use aws.api#arn + @aws.api#service(sdkId: "My") service MyService { version: "2020-07-02", @@ -9,6 +11,7 @@ service MyService { } @aws.iam#iamResource(name: "super") +@arn(template: "super/{id1}") resource SuperResource { identifiers: { id1: String, From e7b180bf13ef97960f08ee0c778db758d5f923c6 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:30:26 -0600 Subject: [PATCH 07/11] Revert "Address PR comments" This reverts commit 3753ac25490074ccdb09eb3079489eb2874a95bd. --- .../iam/traits/IamResourceTraitValidator.java | 10 +- ...e.amazon.smithy.model.validation.Validator | 2 +- smithy-cli/clone-template.sh | 35 ------ .../smithy/cli/commands/InitCommand.java | 112 ------------------ 4 files changed, 6 insertions(+), 153 deletions(-) delete mode 100755 smithy-cli/clone-template.sh delete mode 100644 smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index e236b649ce0..2b8911570fc 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -41,14 +41,14 @@ public List validate(Model model) { // check that the resource name is consistent between the two traits if (resource.hasTrait(ArnTrait.class)) { String resourceName = resource.expectTrait(IamResourceTrait.class).getName() - .orElseGet(() -> StringUtils.lowerCase(resource.getId().getName())); + .orElse(StringUtils.lowerCase(resource.getId().getName())); ArnTrait arnTrait = resource.expectTrait(ArnTrait.class); List arnComponents = parseArnComponents(arnTrait.getTemplate()); if (!arnComponents.contains(resourceName)) { results.add(danger(resource, String.format( - "The `@aws.iam#iamResource trait applied to the resource " - + "defines an IAM resource name, `%s`, that does not match the `@arn` template, " - + "`%s`, for that same resource.", + "The `@aws.iam#iamResource` trait applied to this resource " + + "defines a resource name, `%s`, that does not match the `@arn` template, " + + "`%s`, of the resource.", resourceName, arnTrait.getTemplate()))); } } @@ -57,6 +57,6 @@ public List validate(Model model) { } private List parseArnComponents(String arnTemplate) { - return Arrays.asList(arnTemplate.split("/")); + return new ArrayList<>(Arrays.asList(arnTemplate.split("/"))); } } diff --git a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator index d03291f5128..68fa9892a8d 100644 --- a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator +++ b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -1,2 +1,2 @@ software.amazon.smithy.aws.iam.traits.ConditionKeysValidator -software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator +software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator \ No newline at end of file diff --git a/smithy-cli/clone-template.sh b/smithy-cli/clone-template.sh deleted file mode 100755 index dc9f750814b..00000000000 --- a/smithy-cli/clone-template.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -#REPO=ssh://git.amazon.com/pkg/Smithy-Examples -#TEMPLATE_PATH=templates/common-shapes - -REPO=$1 -TEMPLATE=$2 -TEMPLATE_PATH="templates/$TEMPLATE" -RELATIVE_PREFIX=../ - -# Check whether current directory is a Git repo -if git rev-parse --is-inside-work-tree >& /dev/null; then - printf '%s\n' "Cannot clone template into an existing Git repository" >&2 - exit 1 -fi - -rm -rf Smithy-Examples -git clone --filter=blob:none --no-checkout --depth 1 --sparse $REPO -cd Smithy-Examples -git sparse-checkout set --no-cone $TEMPLATE_PATH -git checkout - -SYMLINK_PATH=$(readlink $TEMPLATE_PATH) -if [ -z ${SYMLINK_PATH+x} ]; then - echo "no symlink found. continuing"; -else - echo "symlink found: '$SYMLINK_PATH'"; - TEMPLATE_PATH=${SYMLINK_PATH#$RELATIVE_PREFIX} - git sparse-checkout set --no-cone $TEMPLATE_PATH - git checkout -fi - -rm -rf "../$TEMPLATE" -mv $TEMPLATE_PATH "../$TEMPLATE" -rm -rf ../Smithy-Examples diff --git a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java deleted file mode 100644 index d11f5a51158..00000000000 --- a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -package software.amazon.smithy.cli.commands; - -import software.amazon.smithy.cli.ArgumentReceiver; -import software.amazon.smithy.cli.Arguments; -import software.amazon.smithy.cli.Command; -import software.amazon.smithy.cli.HelpPrinter; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.function.Consumer; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class InitCommand implements Command { - - private static final Logger LOGGER = Logger.getLogger(InitCommand.class.getName()); - - private final String parentCommandName; - - public InitCommand(String parentCommandName) { - this.parentCommandName = parentCommandName; - } - - @Override - public String getName() { - return "init"; - } - - @Override - public String getSummary() { - return "Init a smithy workspace by template"; - } - - @Override - public int execute(Arguments arguments, Env env) { - arguments.addReceiver(new Options()); - CommandAction action = HelpActionWrapper.fromCommand(this, parentCommandName, this::run); - return action.apply(arguments, env); - } - - public void executeScript(String repoUrl, String template) throws IOException, InterruptedException { - String command = String.format("sh /Volumes/workplace/smithy/smithy-cli/clone-template.sh %s %s", repoUrl, template); - Process p = Runtime.getRuntime().exec(command); - p.waitFor(); - - BufferedReader errorReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); - - String line = ""; - while ((line = errorReader.readLine()) != null) { - LOGGER.log(Level.INFO, line); - } - } - - private int run(Arguments arguments, Env env) { - Options options = arguments.getReceiver(Options.class); - try { - this.executeScript(options.repoUrl, options.template); - } catch (IOException | InterruptedException e) { - throw new RuntimeException(e); - } - - return 0; - } - - private static final class Options implements ArgumentReceiver { - private String template; - - private String repoUrl = "ssh://git.amazon.com/pkg/Smithy-Examples"; - - @Override - public boolean testOption(String name) { - return false; - } - - @Override - public Consumer testParameter(String name) { - switch (name) { - case "--template": - return value -> template = value; - case "--url": - return value -> repoUrl = value; - default: - return value -> { - }; - } - } - - @Override - public void registerHelp(HelpPrinter printer) { - printer.param("--template", null, "", - "template name"); - printer.param("--url", null, "", - "repo url"); - } - } -} From 5751b629139d36882edfbc3523b9ca8032aa11ec Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:38:53 -0600 Subject: [PATCH 08/11] Re-add changes without accidentally popped stashed changes --- .../smithy/aws/iam/traits/IamResourceTraitValidator.java | 8 ++++---- .../software.amazon.smithy.model.validation.Validator | 2 +- .../errorfiles/iam-resources/invalid-iam-resources.errors | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 2b8911570fc..157696a64b7 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -46,9 +46,9 @@ public List validate(Model model) { List arnComponents = parseArnComponents(arnTrait.getTemplate()); if (!arnComponents.contains(resourceName)) { results.add(danger(resource, String.format( - "The `@aws.iam#iamResource` trait applied to this resource " - + "defines a resource name, `%s`, that does not match the `@arn` template, " - + "`%s`, of the resource.", + "The `@aws.iam#iamResource` trait applied to the resource " + + "defines an IAM resource name, `%s`, that does not match the `@arn` template, " + + "`%s`, for that same resource.", resourceName, arnTrait.getTemplate()))); } } @@ -57,6 +57,6 @@ public List validate(Model model) { } private List parseArnComponents(String arnTemplate) { - return new ArrayList<>(Arrays.asList(arnTemplate.split("/"))); + return Arrays.asList(arnTemplate.split("/")); } } diff --git a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator index 68fa9892a8d..d03291f5128 100644 --- a/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator +++ b/smithy-aws-iam-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -1,2 +1,2 @@ software.amazon.smithy.aws.iam.traits.ConditionKeysValidator -software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator \ No newline at end of file +software.amazon.smithy.aws.iam.traits.IamResourceTraitValidator diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors index 16bc16b66ea..b9a472f82be 100644 --- a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors @@ -1,3 +1,3 @@ -[DANGER] smithy.example#BadIamResourceName: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `bad-iam-resourceName`, that does not match the `@arn` template, `bad-iam-resource-name/{id}`, for that same resource. | IamResourceTrait -[DANGER] smithy.example#IncompatibleResourceName: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `IncompatibleResourceName`, that does not match the `@arn` template, `beer/{beerId}/incompatible-resource-name`, for that same resource. | IamResourceTrait -[DANGER] smithy.example#InvalidResource: The `@aws.iam#iamResource trait applied to the resource defines an IAM resource name, `invalidResource`, that does not match the `@arn` template, `invalid-resource`, for that same resource. | IamResourceTrait \ No newline at end of file +[DANGER] smithy.example#BadIamResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `bad-iam-resourceName`, that does not match the `@arn` template, `bad-iam-resource-name/{id}`, for that same resource. | IamResourceTrait +[DANGER] smithy.example#IncompatibleResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `IncompatibleResourceName`, that does not match the `@arn` template, `beer/{beerId}/incompatible-resource-name`, for that same resource. | IamResourceTrait +[DANGER] smithy.example#InvalidResource: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `invalidResource`, that does not match the `@arn` template, `invalid-resource`, for that same resource. | IamResourceTrait From bf1e49c8fc4d6f184fe3850a0c6aa7f05be16f56 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:40:30 -0600 Subject: [PATCH 09/11] Update to use orElseGet --- .../amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 157696a64b7..9d72d79b8ec 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -41,7 +41,7 @@ public List validate(Model model) { // check that the resource name is consistent between the two traits if (resource.hasTrait(ArnTrait.class)) { String resourceName = resource.expectTrait(IamResourceTrait.class).getName() - .orElse(StringUtils.lowerCase(resource.getId().getName())); + .orElseGet(() -> StringUtils.lowerCase(resource.getId().getName())); ArnTrait arnTrait = resource.expectTrait(ArnTrait.class); List arnComponents = parseArnComponents(arnTrait.getTemplate()); if (!arnComponents.contains(resourceName)) { From e7363b2b81fc766e8a8069f041a985e15939da42 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:41:53 -0600 Subject: [PATCH 10/11] Re-add change that was accidentally removed --- .../smithy/aws/iam/traits/IamResourceTraitValidator.java | 2 +- .../errorfiles/iam-resources/invalid-iam-resources.errors | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java index 9d72d79b8ec..1591bc53c3e 100644 --- a/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java +++ b/smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java @@ -48,7 +48,7 @@ public List validate(Model model) { results.add(danger(resource, String.format( "The `@aws.iam#iamResource` trait applied to the resource " + "defines an IAM resource name, `%s`, that does not match the `@arn` template, " - + "`%s`, for that same resource.", + + "`%s`, of the resource.", resourceName, arnTrait.getTemplate()))); } } diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors index b9a472f82be..4278821c860 100644 --- a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/iam-resources/invalid-iam-resources.errors @@ -1,3 +1,3 @@ -[DANGER] smithy.example#BadIamResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `bad-iam-resourceName`, that does not match the `@arn` template, `bad-iam-resource-name/{id}`, for that same resource. | IamResourceTrait -[DANGER] smithy.example#IncompatibleResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `IncompatibleResourceName`, that does not match the `@arn` template, `beer/{beerId}/incompatible-resource-name`, for that same resource. | IamResourceTrait -[DANGER] smithy.example#InvalidResource: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `invalidResource`, that does not match the `@arn` template, `invalid-resource`, for that same resource. | IamResourceTrait +[DANGER] smithy.example#BadIamResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `bad-iam-resourceName`, that does not match the `@arn` template, `bad-iam-resource-name/{id}`, of the resource. | IamResourceTrait +[DANGER] smithy.example#IncompatibleResourceName: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `IncompatibleResourceName`, that does not match the `@arn` template, `beer/{beerId}/incompatible-resource-name`, of the resource. | IamResourceTrait +[DANGER] smithy.example#InvalidResource: The `@aws.iam#iamResource` trait applied to the resource defines an IAM resource name, `invalidResource`, that does not match the `@arn` template, `invalid-resource`, of the resource. | IamResourceTrait From 2462181b1ee6a84bab0ad9175553cb63b22f26c4 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 20 Jun 2023 10:42:32 -0600 Subject: [PATCH 11/11] Add newline at end of file --- .../errorfiles/condition-keys/invalid-condition-keys.errors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors index 80db3255752..a347362d072 100644 --- a/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors +++ b/smithy-aws-iam-traits/src/test/resources/software/amazon/smithy/aws/iam/traits/errorfiles/condition-keys/invalid-condition-keys.errors @@ -1 +1 @@ -[ERROR] smithy.example#Operation: This operation scoped within the `smithy.example#MyService` service refers to an undefined condition key `foo:qux`. Expected one of the following defined condition keys: [`foo:baz`] | ConditionKeys \ No newline at end of file +[ERROR] smithy.example#Operation: This operation scoped within the `smithy.example#MyService` service refers to an undefined condition key `foo:qux`. Expected one of the following defined condition keys: [`foo:baz`] | ConditionKeys