Skip to content

Commit 287bf9b

Browse files
author
Dan Skinner
committed
add integrity e2e test
1 parent 784cdf6 commit 287bf9b

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
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: true,
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+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature: Integrity header
2+
3+
Scenario: Integrity headers are set when setPayloadChecksums is true
4+
Given I navigate to the test URL "/docs/integrity"
5+
And I wait to receive a sampling request
6+
Then I click the element "send-span"
7+
And I wait for 1 span
8+
9+
Then the sampling request "bugsnag-integrity" header matches the regex "^sha1 (\d|[abcdef]){40}$"
10+
Then the trace "bugsnag-integrity" header matches the regex "^sha1 (\d|[abcdef]){40}$"

test/browser/features/support/maze-config.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ def get_test_url()
1616
maze_address = "#{host}:9339"
1717
end
1818

19-
if Maze.config.https
20-
protocol = 'https'
21-
else
22-
protocol = 'http'
23-
end
19+
protocol = Maze.config.https ? 'https' : 'http'
2420

2521
UrlGenerator.new(
2622
URI("#{protocol}://#{maze_address}"),

0 commit comments

Comments
 (0)