Skip to content

Commit

Permalink
Fix tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshbrown committed Jun 7, 2017
1 parent c1c5fbb commit 0b70d32
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,34 @@ var baseCat = require('./base-cat.json');

var PORT = process.env.PORT || 8080;

var HTTPS_SECRETS = JSON.parse(fs.readFileSync("/run/secrets/DATABOX_ARBITER_PEM.json") || {});
var credentials = {
key: HTTPS_SECRETS.clientprivate || '',
cert: HTTPS_SECRETS.clientcert || '',
};

var CM_KEY = fs.readFileSync("/run/secrets/CM_KEY",{encoding:'base64'});
let CM_KEY = '';
let HTTPS_SECRETS = '';
let LOGSTORE_KEY = '';
let EXPORT_SERVICE_KEY = ''
let credentials = {};

try {
//const ARBITER_KEY = process.env.ARBITER_TOKEN;
CM_KEY = fs.readFileSync("/run/secrets/CM_KEY",{encoding:'base64'});
LOGSTORE_KEY = fs.readFileSync("/run/secrets/DATABOX_LOGSTORE_KEY",{encoding:'base64'});
EXPORT_SERVICE_KEY = fs.readFileSync("/run/secrets/DATABOX_EXPORT_SERVICE_KEY",{encoding:'base64'});

//HTTPS certs created by the container mangers for this components HTTPS server.
HTTPS_SECRETS = JSON.parse( fs.readFileSync("/run/secrets/DATABOX_ARBITER_PEM.json") );
credentials = {
key: HTTPS_SECRETS.clientprivate || '',
cert: HTTPS_SECRETS.clientcert || '',
};
} catch (e) {
//secrets missing ;-(
console.log("secrets missing ;-(",e);
CM_KEY = process.env.CM_KEY || ''; //make the tests work
HTTPS_SECRETS = '';
LOGSTORE_KEY = '';
EXPORT_SERVICE_KEY = ''
credentials = {};
}

var LOGSTORE_KEY = fs.readFileSync("/run/secrets/DATABOX_LOGSTORE_KEY",{encoding:'base64'});
var EXPORT_SERVICE_KEY = fs.readFileSync("/run/secrets/DATABOX_EXPORT_SERVICE_KEY",{encoding:'base64'});
var containers = {};

//register the databox platform components
Expand Down Expand Up @@ -355,6 +373,7 @@ app.get('/store/secret', function (req, res) {
});
});

console.log("starting server",credentials);
https.createServer(credentials, app).listen(PORT);

module.exports = app;

0 comments on commit 0b70d32

Please sign in to comment.