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

fix(amplify-category-api): change auth directive type and fix codegen bug #8639

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

danielleadams
Copy link
Contributor

@danielleadams danielleadams commented Nov 3, 2021

Description of changes

changes the global authorization type to use AuthRule -> this also fixes the reported amplify codegen models bug.

Description of how you validated changes

Changed unit tests, tested locally, added codegen models to the e2e tests.

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies

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

@danielleadams danielleadams requested a review from a team as a code owner November 3, 2021 00:08
@codecov-commenter
Copy link

Codecov Report

Merging #8639 (8c3ce76) into master (73793b4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8639   +/-   ##
=======================================
  Coverage   56.97%   56.97%           
=======================================
  Files         741      741           
  Lines       41707    41707           
  Branches     8537     8537           
=======================================
  Hits        23764    23764           
  Misses      17122    17122           
  Partials      821      821           
Impacted Files Coverage Δ
...ils/awscloudformation/utils/global-sandbox-mode.ts 100.00% <ø> (ø)
...wscloudformation/src/utils/sandbox-mode-helpers.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73793b4...8c3ce76. Read the comment docs.

@danielleadams danielleadams marked this pull request as draft November 3, 2021 01:37
@danielleadams danielleadams marked this pull request as ready for review November 3, 2021 01:37
Copy link
Contributor

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

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

couple nits but LGTM

@@ -15,7 +15,7 @@ export async function showSandboxModePrompts(context: $TSContext): Promise<any>
printer.info(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could use printer.warn here. If you switch it, remove the leading ⚠️ as this will be prepended by warn internally

Comment on lines 159 to 171
for (let i = 0; i < authModes.length; i++) {
const mode = authModes[i];

if (mode !== 'API_KEY' && mode !== 'AMAZON_COGNITO_USER_POOLS' && mode !== 'AWS_IAM' && mode !== 'OPENID_CONNECT' && mode !== 'AWS_LAMBDA') {
if (
mode !== 'API_KEY' &&
mode !== 'AMAZON_COGNITO_USER_POOLS' &&
mode !== 'AWS_IAM' &&
mode !== 'OPENID_CONNECT' &&
mode !== 'AWS_LAMBDA'
) {
throw new Error(`Invalid auth mode ${mode}`);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I know this was just a formatting change, but this could be simplified a bit to:

const allowedAuthModes = ['API_KEY', 'AWS_IAM', ...];
const invalidMode = authModes.find(mode => !allowedAuthModes.includes(mode));
if (!!invalidMode) {
  throw new Error(`Invalid auth mode ${mode}`)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to go this route, please hoist the array out of the function so that the same array can be reused. It might also make sense to use a Set instead of an array (not sure if there are enough elements to make it worth it though).

@lazpavel lazpavel merged commit b8d838d into aws-amplify:master Nov 3, 2021
@danielleadams danielleadams deleted the update-sandbox-type branch November 3, 2021 19:36
@github-actions github-actions bot added the referenced-in-release Issues referenced in a published release changelog label Nov 11, 2021
@github-actions
Copy link

👋 Hi, this pull request was referenced in the v6.4.0 release!

Check out the release notes here https://github.com/aws-amplify/amplify-cli/releases/tag/v6.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
referenced-in-release Issues referenced in a published release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants