first commit
This commit is contained in:
1 parent
18d31d5dcf
commit
77a5f5248c
31 files changed
+6637
-30
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { EDGE_USER_AGENT, edgeBrowserHeaders, encodeMultipart } from '../electron/main/keyescape-http'
|
||||
|
||||
describe('Edge-compatible Keyescape request metadata', () => {
|
||||
it('matches the captured Edge client hints and XHR metadata', () => {
|
||||
const headers = edgeBrowserHeaders({
|
||||
accept: 'application/json, text/javascript, */*; q=0.01',
|
||||
referer: 'https://www.keyescape.com/reservation2.php',
|
||||
xhr: true,
|
||||
})
|
||||
|
||||
expect(headers['User-Agent']).toBe(EDGE_USER_AGENT)
|
||||
expect(headers['Sec-CH-UA']).toContain('Microsoft Edge')
|
||||
expect(headers['Sec-CH-UA']).toContain('v="151"')
|
||||
expect(headers['Sec-CH-UA-Mobile']).toBe('?0')
|
||||
expect(headers['Sec-CH-UA-Platform']).toBe('"Windows"')
|
||||
expect(headers['Sec-Fetch-Mode']).toBe('cors')
|
||||
expect(headers['Sec-Fetch-Dest']).toBe('empty')
|
||||
expect(headers['X-Requested-With']).toBe('XMLHttpRequest')
|
||||
expect(headers.Referer).toBe('https://www.keyescape.com/reservation2.php')
|
||||
})
|
||||
|
||||
it('uses a fresh WebKit-style multipart boundary', () => {
|
||||
const first = encodeMultipart({ device: 'pc', t: 'ins_rev' })
|
||||
const second = encodeMultipart({ device: 'pc' })
|
||||
|
||||
expect(first.boundary).toMatch(/^----WebKitFormBoundary[A-Za-z0-9_-]{16}$/)
|
||||
expect(second.boundary).not.toBe(first.boundary)
|
||||
expect(first.body.toString('utf8')).toContain(`--${first.boundary}\r\n`)
|
||||
expect(first.body.toString('utf8')).toContain('Content-Disposition: form-data; name="device"')
|
||||
expect(first.body.toString('utf8')).toMatch(/--\r\n$/)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user