Skip to content

Commit

Permalink
Add failing test for noAuth option
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrowan committed Oct 18, 2018
1 parent e5a37df commit 018497d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/integration/offline.js
Expand Up @@ -95,6 +95,53 @@ describe('Offline', () => {

});

context('with private function and noAuth option set', () => {
let offline;
const validToken = 'valid-token'

before(done => {
offline = new OfflineBuilder(new ServerlessBuilder(), { apiKey: validToken, noAuth: true }).addFunctionConfig('fn2', {
handler: 'handler.basicAuthentication',
events: [{
http: {
path: 'fn3',
method: 'GET',
private: true,
},
}],
}, (event, context, cb) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Private Function Executed Correctly',
}),
};
cb(null, response);
}).addApiKeys(['token']).toObject();
done();
});

it('should execute the function correctly if no API key is provided', done => {
offline.inject({
method: 'GET',
url: '/fn3',
}, res => {
expect(res.statusCode).to.eq(200);
done();
});
});

it('should execute the function correctly if API key is provided', done => {
offline.inject({
method: 'GET',
url: '/fn3',
}, res => {
expect(res.statusCode).to.eq(200);
done();
});
});
});

context('lambda integration', () => {
it('should use event defined response template and headers', done => {
const offline = new OfflineBuilder().addFunctionConfig('index', {
Expand Down

0 comments on commit 018497d

Please sign in to comment.