Skip to content

Commit 6509be3

Browse files
Dan Skinnergingerbenw
authored andcommitted
add test for integrity disabled
1 parent cc375a0 commit 6509be3

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<link href="/favicon.png" rel="shortcut icon" type="image/x-icon">
6+
<script src="./dist/bundle.js" type="module"></script>
7+
<title>Integrity header</title>
8+
</head>
9+
<body>
10+
<h1>integrity-header</h1>
11+
<button id="send-span">send-span</button>
12+
</body>
13+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "integrity",
3+
"private": true,
4+
"scripts": {
5+
"build": "rollup --config ../rollup.config.mjs",
6+
"clean": "rm -rf dist"
7+
}
8+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import BugsnagPerformance from '@bugsnag/browser-performance'
2+
3+
const parameters = new URLSearchParams(window.location.search)
4+
const apiKey = parameters.get('api_key')
5+
const endpoint = parameters.get('endpoint')
6+
7+
BugsnagPerformance.start({
8+
apiKey,
9+
endpoint,
10+
sendPayloadChecksums: false,
11+
maximumBatchSize: 1,
12+
autoInstrumentFullPageLoads: false,
13+
autoInstrumentNetworkRequests: false,
14+
autoInstrumentRouteChanges: false,
15+
serviceName: 'integrity'
16+
})
17+
18+
document.getElementById('send-span').onclick = () => {
19+
const spanOptions = {}
20+
21+
if (parameters.has('isFirstClass')) {
22+
spanOptions.isFirstClass = JSON.parse(parameters.get('isFirstClass'))
23+
}
24+
25+
const span = BugsnagPerformance.startSpan("Custom/ManualSpanScenario", spanOptions)
26+
span.end()
27+
}
28+

test/browser/features/integrity.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ Scenario: Integrity headers are set when setPayloadChecksums is true
88

99
Then the sampling request "bugsnag-integrity" header matches the regex "^sha1 (\d|[abcdef]){40}$"
1010
Then the trace "bugsnag-integrity" header matches the regex "^sha1 (\d|[abcdef]){40}$"
11+
12+
Scenario: Integrity headers are not set when setPayloadChecksums is false
13+
Given I navigate to the test URL "/docs/integrity-disabled"
14+
And I wait to receive a sampling request
15+
Then I click the element "send-span"
16+
And I wait for 1 span
17+
18+
Then the sampling request "bugsnag-integrity" header is not present
19+
Then the trace "bugsnag-integrity" header is not present

0 commit comments

Comments
 (0)