Skip to content
This repository has been archived by the owner on Dec 31, 2021. It is now read-only.

Commit

Permalink
test - adding more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
neverendingqs committed Apr 12, 2020
1 parent 707a013 commit 1af85ca
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe('DefaultAwsProperties', function() {
this.sandbox = sinon.createSandbox();

this.serverless = {
custom: {}
custom: {},
resources: {}
};
this.defaultAwsProperties = new DefaultAwsProperties({
getProvider: this.sandbox.stub(),
Expand Down Expand Up @@ -100,4 +101,62 @@ describe('DefaultAwsProperties', function() {
});
});
});

describe('addDefaults()', function() {
it('excludes resources based on type or logical ID', function() {
const defaultProperties = {
BucketEncryption: {
ServerSideEncryptionConfiguration: [
{
ServerSideEncryptionByDefault: {
SSEAlgorithm: 'AES256'
}
}
]
},
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true
}
};

this.serverless.custom.defaultAwsProperties = [
{
Type: 'AWS::S3::Bucket',
Exclude: [
'IgnoredBucket'
],
Properties: defaultProperties
}
];

this.serverless.resources.Resources = {
IgnoredBucket: {
Type: 'AWS::S3::Bucket',
Properties: {}
},
NotABucket: {
Type: 'AWS::DynamoDB::Table',
Properties: {}
},
RegularBucket: {
Type: 'AWS::S3::Bucket',
Properties: {}
}
};

this.defaultAwsProperties.addDefaults();

this.serverless.resources.Resources.IgnoredBucket.Properties
.should.not.have.property('BucketEncryption');

this.serverless.resources.Resources.NotABucket.Properties
.should.not.have.property('BucketEncryption');

this.serverless.resources.Resources.RegularBucket.Properties
.should.deep.include(defaultProperties);
});
});
});

0 comments on commit 1af85ca

Please sign in to comment.