-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
116 additions
and
62 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
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 |
---|---|---|
|
@@ -15,14 +15,22 @@ const port = process.env.PORT || 8000; | |
const secret = process.env.README_API_KEY; | ||
|
||
app.use((req, res, next) => { | ||
readme.log(process.env.README_API_KEY, req, res, { | ||
// User's API Key | ||
apiKey: 'owlbert-api-key', | ||
// Username to show in the dashboard | ||
label: 'Owlbert', | ||
// User's email address | ||
email: '[email protected]', | ||
}); | ||
readme.log( | ||
process.env.README_API_KEY, | ||
req, | ||
res, | ||
{ | ||
// User's API Key | ||
apiKey: 'owlbert-api-key', | ||
// Username to show in the dashboard | ||
label: 'Owlbert', | ||
// User's email address | ||
email: '[email protected]', | ||
}, | ||
{ | ||
denylist: ['secretKey'], | ||
} | ||
); | ||
|
||
return next(); | ||
}); | ||
|
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 |
---|---|---|
|
@@ -350,6 +350,35 @@ describe('Metrics SDK Integration Tests', function () { | |
expect(response.status).to.equal(200); | ||
}); | ||
|
||
it('should respect denyLIst', async function () { | ||
const content = JSON.stringify({ secretKey: 'mySecretKey', user: { email: '[email protected]' } }); | ||
await fetch(`http://localhost:${PORT}/`, { | ||
method: 'post', | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: content, | ||
}); | ||
|
||
const [, body] = await getRequest(); | ||
const [payload] = body; | ||
|
||
const har = payload.request; | ||
await expect(har).to.have.a.har.request; | ||
await expect(har).to.have.a.har.response; | ||
|
||
const { request, response } = har.log.entries[0]; | ||
|
||
expect(request.method).to.equal('POST'); | ||
expect(request.headers).to.have.header('content-type', 'application/json'); | ||
expect(request.postData).to.deep.equal({ | ||
mimeType: 'application/json', | ||
text: JSON.stringify({ secretKey: '[REDACTED 11]', user: { email: '[email protected]' } }), | ||
}); | ||
|
||
expect(response.status).to.equal(200); | ||
}); | ||
|
||
/** | ||
* We should eventually support returning the raw POST payload to Metrics in this case but Express | ||
* has a fun quirk where if you declare the `express.json()` middleware on a route to identify | ||
|
@@ -398,6 +427,7 @@ describe('Metrics SDK Integration Tests', function () { | |
it('should process an `application/x-www-url-formencoded` POST payload', async function () { | ||
const params = new URLSearchParams(); | ||
params.append('email', '[email protected]'); | ||
params.append('secretKey', 'helloWorld'); | ||
|
||
await fetch(`http://localhost:${PORT}/`, { | ||
method: 'post', | ||
|
@@ -420,7 +450,10 @@ describe('Metrics SDK Integration Tests', function () { | |
expect(request.headers).to.have.header('content-type', 'application/x-www-form-urlencoded'); | ||
expect(request.postData).to.deep.equal({ | ||
mimeType: 'application/x-www-form-urlencoded', | ||
params: [{ name: 'email', value: '[email protected]' }], | ||
params: [ | ||
{ name: 'email', value: '[email protected]' }, | ||
{ name: 'secretKey', value: '[REDACTED 10]' }, | ||
], | ||
}); | ||
|
||
expect(response.status).to.be.oneOf([ | ||
|