-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from HyperBrain/support-custom-authorizers
Set authorizer name and Uri
- Loading branch information
Showing
2 changed files
with
105 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
/** | ||
* Unit tests for initialization. | ||
*/ | ||
|
||
const getInstalledPath = require('get-installed-path'); | ||
const BbPromise = require('bluebird'); | ||
const chai = require('chai'); | ||
const sinon = require('sinon'); | ||
const AWSAlias = require('../../index'); | ||
|
||
const serverlessPath = getInstalledPath.sync('serverless', { local: true }); | ||
const AwsProvider = require(`${serverlessPath}/lib/plugins/aws/provider/awsProvider`); | ||
const Serverless = require(`${serverlessPath}/lib/Serverless`); | ||
|
||
chai.use(require('chai-as-promised')); | ||
chai.use(require('sinon-chai')); | ||
const expect = chai.expect; | ||
|
||
describe('SNS Events', () => { | ||
let serverless; | ||
let options; | ||
let awsAlias; | ||
// Sinon and stubs for SLS CF access | ||
let sandbox; | ||
let logStub; | ||
|
||
before(() => { | ||
sandbox = sinon.sandbox.create(); | ||
}); | ||
|
||
beforeEach(() => { | ||
options = { | ||
alias: 'myAlias', | ||
stage: 'myStage', | ||
region: 'us-east-1', | ||
}; | ||
serverless = new Serverless(options); | ||
serverless.setProvider('aws', new AwsProvider(serverless)); | ||
serverless.cli = new serverless.classes.CLI(serverless); | ||
serverless.service.service = 'testService'; | ||
serverless.service.provider.compiledCloudFormationAliasTemplate = {}; | ||
awsAlias = new AWSAlias(serverless, options); | ||
|
||
// Disable logging | ||
logStub = sandbox.stub(serverless.cli, 'log'); | ||
logStub.returns(); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('#aliasInit()', () => { | ||
it('should set alias flags', () => { | ||
serverless.service.provider.compiledCloudFormationTemplate = require('../data/sls-stack-1.json'); | ||
const aliasStack = serverless.service.provider.compiledCloudFormationAliasTemplate = require('../data/alias-stack-1.json'); | ||
return expect(awsAlias.aliasInit({}, [], {})).to.be.fulfilled | ||
.then(() => BbPromise.all([ | ||
expect(aliasStack).to.have.property('Outputs') | ||
.that.has.property('AliasFlags') | ||
.that.deep.equals({ | ||
Description: 'Alias flags.', | ||
Value: { hasRole: false } | ||
}) | ||
])); | ||
}); | ||
}); | ||
}); |