Permalink
Browse files

Supports letsencrypt challenges (#239)

So you can setup LetsEncrypt certificates natively
  • Loading branch information...
arunthampi authored and rauchg committed Sep 26, 2016
1 parent c3c1e8f commit a506f2fd33e6242e73e43cf1c064e4cca8437c1e
Showing with 47 additions and 0 deletions.
  1. +4 −0 lib/index.js
  2. +43 −0 test/index.js
View
@@ -180,6 +180,10 @@ export default function slackin ({
res.send(dom.toHTML())
})
app.get('/.well-known/acme-challenge/:id', (req, res) => {
res.send(process.env.LETSENCRYPT_CHALLENGE)
})
// badge js
app.use('/slackin.js', express.static(assets + '/badge.js'))
View
@@ -74,4 +74,47 @@ describe('slackin', () => {
.end(done);
});
});
describe('GET /.well-known/acme-challenge/:id', () => {
beforeEach(() => {
process.env.LETSENCRYPT_CHALLENGE = 'letsencrypt-challenge';
nock('https://myorg.slack.com')
.get('/api/users.list')
.query({token: 'mytoken', presence: '1'})
.query({token: 'mytoken'})
.reply(200, {
ok: true,
members: [{}]
});
nock('https://myorg.slack.com')
.get('/api/channels.list?token=mytoken')
.reply(200, {
ok: true,
channels: [{}]
});
nock('https://myorg.slack.com')
.get('/api/team.info?token=mytoken')
.reply(200, {
ok: true,
team: {icon: {}}
})
});
it('returns the contents of the environment variable LETSENCRYPT_CHALLENGE', (done) => {
let opts = {
token: 'mytoken',
org: 'myorg'
};
let app = slackin(opts);
request(app)
.get('/.well-known/acme-challenge/deadbeef')
.expect(200, 'letsencrypt-challenge')
.end(done);
})
});
});

0 comments on commit a506f2f

Please sign in to comment.