Skip to content

Commit

Permalink
Remove obsolete test and other cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zakwalters committed Mar 25, 2020
1 parent b038bb1 commit ea625aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 62 deletions.
5 changes: 2 additions & 3 deletions packages/@aws-cdk/aws-iam/test/policy-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ describe('IAM polocy document', () => {

// add via policy statement
statement.addArnPrincipal('aws-principal-3');
statement.addCondition('cond2', { boom: "123" });
statement.addCondition('cond2', { boom: '123' });

expect(stack.resolve(statement.toStatementJson())).toEqual({
Condition: {
cond2: { boom: "123" }
cond2: { boom: '123' }
},
Effect: 'Allow',
Principal: {
Expand All @@ -475,7 +475,6 @@ describe('IAM polocy document', () => {

describe('PrincipalWithConditions can be used to add a principal with conditions', () => {
test('includes conditions from both the wrapped principal and the wrapper', () => {
// TODO: quote style
const stack = new Stack();
const principalOpts = {
conditions: {
Expand Down
61 changes: 2 additions & 59 deletions packages/@aws-cdk/aws-iam/test/principals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,63 +46,6 @@ test('use of cross-stack role reference does not lead to URLSuffix being exporte
}
}
}
});
}
);
});

// TODO: may well belong in policy-document.test.ts
test('can create principal with conditions', () => {
// GIVEN
const accountId = '012345678910';
const app = new App();
const stack = new Stack(app, 'Stack');

// WHEN
const conditions = {
StringEquals: {
"s3:x-amz-acl": [
"public-read"
]
}
};
const principal = new iam.AccountPrincipal(accountId).withConditions(conditions);
new iam.Role(stack, 'Role', {
assumedBy: principal,
});

// THEN
app.synth();

expect(stack).toMatchTemplate({
Resources: {
Role1ABCC5F0: { // how is this name set? Seems to be used a lot of places so I guess it's the one that'll be generated...
Type: "AWS::IAM::Role",
Properties: {
AssumeRolePolicyDocument: {
Statement: [
{
Action: "sts:AssumeRole",
Condition: {
StringEquals: {
"s3:x-amz-acl": [
"public-read"
]
}
},
Effect: "Allow",
Principal: {
AWS: {
'Fn::Join': [
'',
[ 'arn:', { Ref: 'AWS::Partition' }, `:iam::${accountId}:root` ]
]
}
},
}
],
Version: "2012-10-17"
}
}
}
}
});
});

0 comments on commit ea625aa

Please sign in to comment.