Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Dec 4, 2019
1 parent a45d2a2 commit f2a41bf
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/plugins/aws/invokeLocal/index.test.js
Expand Up @@ -327,18 +327,31 @@ describe('AwsInvokeLocal', () => {
expect(process.env.NODE_PATH).to.equal('/var/runtime:/var/task:/var/runtime/node_modules');
}));

it('it should set credential env vars', () => {
provider.cachedCredentials.accessKeyId = 'ID';
provider.cachedCredentials.secretAccessKey = 'SECRET';
provider.cachedCredentials.sessionToken = 'TOKEN';
it('it should set credential env vars #1', () => {
provider.cachedCredentials = {
accessKeyId: 'ID',
secretAccessKey: 'SECRET',
};

return awsInvokeLocal.loadEnvVars().then(() => {
expect(process.env.AWS_ACCESS_KEY_ID).to.equal('ID');
expect(process.env.AWS_SECRET_ACCESS_KEY).to.equal('SECRET');
expect(process.env.AWS_SESSION_TOKEN).to.equal('TOKEN');
expect('AWS_SESSION_TOKEN' in process.env).to.equal(false);
});
});

it('it should set credential env vars #2', () => {
provider.cachedCredentials = { sessionToken: 'TOKEN' };
return awsInvokeLocal
.loadEnvVars()

.then(() => {
expect(process.env.AWS_SESSION_TOKEN).to.equal('TOKEN');
expect('AWS_ACCESS_KEY_ID' in process.env).to.equal(false);
expect('AWS_SECRET_ACCESS_KEY' in process.env).to.equal(false);
});
});

it('should fallback to service provider configuration when options are not available', () => {
awsInvokeLocal.provider.options.region = null;
awsInvokeLocal.serverless.service.provider.region = 'us-west-1';
Expand Down

0 comments on commit f2a41bf

Please sign in to comment.