Skip to content

Commit 9505ba1

Browse files
author
Vieltojarvi
committed
e2e tests
1 parent 725ef86 commit 9505ba1

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

packages/integration-tests/src/test-project-setup/seed_test_project.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ import { AmplifyAuthCredentialsFactory } from '../amplify_auth_credentials_facto
2727
import { execa, execaSync } from 'execa';
2828
import { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts';
2929
import { shortUuid } from '../short_uuid.js';
30+
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam';
31+
import { SemVer } from 'semver';
32+
33+
// TODO: this is a work around - in theory this should be fixed
34+
// it seems like as of amplify v6 , some of the code only runs in the browser ...
35+
// see https://github.com/aws-amplify/amplify-js/issues/12751
36+
if (process.versions.node) {
37+
// node >= 20 now exposes crypto by default. This workaround is not needed: https://github.com/nodejs/node/pull/42083
38+
if (new SemVer(process.versions.node).major < 20) {
39+
// @ts-expect-error altering typing for global to make compiler happy is not worth the effort assuming this is temporary workaround
40+
globalThis.crypto = crypto;
41+
}
42+
}
3043

3144
/**
3245
* Creates test project for seed
@@ -127,7 +140,7 @@ class SeedTestProject extends TestProjectBase {
127140
env: environment,
128141
}
129142
);
130-
await this.attachToRole(seedPolicyProcess.stdout, backendIdentifier);
143+
//await this.attachToRole(seedPolicyProcess.stdout, backendIdentifier);
131144

132145
console.log(seedPolicyProcess.stdout);
133146
const clientConfig = await generateClientConfig(backendIdentifier, '1.3');
@@ -140,6 +153,14 @@ class SeedTestProject extends TestProjectBase {
140153
new AssumeRoleCommand({
141154
RoleArn: seedRoleArn,
142155
RoleSessionName: `seedSession`,
156+
Policy: seedPolicyProcess.stdout,
157+
PolicyArns: [
158+
{
159+
arn: ManagedPolicy.fromAwsManagedPolicyName(
160+
'service-role/AmplifyBackendDeployFullAccess'
161+
).managedPolicyArn,
162+
},
163+
],
143164
})
144165
);
145166

packages/integration-tests/src/test-projects/seed-test-project/amplify/backend.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineBackend } from '@aws-amplify/backend';
22
import { auth } from './auth/resource.js';
33
import { data } from './data/resource.js';
4-
import { AccountPrincipal, ManagedPolicy, Role } from 'aws-cdk-lib/aws-iam';
4+
import { AccountPrincipal, Role } from 'aws-cdk-lib/aws-iam';
55
import { RemovalPolicy } from 'aws-cdk-lib';
66

77
/**
@@ -18,11 +18,6 @@ const seedRoleStack = backend.createStack('seed-policy');
1818
const seedRole = new Role(seedRoleStack, 'SeedRole', {
1919
assumedBy: new AccountPrincipal(seedRoleStack.account),
2020
path: '/',
21-
managedPolicies: [
22-
ManagedPolicy.fromAwsManagedPolicyName(
23-
'service-role/AmplifyBackendDeployFullAccess'
24-
),
25-
],
2621
});
2722
seedRole.applyRemovalPolicy(RemovalPolicy.DESTROY);
2823

0 commit comments

Comments
 (0)