Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

apiserver over https

  • Loading branch information...
commit e436587183d7d77330f54eea8e4433317a2a9c01 1 parent f3d5cfe
Romain Filirom1 authored
2  Makefile
View
@@ -8,5 +8,3 @@ certs:
openssl genrsa -out certs/server-key.pem 1024
openssl req -new -key certs/server-key.pem -out certs/server-csr.pem
openssl x509 -req -in certs/server-csr.pem -signkey certs/server-key.pem -out certs/server-cert.pem
-
-
10 apiserver/apiserver.js
View
@@ -1,11 +1,15 @@
var express = require('./customexpress');
var apiglue = require('./apiglue');
var fs = require('fs');
-var path = require('path');
+var Path = require('path');
module.exports.createServer = function(opts) {
+ var tls = {
+ key: fs.readFileSync(Path.join(__dirname, '../certs/server-key.pem')),
+ cert: fs.readFileSync(Path.join(__dirname, '../certs/server-cert.pem'))
+ };
- var app = express.createServer();
+ var app = express.createServer(tls);
app.configure(function() {
app.use(express.bodyParser());
@@ -59,7 +63,7 @@ module.exports.createServer = function(opts) {
module.exports.getApiLets = getApiLets;
function getApiLets() {
- var apiLetsPath = path.join(__dirname, 'api');
+ var apiLetsPath = Path.join(__dirname, 'api');
var files = fs.readdirSync(apiLetsPath);
var requireFiles = files.map(function(file) {
return file.substring(0, file.length - 3);
2  apiserver/conf.js
View
@@ -23,7 +23,7 @@ module.exports = {
}
},
apiserver: {
- protocol: env.APISERVER_PROTOCOL || 'http',
+ protocol: env.APISERVER_PROTOCOL || 'https',
hostname: env.APISERVER_HOST || 'localhost',
port: env.APISERVER_PORT || 5000,
rendezvous: {
4 test/apps.js
View
@@ -22,7 +22,7 @@ describe('Apps API', function(){
beforeEach(common.cleanDB);
beforeEach(common.addUser);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
describe('without apps', function(){
it('list apps should return nothing', function(done){
@@ -147,7 +147,7 @@ describe('Apps API', function(){
});
it('should return one app when listing apps as friendd', function(done){
- var base = 'http://:' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + '@localhost:5000';
+ var base = 'https://:' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + '@localhost:5000';
request({
url: base + '/apps'
}, function(err, res, body){
8 test/authentication.js
View
@@ -11,7 +11,7 @@ describe('Authentication', function(){
beforeEach(common.cleanDB);
describe('without user', function(){
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should not be authorized to access /apps', function(done){
request({
url: base + '/apps',
@@ -28,7 +28,7 @@ describe('Authentication', function(){
beforeEach(common.addUser);
describe('without key', function(){
- var base = 'http://localhost:5000';
+ var base = 'https://localhost:5000';
it('should not be authorized to access /apps', function(done){
request({
url: base + '/apps',
@@ -42,7 +42,7 @@ describe('Authentication', function(){
});
describe('with a wrong key', function(){
- var base = 'http://:blablabla@localhost:5000';
+ var base = 'https://:blablabla@localhost:5000';
it('should not be authorized to access /apps', function(done){
request({
url: base + '/apps',
@@ -56,7 +56,7 @@ describe('Authentication', function(){
});
describe('with a valid key', function(){
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should be authorized to access /apps', function(done){
request({
url: base + '/apps',
2  test/common.js
View
@@ -41,7 +41,7 @@ exports.cleanDB = function(cb){
app.db.exec('clean', null, cb);
};
-var base = 'http://:' + exports.defaultUser.apiKey + '@localhost:5000';
+var base = 'https://:' + exports.defaultUser.apiKey + '@localhost:5000';
exports.addApp = function(cb){
request.post({
url: base + '/apps',
2  test/config.js
View
@@ -12,7 +12,7 @@ describe('config API', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should return empty when listing config', function(done){
request({
2  test/domains.js
View
@@ -12,7 +12,7 @@ describe('domains API', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should return empty when listing domains', function(done){
request({
2  test/internal-lookupUserByPublicKey.js
View
@@ -7,7 +7,7 @@ var common = require('./common');
var gitmouthMock = require('./mock/gitmouth');
before(common.startServer);
-var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
describe('internal lookupUserByPublicKey', function(){
beforeEach(common.cleanDB);
2  test/internal-provisionJob.js
View
@@ -59,7 +59,7 @@ describe('internal provisionJob', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
describe('without a commit', function(){
describe('when restarting an app', function(){
2  test/keys.js
View
@@ -12,7 +12,7 @@ describe('keys API', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
var sshKey = common.defaultKey.sshKey;
it('should return empty when listing keys', function(done){
2  test/mock/codonhooks.js
View
@@ -1,6 +1,6 @@
var request = require('request');
var common = require('../common');
-var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
exports.preReceive = function(appName, pstable, cb){
if(typeof pstable === 'function'){
2  test/mock/dynohost.js
View
@@ -1,7 +1,7 @@
var request = require('request');
var common = require('../common');
-var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
exports.updateState = function(appId, dynoId, instanceId, state, cb){
request.post({
4 test/mock/gitmouth.js
View
@@ -2,14 +2,14 @@ var request = require('request');
var common = require('../common');
exports.handleGitCommand = function(appName, cb){
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
request.post({
url: base + '/internal/' + appName + '/gitaction?command=git-receive-pack'
}, cb);
};
exports.lookupUserByPublicKey = function(fingerprint, cb){
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
request({
url: base + '/internal/lookupUserByPublicKey?fingerprint=' + fingerprint
}, cb);
2  test/ps.js
View
@@ -14,7 +14,7 @@ describe('ps API', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should return empty when listing processes', function(done){
request({
2  test/releases.js
View
@@ -26,7 +26,7 @@ describe('releases API', function(){
beforeEach(common.addUser);
beforeEach(common.addApp);
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should return releases list', function(done){
request({
2  test/sharing.js
View
@@ -20,7 +20,7 @@ describe('collaborators API', function(){
}, done);
});
- var base = 'http://:' + common.defaultUser.apiKey + '@localhost:5000';
+ var base = 'https://:' + common.defaultUser.apiKey + '@localhost:5000';
it('should only return me when listing collaborators', function(done){
request({
Please sign in to comment.
Something went wrong with that request. Please try again.