Skip to content

Commit

Permalink
add sensitive data
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Sep 27, 2024
1 parent 8ab3d4d commit 9e5ebfc
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions packages/signals/signals/src/core/client/__tests__/redact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createInstrumentationSignal,
createInteractionSignal,
createNetworkSignal,
NetworkSignalMetadata,
} from '../../../types'
import { redactJsonValues, redactSignalData } from '../redact'

Expand Down Expand Up @@ -61,6 +62,12 @@ describe(redactJsonValues, () => {
})

describe(redactSignalData, () => {
const metadataFixture: NetworkSignalMetadata = {
filters: {
allowed: [],
disallowed: [],
},
}
it('should return the signal as is if the type is "instrumentation"', () => {
const signal = createInstrumentationSignal({
foo: 123,
Expand All @@ -86,18 +93,24 @@ describe(redactSignalData, () => {
})

it('should redact the values in the "data" property if the type is "network"', () => {
const signal = createNetworkSignal({
action: 'Request',
method: 'post',
url: 'http://foo.com',
data: { name: 'John Doe', age: 30 },
})
const expected = createNetworkSignal({
action: 'Request',
method: 'post',
url: 'http://foo.com',
data: { name: 'XXX', age: 999 },
})
const signal = createNetworkSignal(
{
action: 'request',
method: 'post',
url: 'http://foo.com',
data: { name: 'John Doe', age: 30 },
},
metadataFixture
)
const expected = createNetworkSignal(
{
action: 'request',
method: 'post',
url: 'http://foo.com',
data: { name: 'XXX', age: 999 },
},
metadataFixture
)
expect(redactSignalData(signal)).toEqual(expected)
})

Expand Down

0 comments on commit 9e5ebfc

Please sign in to comment.