Permalink
Browse files
Supports letsencrypt challenges (#239)
So you can setup LetsEncrypt certificates natively
- Loading branch information...
Showing
with
47 additions
and
0 deletions.
-
+4
−0
lib/index.js
-
+43
−0
test/index.js
|
|
@@ -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'))
|
|
|
|
|
|
|
|
|
@@ -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