Skip to content

Commit

Permalink
test: rm e2e test changes and move to aws-amplify#10198
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleadams committed Apr 21, 2022
1 parent 5965a06 commit 81519b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ $util.unauthorized()
#if( $util.authType() == \\"User Pool Authorization\\" )
#if( !$isAuthorized )
#set( $ownerEntity0 = $util.defaultIfNull($ctx.args.input.owner, null) )
#set( $ownerClaim0 = $ctx.identity.claims.get(\\"sub\\") )
#set( $currentClaim0 = $util.defaultIfNull($ctx.identity.claims.get(\\"username\\"), $util.defaultIfNull($ctx.identity.claims.get(\\"cognito:username\\"), \\"___xamznone____\\")) )
#set( $ownerClaim0 = \\"$ownerClaim0:$currentClaim0\\" )
#set( $ownerClaim0 = $util.defaultIfNull($ctx.identity.claims.get(\\"username\\"), $util.defaultIfNull($ctx.identity.claims.get(\\"cognito:username\\"), \\"___xamznone____\\")) )
#set( $ownerAllowedFields0 = [\\"id\\",\\"content\\"] )
#set( $isAuthorizedOnAllFields0 = true )
#if( $ownerClaim0 == $ownerEntity0 )
Expand Down Expand Up @@ -65,9 +63,7 @@ $util.unauthorized()
#if( $util.authType() == \\"User Pool Authorization\\" )
#if( !$isAuthorized )
#set( $ownerEntity0 = $util.defaultIfNull($ctx.args.input.owner, null) )
#set( $ownerClaim0 = $ctx.identity.claims.get(\\"sub\\") )
#set( $currentClaim0 = $util.defaultIfNull($ctx.identity.claims.get(\\"username\\"), $util.defaultIfNull($ctx.identity.claims.get(\\"cognito:username\\"), \\"___xamznone____\\")) )
#set( $ownerClaim0 = \\"$ownerClaim0:$currentClaim0\\" )
#set( $ownerClaim0 = $util.defaultIfNull($ctx.identity.claims.get(\\"username\\"), $util.defaultIfNull($ctx.identity.claims.get(\\"cognito:username\\"), \\"___xamznone____\\")) )
#set( $ownerAllowedFields0 = [\\"id\\",\\"content\\"] )
#set( $isAuthorizedOnAllFields0 = true )
#if( $ownerClaim0 == $ownerEntity0 )
Expand Down
49 changes: 7 additions & 42 deletions packages/amplify-e2e-tests/src/__tests__/api_2.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
import { JSONUtilities } from 'amplify-cli-core';
import {
addApi,
Expand All @@ -21,15 +20,13 @@ import {
updateApiSchema,
updateAPIWithResolutionStrategyWithModels,
setCustomRolesConfig,
addFeatureFlag,
} from 'amplify-e2e-core';
import AWSAppSyncClient, { AUTH_TYPE } from 'aws-appsync';
import { existsSync, readFileSync } from 'fs';
import gql from 'graphql-tag';
import { TRANSFORM_CURRENT_VERSION } from 'graphql-transformer-core';
import _ from 'lodash';
import * as path from 'path';

const providerName = 'awscloudformation';

// to deal with bug in cognito-identity-js
Expand All @@ -52,14 +49,14 @@ describe('amplify add api (GraphQL)', () => {
});

it('init a project with conflict detection enabled and a schema with @key, test update mutation', async () => {
const name = 'keyconflictdetection';
const name = `keyconflictdetection`;
await initJSProjectWithProfile(projRoot, { name });
await addApiWithBlankSchemaAndConflictDetection(projRoot, { transformerVersion: 1 });
await updateApiSchema(projRoot, name, 'key-conflict-detection.graphql');
await amplifyPush(projRoot);

const meta = getProjectMeta(projRoot);
const region = meta.providers[providerName].Region as string;
const region = meta['providers'][providerName]['Region'] as string;
const { output } = meta.api[name];
const url = output.GraphQLAPIEndpointOutput as string;
const apiKey = output.GraphQLAPIKeyOutput as string;
Expand Down Expand Up @@ -137,7 +134,7 @@ describe('amplify add api (GraphQL)', () => {
});

it('init a project with conflict detection enabled and toggle disable', async () => {
const name = 'conflictdetection';
const name = `conflictdetection`;
await initJSProjectWithProfile(projRoot, { name });
await addApiWithBlankSchemaAndConflictDetection(projRoot, { transformerVersion: 1 });
await updateApiSchema(projRoot, name, 'simple_model.graphql');
Expand Down Expand Up @@ -174,7 +171,7 @@ describe('amplify add api (GraphQL)', () => {
});

it('init a project with conflict detection enabled and admin UI enabled to generate datastore models in the cloud', async () => {
const name = 'dsadminui';
const name = `dsadminui`;
await initJSProjectWithProfile(projRoot, { disableAmplifyAppCreation: false, name });

let meta = getProjectMeta(projRoot);
Expand All @@ -184,7 +181,7 @@ describe('amplify add api (GraphQL)', () => {
expect(appId).toBeDefined();

const localEnvInfo = getLocalEnvInfo(projRoot);
const { envName } = localEnvInfo;
const envName = localEnvInfo.envName;

// setupAdminUI
await enableAdminUI(appId, envName, region);
Expand All @@ -209,7 +206,7 @@ describe('amplify add api (GraphQL)', () => {
});

it('init a sync enabled project and update conflict resolution strategy', async () => {
const name = 'syncenabled';
const name = `syncenabled`;
await initJSProjectWithProfile(projRoot, { name });
await addApiWithBlankSchemaAndConflictDetection(projRoot, { transformerVersion: 1 });
await updateApiSchema(projRoot, name, 'simple_model.graphql');
Expand Down Expand Up @@ -272,7 +269,7 @@ describe('amplify add api (GraphQL)', () => {

// amplify update api to enable datastore
await apiEnableDataStore(projRoot, {});
const transformConfigWithDS = getTransformConfig(projRoot, name);
let transformConfigWithDS = getTransformConfig(projRoot, name);
expect(transformConfigWithDS).toBeDefined();
expect(transformConfigWithDS.ResolverConfig).toBeDefined();
expect(transformConfigWithDS.ResolverConfig.project).toBeDefined();
Expand Down Expand Up @@ -309,36 +306,6 @@ describe('amplify add api (GraphQL)', () => {
expect(beforeAdminConfig).not.toEqual(afterAdminConfig);
});

it('init a project and add custom iam roles - local test with gql v2 w/ identity claim feature flag disabled', async () => {
const name = 'customadminroles';
await initJSProjectWithProfile(projRoot, { name });
addFeatureFlag(projRoot, 'graphqlTransformer', 'userSubUsernameForDefaultIdentityClaim', false);
await addApi(projRoot, { transformerVersion: 2, IAM: {}, 'Amazon Cognito User Pool': {} });
updateApiSchema(projRoot, name, 'cognito_simple_model.graphql');
await apiGqlCompile(projRoot);
const createResolver = path.join(
projRoot,
'amplify',
'backend',
'api',
name,
'build',
'resolvers',
'Mutation.createTodo.auth.1.req.vtl',
);
const beforeAdminConfig = readFileSync(createResolver).toString();
expect(beforeAdminConfig).toMatchSnapshot();

const customRolesConfig = {
adminRoleNames: ['myAdminRoleName'],
};
setCustomRolesConfig(projRoot, name, customRolesConfig);
await apiGqlCompile(projRoot);
const afterAdminConfig = readFileSync(createResolver).toString();
expect(afterAdminConfig).toMatchSnapshot();
expect(beforeAdminConfig).not.toEqual(afterAdminConfig);
});

// TODO: Disabling for now until further conversation.
// it('inits a project with a simple model with deletion protection enabled and then migrates the api', async () => {
// const projectName = 'retaintables';
Expand Down Expand Up @@ -369,5 +336,3 @@ describe('amplify add api (GraphQL)', () => {
// }
// });
});

/* eslint-enable */

0 comments on commit 81519b1

Please sign in to comment.