Skip to content

Commit

Permalink
Supports letsencrypt challenges (rauchg#239)
Browse files Browse the repository at this point in the history
So you can setup LetsEncrypt certificates natively
  • Loading branch information
arunthampi authored and rauchg committed Sep 26, 2016
1 parent c3c1e8f commit a506f2f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down
43 changes: 43 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.