Skip to content
Snippets Groups Projects
Commit a66ed941 authored by Marcos Defendi's avatar Marcos Defendi
Browse files

Added endpoint to get the list of available oauth services

parent 6571b8f9
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,26 @@ RocketChat.API.v1.addRoute('info', { authRequired: false }, {
}
});
RocketChat.API.v1.addRoute('oAuthServices', { authRequired: false }, {
get() {
const mountOAuthServices = () => {
const oAuthServicesEnabled = ServiceConfiguration.configurations.find({}).fetch();
return oAuthServicesEnabled.map((service) => {
return {
id: service._id,
name: service.service,
appId: service.appId || service.clientId
}
})
};
return RocketChat.API.v1.success({
services: mountOAuthServices()
});
}
});
RocketChat.API.v1.addRoute('me', { authRequired: true }, {
get() {
const me = _.pick(this.user, [
......
......@@ -70,4 +70,30 @@ describe('miscellaneous', function() {
})
.end(done);
});
describe('/oAuthServices', () => {
it('should have return list of available oauth services when user is not logged', (done) => {
request.get(api('oAuthServices'))
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});
it('should have return list of available oauth services when user is logged', (done) => {
request.get(api('oAuthServices'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment