Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(appsync): clean up code and bugs for auth config #9847

Merged
merged 6 commits into from
Aug 21, 2020

Conversation

BryanPan342
Copy link
Contributor

Added unit tests for default and additional auth config and cleaning up the code.

Fixes: #9846


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@BryanPan342 BryanPan342 added pr/do-not-merge This PR should not be merged at this time. @aws-cdk/aws-appsync Related to AWS AppSync labels Aug 19, 2020
@BryanPan342 BryanPan342 self-assigned this Aug 19, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 19, 2020
@BryanPan342 BryanPan342 removed the pr/do-not-merge This PR should not be merged at this time. label Aug 20, 2020
Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change the title of this issue to be a chore or a refactor
you can still have Closes #abcd in the commit body, but I don't think this belongs in the release changelog as it does not really resolve a user facing bug or alter the API

Comment on lines 125 to 140
const when = () => {
new appsync.GraphQLApi(stack, 'api', {
name: 'api',
schemaDefinition: appsync.SchemaDefinition.FILE,
schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'),
authorizationConfig: {
additionalAuthorizationModes: [{
authorizationType: appsync.AuthorizationType.API_KEY,
}],
},
});
};

// THEN
expect(when).toThrowError('You can\'t duplicate API_KEY configuration. See https://docs.aws.amazon.com/appsync/latest/devguide/security.html');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we typically wrap the code that throws with the when

i.e.

expect(() => { //code that throws
  }).toThrowError("message");

I know this was already existing code, but let's align it with our normal conventions in this chore/refactor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code is a little big tho.. are you suggesting just putting everything into the expect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, ultimately it requires the same amount of reading to understand the scenario where the error is thrown.
I'm not strongly opinionated here, just pointing out that it's not aligned with the style of the rest of the codebase

packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts Outdated Show resolved Hide resolved
@BryanPan342 BryanPan342 changed the title fix(appsync): clean up code and bugs for auth config chore(appsync): clean up code and bugs for auth config Aug 20, 2020
@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f021d61
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 25a9cc7 into aws:master Aug 21, 2020
@BryanPan342 BryanPan342 deleted the config-refactor branch September 8, 2020 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[appsync]: unit/integ tests for authorization config
3 participants