Skip to content

Commit

Permalink
Merge pull request #201 from Financial-Times/modify-heroku-log-drain-…
Browse files Browse the repository at this point in the history
…sourcetype-param-check

Modify Heroku log drain check to ensure absence of sourcetype param
  • Loading branch information
andygout authored Aug 9, 2022
2 parents 0643506 + 0292891 commit 0e7ca43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/checks/herokuLogDrain.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class HerokuLogDrainCheck extends Check {
throw new Error('log drain source parameter is not set to the application system code');
}

if (parsedUrl.searchParams.get('sourcetype') !== 'heroku') {
throw new Error('log drain sourcetype parameter is not set to "heroku"');
if (parsedUrl.searchParams.get('sourcetype')) {
throw new Error('log drain sourcetype parameter is present; sourcetype should instead be specified on the HEC (HTTP Event Collector) token');
}

if (!parsedUrl.searchParams.get('host')) {
Expand Down
16 changes: 8 additions & 8 deletions test/herokuLogDrain.check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mockValidResponse = {
ok: true,
json: sinon.stub().resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=heroku&source=mock-system-code&host=mock-host&channel=mock-channel'
url: 'https://x:[email protected]/services/collector/raw?source=mock-system-code&host=mock-host&channel=mock-channel'
}
])
};
Expand Down Expand Up @@ -194,7 +194,7 @@ describe.only('Heroku Log Drain Check', () => {
beforeEach(done => {
mockValidResponse.json.resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=heroku&host=mock-host&channel=mock-channel'
url: 'https://x:[email protected]/services/collector/raw?host=mock-host&channel=mock-channel'
}
]);
check.start();
Expand All @@ -214,7 +214,7 @@ describe.only('Heroku Log Drain Check', () => {
beforeEach(done => {
mockValidResponse.json.resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=heroku&source=invalid&host=mock-host&channel=mock-channel'
url: 'https://x:[email protected]/services/collector/raw?source=invalid&host=mock-host&channel=mock-channel'
}
]);
check.start();
Expand All @@ -229,12 +229,12 @@ describe.only('Heroku Log Drain Check', () => {

});

describe('when the app log drain has an invalid sourcetype query parameter', () => {
describe('when the app log drain has a sourcetype query parameter (sourcetype should instead be specified on the HEC (HTTP Event Collector) token)', () => {

beforeEach(done => {
mockValidResponse.json.resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=invalid&source=mock-system-code&host=mock-host&channel=mock-channel'
url: 'https://x:[email protected]/services/collector/raw?sourcetype=mock-sourcetype&source=mock-system-code&host=mock-host&channel=mock-channel'
}
]);
check.start();
Expand All @@ -243,7 +243,7 @@ describe.only('Heroku Log Drain Check', () => {

it('it sets the check properties to indicate failure', () => {
const status = check.getStatus();
expect(status.checkOutput).to.equal('Heroku log drains are misconfigured: log drain sourcetype parameter is not set to "heroku"');
expect(status.checkOutput).to.equal('Heroku log drains are misconfigured: log drain sourcetype parameter is present; sourcetype should instead be specified on the HEC (HTTP Event Collector) token');
expect(status.ok).to.be.false;
});

Expand All @@ -254,7 +254,7 @@ describe.only('Heroku Log Drain Check', () => {
beforeEach(done => {
mockValidResponse.json.resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=heroku&source=mock-system-code&channel=mock-channel'
url: 'https://x:[email protected]/services/collector/raw?source=mock-system-code&channel=mock-channel'
}
]);
check.start();
Expand All @@ -274,7 +274,7 @@ describe.only('Heroku Log Drain Check', () => {
beforeEach(done => {
mockValidResponse.json.resolves([
{
url: 'https://x:[email protected]/services/collector/raw?sourcetype=heroku&source=mock-system-code&host=mock-host'
url: 'https://x:[email protected]/services/collector/raw?source=mock-system-code&host=mock-host'
}
]);
check.start();
Expand Down

0 comments on commit 0e7ca43

Please sign in to comment.