-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from Financial-Times/check-request-header-type
Check the type for request headers passed via config
- Loading branch information
Showing
10 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const NTestError = require('./n-test-error'); | ||
const NTestConfigError = require('./n-test-config-error'); | ||
|
||
module.exports = { | ||
NTestError, | ||
NTestConfigError, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const NTestError = require('./n-test-error'); | ||
|
||
class NTestConfigError extends NTestError { | ||
|
||
constructor (...params) { | ||
super(...params); | ||
|
||
this.name = this.constructor.name; | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, NTestConfigError); | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports = NTestConfigError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class NTestError extends Error { | ||
|
||
constructor (...params) { | ||
super(...params); | ||
|
||
this.name = this.constructor.name; | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, NTestError); | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports = NTestError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = [ | ||
{ | ||
// All valid headers | ||
headers: { | ||
'ft-valid-header-number': 1, | ||
'ft-valid-header-string': 'some-string', | ||
}, | ||
urls: { | ||
'/status?1': 200 | ||
} | ||
}, | ||
{ | ||
// Contains an invalid header (undefined) | ||
headers: { | ||
'ft-valid-header-number': 1, | ||
'ft-valid-header-string': 'some-string', | ||
'ft-invalid-header-undefined': process.env.UNDEFINED_HEADER_VARIABLE, | ||
}, | ||
urls: { | ||
'/status?2': 200 | ||
} | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = [ | ||
{ | ||
headers: { | ||
'ft-valid-header-number': 1, | ||
'ft-valid-header-string': 'some-string', | ||
}, | ||
urls: { | ||
'/status/200?1': 200, | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters