Skip to content

Commit 77c8171

Browse files
committed
test: handle multi-os user-agent strings in ci tests
1 parent 31b6898 commit 77c8171

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

test/modes/authenticated.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const mockArtifact: SocketArtifact = {
5757
headers: {
5858
'Content-Type': 'application/json',
5959
'Authorization': `Bearer ${apiKey}`,
60-
'User-Agent': 'SocketBunSecurityScanner/0.1.0 (linux x64) Bun/1.2.23'
60+
'User-Agent': expect.stringContaining('SocketBunSecurityScanner')
6161
},
6262
body: JSON.stringify({
6363
components: [{ purl: 'pkg:npm/[email protected]' }]

test/modes/unauthenticated.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ describe('unauthenticated', () => {
4848
}
4949

5050
expect(fetchSpy).toHaveBeenCalledTimes(1)
51-
expect(fetchSpy).toHaveBeenCalledWith('https://firewall-api.socket.dev/purl/pkg%3Anpm%2Flodahs%400.0.1-security', {
52-
"headers": {
53-
"User-Agent": "SocketBunSecurityScanner/0.1.0 (linux x64) Bun/1.2.23",
54-
}})
51+
expect(fetchSpy).toHaveBeenCalledWith(
52+
'https://firewall-api.socket.dev/purl/pkg%3Anpm%2Flodahs%400.0.1-security',
53+
{
54+
'headers': {
55+
'User-Agent': expect.stringContaining('SocketBunSecurityScanner'),
56+
}
57+
}
58+
)
5559
})
5660

5761
test('unauthenticated scanner should batch requests correctly', async () => {
@@ -117,10 +121,10 @@ describe('unauthenticated', () => {
117121
expect(fetchSpy).toHaveBeenCalledTimes(1)
118122
// Check that special characters are properly encoded
119123
expect(fetchSpy).toHaveBeenCalledWith(
120-
'https://firewall-api.socket.dev/purl/pkg%3Anpm%2F%40scope%2Fpackage-name%401.0.0-beta.1',
124+
expect.stringContaining('pkg%3Anpm%2F%40scope%2Fpackage-name%401.0.0-beta.1'),
121125
{
122-
"headers": {
123-
"User-Agent": "SocketBunSecurityScanner/0.1.0 (linux x64) Bun/1.2.23",
126+
'headers': {
127+
'User-Agent': expect.stringContaining('SocketBunSecurityScanner'),
124128
}
125129
}
126130
)

0 commit comments

Comments
 (0)