Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cb8d3f8
fix: double hooks invocation (fixes #9996)
jhockett Apr 21, 2023
96d0ce1
test: ensure single execution of push hooks
jhockett Apr 24, 2023
a4142e8
fix: codeql findings
jhockett Apr 24, 2023
dbf1550
style: run prettier
jhockett Apr 24, 2023
8a599ba
fix(mock)-handle stack trace & produce meaningful error, resolution m…
manaswi223 Apr 27, 2023
dc43eb8
address comments
manaswi223 Apr 28, 2023
b013e9c
make getAppSyncAPI public
manaswi223 Apr 28, 2023
606284d
address comments
manaswi223 Apr 28, 2023
9cad369
remove unwanted ?
manaswi223 Apr 28, 2023
0132ccc
fix lint errors
manaswi223 Apr 28, 2023
4387f34
use AmplifyError as exception
manaswi223 Apr 28, 2023
0f20518
Merge pull request #12537 from aws-amplify/fix/stack-trace-mockAPI
aws-eddy May 1, 2023
91826bb
Merge pull request #12512 from jhockett/double-hooks
aws-eddy May 1, 2023
6885e01
fix: add min delay to exp backoff (#12488)
jhockett May 1, 2023
ad063e1
fix: remove smoketest from normal e2e flow (#12555)
sdstolworthy May 1, 2023
8eaf6c3
fix: don't throw for missing backend in prepush function handler (#12…
Amplifiyer May 1, 2023
3586334
test: fix bad import in pull-2 e2e test (#12559)
jhockett May 1, 2023
663737a
fix: generate OAuth keys from cognito for amplify pull workflow (#12518)
akshbhu May 1, 2023
4616a18
test: add hooks-c e2e to windows exclusion list (#12562)
jhockett May 1, 2023
864c197
Run smoketests with e2e (#12558)
sdstolworthy May 1, 2023
687dcc2
feat(amplify-util-uibuilder): update codegen-ui to 2.13.1 (#12565)
May 2, 2023
0d6bca4
fix: exclude smoketests on windows; remove extraneous dependency (#12…
sdstolworthy May 2, 2023
2d51b74
fix: yarn lock
pavellazar May 2, 2023
bd57e36
chore: yarn lock updates
pavellazar May 2, 2023
22aa332
chore: test updates
pavellazar May 3, 2023
2039c58
test: fix function parameters
pavellazar May 3, 2023
0697cfb
chore: update mock util tests to be executed
pavellazar May 3, 2023
daecff5
chore: update container hosting dependencies in yarn
pavellazar May 3, 2023
8f813d3
chore: update snapshots
pavellazar May 3, 2023
7129a3f
test: revert serializable error logic
pavellazar May 3, 2023
a85607e
test: fix amplify-cli package tests
pavellazar May 3, 2023
1cb72d9
chore: migrate to yarn 2 (#12501)
pavellazar May 3, 2023
cc3b6ce
chore: merged latest yarn-migration-main
pavellazar May 3, 2023
ffd7306
chore: fix yarn.lock
pavellazar May 3, 2023
7873e6a
test: auth snapshots updated
pavellazar May 3, 2023
10735b0
chore: prettier run
pavellazar May 3, 2023
2a57333
chore: prettier run
pavellazar May 3, 2023
6d61e85
chore: prettier run
pavellazar May 3, 2023
8c8ac3b
chore: prettier run
pavellazar May 3, 2023
a3015a8
chore: prettier run
pavellazar May 3, 2023
a8e23f4
chore: remove set registy step, already in config file
pavellazar May 3, 2023
7bc8c67
chore: remove set registy step, already in config file
pavellazar May 3, 2023
d7cc6b2
chore: remove set registy step, already in config file
pavellazar May 3, 2023
42ceba8
fix: plugin lookup directory
pavellazar May 4, 2023
8c7959b
try and fix pkg linux (#53)
aws-eddy May 4, 2023
3e548d1
chore: add plugins
pavellazar May 4, 2023
72007b4
chore: add plugins
pavellazar May 4, 2023
c2da27f
chore: testing changes
aws-eddy May 10, 2023
8d8e7a9
Merge branch 'ev-ym-tests' into fix-util-mock-tests
aws-eddy May 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .circleci/config.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ jobs:
executor: l_xlarge
steps:
- checkout
- run: yarn config set npmRegistryServer https://registry.npmjs.org
- run: yarn --immutable
- run: yarn production-build
- run:
Expand All @@ -133,7 +132,6 @@ jobs:
executor: l_xlarge
steps:
- checkout
- run: yarn config set npmRegistryServer https://registry.npmjs.org
- run: yarn install --immutable
- run:
name: Build tests
Expand Down
7 changes: 1 addition & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"Orta.vscode-jest",
"arcanis.vscode-zipfs",
"esbenp.prettier-vscode"
]
"recommendations": ["dbaeumer.vscode-eslint", "Orta.vscode-jest", "arcanis.vscode-zipfs", "esbenp.prettier-vscode"]
}
11 changes: 2 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"editor.rulers": [
140
],
"editor.rulers": [140],
"files.exclude": {
"**/.git": true,
"**/build": true
},
"files.insertFinalNewline": true,
"editor.formatOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.lintTask.enable": true,
"eslint.packageManager": "yarn",
"eslint.quiet": false,
Expand Down
4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ nmMode: hardlinks-local
nodeLinker: node-modules

npmRegistryServer: 'https://registry.npmjs.org'
unsafeHttpWhitelist:
- 'localhost'

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
unsafeHttpWhitelist:
- localhost

yarnPath: .yarn/releases/yarn-3.5.0.cjs
4 changes: 1 addition & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
2 changes: 0 additions & 2 deletions nx.ignore

This file was deleted.

77 changes: 16 additions & 61 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"test",
"lint",
"package",
"prepare",
"extract-api"
],
"cacheableOperations": ["build", "test", "lint", "package", "prepare", "extract-api"],
"parallel": 8
}
}
Expand All @@ -35,71 +28,33 @@
},
"targetDefaults": {
"build": {
"inputs": [
"default",
"^production"
],
"dependsOn": [
"^build"
]
"inputs": ["default", "^production"],
"dependsOn": ["^build"]
},
"build-tests": {
"inputs": [
"default",
"^production"
],
"dependsOn": [
"build",
"^build"
]
"inputs": ["default", "^production"],
"dependsOn": ["build", "^build"]
},
"prepare": {
"inputs": [
"default",
"^default"
],
"dependsOn": [
"^prepare"
]
"inputs": ["default", "^default"],
"dependsOn": ["^prepare"]
},
"package": {
"inputs": [
"default",
"^default"
],
"dependsOn": [
"^package"
]
"inputs": ["default", "^default"],
"dependsOn": ["^package"]
},
"smoketest": {
"inputs": [
"default",
"^production"
],
"dependsOn": [
"build"
]
"inputs": ["default", "^production"],
"dependsOn": ["build"]
},
"test": {
"inputs": [
"default",
"^production"
],
"dependsOn": [
"build"
]
"inputs": ["default", "^production"],
"dependsOn": ["build"]
},
"extract-api": {
"dependsOn": [
"build"
],
"inputs": [
"{projectRoot}/src/**/*",
"!{projectRoot}/src/__tests__/**/*"
],
"outputs": [
"{projectRoot}/API.md"
]
"dependsOn": ["build"],
"inputs": ["{projectRoot}/src/**/*", "!{projectRoot}/src/__tests__/**/*"],
"outputs": ["{projectRoot}/API.md"]
}
},
"affected": {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"build": "lerna run build",
"check-version-conflicts:beta": "yarn ts-node ./scripts/check-version.ts beta",
"check-version-conflicts:release": "yarn ts-node ./scripts/check-version.ts",
"clean": "lerna run clean && lerna exec yarn rimraf tsconfig.tsbuildinfo && lerna clean --yes && yarn rimraf node_modules",
"clean": "lerna run clean && yarn rimraf tsconfig.tsbuildinfo && lerna clean --yes && yarn rimraf node_modules",
"cloud-e2e-with-rc": "CURR_BRANCH=$(git branch | awk '/\\*/{printf \"%s\", $2}') && UPSTREAM_BRANCH=run-e2e-with-rc/$USER/$CURR_BRANCH && git push $(git remote -v | grep aws-amplify/amplify-cli | head -n1 | awk '{print $1;}') $CURR_BRANCH:$UPSTREAM_BRANCH --no-verify --force-with-lease && echo \"\n\n 🏃 E2E test are running at:\nhttps://app.circleci.com/pipelines/github/aws-amplify/amplify-cli?branch=$UPSTREAM_BRANCH\"",
"cloud-e2e": "CURR_BRANCH=$(git branch | awk '/\\*/{printf \"%s\", $2}') && UPSTREAM_BRANCH=run-e2e/$USER/$CURR_BRANCH && git push $(git remote -v | grep aws-amplify/amplify-cli | head -n1 | awk '{print $1;}') $CURR_BRANCH:$UPSTREAM_BRANCH --no-verify --force-with-lease && echo \"\n\n 🏃 E2E test are running at:\nhttps://app.circleci.com/pipelines/github/aws-amplify/amplify-cli?branch=$UPSTREAM_BRANCH\"",
"commit": "git-cz",
"coverage:collect": "ts-node ./scripts/collect-test-coverage.ts",
"coverage": "codecov || exit 0",
"e2e": "lerna run e2e",
"extract-api": "lerna run extract-api",
"extract-api": "lerna run extract-api --concurrency 4",
"extract-formatting-changes": "yarn ts-node ./scripts/extract-formatting-changes.ts",
"finish-release": "ts-node ./scripts/finish-release.ts",
"link-aa-dev": "mkdir -p .bin/ && cd packages/amplify-app && ln -s \"$(pwd)/bin/amplify-app\" ../../.bin/amplify-app-dev && cd ../../",
Expand Down Expand Up @@ -49,7 +49,7 @@
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .circleci/config.yml",
"test-changed": "lerna run test --since dev",
"test-ci": "lerna run test --concurrency 4 -- --ci -i",
"test": "lerna run test",
"test": "lerna run test --concurrency 1",
"update-data-packages": "./scripts/update-data-dependencies.sh && yarn",
"update-test-timing-data": "ts-node ./scripts/cci-get-job-metrics.ts && ts-node ./scripts/cci-extract-test-timings-from-job-metrics.ts",
"update-versions": "lerna version --yes --no-commit-hooks --no-push --exact --conventional-commits --no-git-tag-version",
Expand Down
1 change: 1 addition & 0 deletions packages/amplify-category-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/client-cognito-identity-provider": "^3.303.0",
"@types/mime-types": "^2.1.1",
"cloudform-types": "^4.2.0",
"jest": "^29.5.0",
"rimraf": "^3.0.2"
},
"jest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ describe('generateCognitoStackResources', () => {
cognitoStack.createOAuthCustomResource();
expect(cognitoStack.oAuthCustomResource).toBeDefined();
expect(
cognitoStack.
oAuthCustomResource!.node!.dependencies!.map((dep: any) => dep.logicalId).
map((logicalIdToken) => /testCognitoStack\.([^.]+)\.Default/.exec(logicalIdToken)![1])).
toMatchInlineSnapshot(`
cognitoStack
.oAuthCustomResource!.node!.dependencies!.map((dep: any) => dep.logicalId)
.map((logicalIdToken) => /testCognitoStack\.([^.]+)\.Default/.exec(logicalIdToken)![1]),
).toMatchInlineSnapshot(`
[
"HostedUICustomResourceInputs",
"HostedUIProvidersCustomResourceInputs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { updateConfigOnEnvInit } from '../../../provider-utils/awscloudformation/index';
import { getOAuthObjectFromCognito } from '../../../provider-utils/awscloudformation/utils/get-oauth-secrets-from-cognito';

jest.mock('@aws-amplify/amplify-environment-parameters');
jest.mock('../../../provider-utils/awscloudformation/utils/get-oauth-secrets-from-cognito');
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
JSONUtilities: {
Expand All @@ -18,12 +20,14 @@ jest.mock('@aws-amplify/amplify-cli-core', () => ({
const pluginInstanceMock = jest.fn();
const loadResourceParametersMock = jest.fn().mockReturnValue({
hostedUIProviderMeta:
'[{"ProviderName":"Facebook","authorize_scopes":"email,public_profile","AttributeMapping":{"email":"email","username":"id"}},{"ProviderName":"LoginWithAmazon","authorize_scopes":"profile profile:user_id","AttributeMapping":{"email":"email","username":"user_id"}},{"ProviderName":"Google","authorize_scopes":"openid email profile","AttributeMapping":{"email":"email","username":"sub"}}]',
'[{"ProviderName":"Facebook","authorize_scopes":"email,public_profile","AttributeMapping":{"email":"email","username":"id"}},{"ProviderName":"LoginWithAmazon","authorize_scopes":"profile profile:user_id","AttributeMapping":{"email":"email","username":"user_id"}},{"ProviderName":"Google","authorize_scopes":"openid email profile","AttributeMapping":{"email":"email","username":"sub"}},{"ProviderName":"SignInWithApple","authorize_scopes":"openid email profile","AttributeMapping":{"email":"email","username":"sub"}}]',
});
const pluginInstance = {
loadResourceParameters: loadResourceParametersMock,
};

const getOAuthObjectFromCognitoMock = getOAuthObjectFromCognito as jest.MockedFunction<typeof getOAuthObjectFromCognito>;

// mock context
let mockContext = {
amplify: {
Expand Down Expand Up @@ -61,8 +65,106 @@ let mockContext = {
},
} as unknown as $TSContext;

test('throws amplify error when auth headless params are missing during pull', async () => {
expect(() => updateConfigOnEnvInit(mockContext, 'auth', 'Cognito')).rejects.toThrowErrorMatchingInlineSnapshot(
`"auth headless is missing the following inputParameters facebookAppIdUserPool, facebookAppSecretUserPool, loginwithamazonAppIdUserPool, loginwithamazonAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool"`,
);
describe('import checks', () => {
test('throws amplify error when auth headless params are missing during pull', async () => {
expect(() => updateConfigOnEnvInit(mockContext, 'auth', 'Cognito')).rejects.toThrowErrorMatchingInlineSnapshot(
`"auth headless is missing the following inputParameters facebookAppIdUserPool, facebookAppSecretUserPool, loginwithamazonAppIdUserPool, loginwithamazonAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool"`,
);
});
});

describe('update config when amplify pull headless command', () => {
test('throws amplify error when auth headless params are missing during pull', async () => {
mockContext.input.command = 'pull';
getOAuthObjectFromCognitoMock.mockResolvedValue(undefined);
expect(() => updateConfigOnEnvInit(mockContext, 'auth', 'Cognito')).rejects.toThrowErrorMatchingInlineSnapshot(
`"auth headless is missing the following inputParameters facebookAppIdUserPool, facebookAppSecretUserPool, loginwithamazonAppIdUserPool, loginwithamazonAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool"`,
);
});

test('works when secrets are fetched from userpool', async () => {
mockContext.input.command = 'pull';
getOAuthObjectFromCognitoMock.mockResolvedValue([
{
client_id: 'mockClientFacebook',
client_secret: 'mockSecretFacebook',
ProviderName: 'Facebook',
},
{
client_id: 'mockClientGoogle',
client_secret: 'mockSecretGoogle',
ProviderName: 'Google',
},
{
client_id: 'mockClientLoginWithAmazon',
client_secret: 'mockSecretLoginWithAmazon',
ProviderName: 'LoginWithAmazon',
},
{
client_id: 'mockClientSignInWithApple',
team_id: 'mockTeamIdSignInWithApple',
key_id: 'mockKeyIdSignInWithApple',
private_key: 'mockPrivayKeySignInWithApple',
ProviderName: 'SignInWithApple',
},
]);
const params = await updateConfigOnEnvInit(mockContext, 'auth', 'Cognito');
expect(params).toMatchInlineSnapshot(`
{
"hostedUIProviderCreds": "[{"ProviderName":"Facebook"},{"ProviderName":"LoginWithAmazon"},{"ProviderName":"Google"},{"ProviderName":"SignInWithApple"}]",
}
`);
});

test('works when secrets are present in deployment params', async () => {
mockContext.input.command = 'pull';
getOAuthObjectFromCognitoMock.mockResolvedValue(undefined);
mockContext.amplify.loadEnvResourceParameters = jest.fn().mockReturnValue({
hostedUIProviderCreds:
'[{"ProviderName":"Facebook","client_id":"sdcsdc","client_secret":"bfdsvsr"},{"ProviderName":"Google","client_id":"avearver","client_secret":"vcvereger"},{"ProviderName":"LoginWithAmazon","client_id":"vercvdsavcer","client_secret":"revfdsavrtv"},{"ProviderName":"SignInWithApple","client_id":"vfdvergver","team_id":"ervervre","key_id":"vfdavervfer","private_key":"vaveb"}]',
});
const params = await updateConfigOnEnvInit(mockContext, 'auth', 'Cognito');
expect(params).toMatchInlineSnapshot(`
{
"hostedUIProviderCreds": "[{"ProviderName":"Facebook"},{"ProviderName":"LoginWithAmazon"},{"ProviderName":"Google"},{"ProviderName":"SignInWithApple"}]",
}
`);
});

test('test works when secrets are present in context input params', async () => {
mockContext.input.command = 'pull';
getOAuthObjectFromCognitoMock.mockResolvedValue(undefined);
mockContext.amplify.loadEnvResourceParameters = jest.fn().mockReturnValue('[]');
mockContext.exeInfo = {
inputParams: {
yes: true,
categories: {
auth: {
facebookAppIdUserPool: 'mockfacebookAppIdUserPool',
facebookAppSecretUserPool: 'facebookAppSecretUserPool',
googleAppIdUserPool: 'googleAppIdUserPool',
googleAppSecretUserPool: 'googleAppSecretUserPool',
loginwithamazonAppIdUserPool: 'loginwithamazonAppIdUserPool',
loginwithamazonAppSecretUserPool: 'loginwithamazonAppSecretUserPool',
signinwithappleClientIdUserPool: 'signinwithappleClientIdUserPool',
signinwithappleTeamIdUserPool: 'signinwithappleTeamIdUserPool',
signinwithappleKeyIdUserPool: 'signinwithappleKeyIdUserPool',
signinwithapplePrivateKeyUserPool: 'signinwithapplePrivateKeyUserPool',
},
},
},
localEnvInfo: {
projectPath: 'mockProjectPath',
defaultEditor: 'vscode',
envName: 'dev',
noUpdateBackend: false,
},
};
const params = await updateConfigOnEnvInit(mockContext, 'auth', 'Cognito');
expect(params).toMatchInlineSnapshot(`
{
"hostedUIProviderCreds": "[{"ProviderName":"Facebook","client_id":"mockfacebookAppIdUserPool","client_secret":"facebookAppSecretUserPool"},{"ProviderName":"LoginWithAmazon","client_id":"loginwithamazonAppIdUserPool","client_secret":"loginwithamazonAppSecretUserPool"},{"ProviderName":"Google","client_id":"googleAppIdUserPool","client_secret":"googleAppSecretUserPool"},{"ProviderName":"SignInWithApple","client_id":"signinwithappleClientIdUserPool","team_id":"signinwithappleTeamIdUserPool","key_id":"signinwithappleKeyIdUserPool","private_key":"signinwithapplePrivateKeyUserPool"}]",
}
`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ const createEnvSpecificResourceParameters = (
return envSpecificResourceParameters;
};

const createOAuthCredentials = (identityProviders: IdentityProviderType[]): string => {
export const createOAuthCredentials = (identityProviders: IdentityProviderType[]): string => {
const credentials = identityProviders.map((idp) => {
if (idp.ProviderName === 'SignInWithApple') {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getAddAuthHandler, getUpdateAuthHandler } from './handlers/resource-han
import { getSupportedServices } from '../supported-services';
import { importResource, importedAuthEnvInit } from './import';
import { AuthContext } from '../../context';
import { getOAuthObjectFromCognito } from './utils/get-oauth-secrets-from-cognito';

export { importResource } from './import';

Expand Down Expand Up @@ -133,6 +134,14 @@ export const updateConfigOnEnvInit = async (context: $TSContext, category: any,

if (hostedUIProviderMeta) {
currentEnvSpecificValues = getOAuthProviderKeys(currentEnvSpecificValues, resourceParams);
const authParamsFromCognito = await getOAuthObjectFromCognito(context, resourceParams.userPoolName);
// fill in the OAuthProvider Keys from userpool if missing from currentEnvValues
if (authParamsFromCognito) {
currentEnvSpecificValues = {
...getOAuthProviderKeys({ hostedUIProviderCreds: JSON.stringify(authParamsFromCognito) }, resourceParams),
...currentEnvSpecificValues,
};
}
}

// legacy headless mode (only supports init)
Expand Down
Loading