Skip to content

Commit

Permalink
make base url configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed Dec 19, 2017
1 parent 7e4837a commit cd6c26a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ module.exports = {
server: {
secret: process.env.SERVER_SECRET || '*',
port: process.env.SERVER_PORT || 3006
},
insights: {
url: process.env.INSIGHTS_URL || 'https://access.redhat.com/insightsbeta'
}
};
6 changes: 3 additions & 3 deletions app/events/events.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('Events', function () {
};

const result = events['report:new'](msg);
result.should.equal(':exclamation: <https://access.redhat.com/insights/inventory?machine=dd18ed75-44f5-4fd1-8ca0-ed08c2d9c320|rhelbox>' +
': new high severity security problem: <https://access.redhat.com/insights/actions/security/heartbleed%7Cheartbleed|Heartbleed>');
result.should.equal(':exclamation: <https://access.redhat.com/insightsbeta/inventory?machine=dd18ed75-44f5-4fd1-8ca0-ed08c2d9c320|rhelbox>' +
': new high severity security problem: <https://access.redhat.com/insightsbeta/actions/security/heartbleed%7Cheartbleed|Heartbleed>');
});
});

Expand All @@ -48,7 +48,7 @@ describe('Events', function () {
};

const result = events['system:registered'](msg);
result.should.equal('System registered: <https://access.redhat.com/insights/inventory?machine=dd18ed75-44f5-4fd1-8ca0-ed08c2d9c320|jozef_vm04>' +
result.should.equal('System registered: <https://access.redhat.com/insightsbeta/inventory?machine=dd18ed75-44f5-4fd1-8ca0-ed08c2d9c320|jozef_vm04>' +
' (dd18ed75-44f5-4fd1-8ca0-ed08c2d9c320)');
});
});
Expand Down
7 changes: 5 additions & 2 deletions app/events/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

const config = require('../config');
const baseUrl = config.insights.url;

const SEVERITIES = {
INFO: 'low severity',
WARN: 'medium severity',
Expand Down Expand Up @@ -27,11 +30,11 @@ function getProblemDescription (msg) {
}

function systemLink (system) {
return `<https://access.redhat.com/insights/inventory?machine=${system.system_id}|${system.toString}>`;
return `<${baseUrl}/inventory?machine=${system.system_id}|${system.toString}>`;
}

function ruleLink (rule) {
return `<https://access.redhat.com/insights/actions/${rule.category.toLowerCase()}/${encodeURIComponent(rule.rule_id)}|${rule.description}>`;
return `<${baseUrl}/actions/${rule.category.toLowerCase()}/${encodeURIComponent(rule.rule_id)}|${rule.description}>`;
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js app server.js",
"nsp": "./node_modules/nsp/bin/nsp check",
"test": "./node_modules/mocha/bin/mocha '**/*.unit.js'",
"test": "SLACK_TOKEN=xoxb123 ./node_modules/mocha/bin/mocha '**/*.unit.js'",
"verify": "npm run lint && npm test && npm run nsp"
},
"pre-push": [
Expand Down

0 comments on commit cd6c26a

Please sign in to comment.