add duid endpoint

This commit is contained in:
Devin Zuczek
2026-07-13 17:35:35 -04:00
parent 06c9f8f409
commit 08f25fb584
3 changed files with 68 additions and 0 deletions
+31
View File
@@ -222,6 +222,37 @@ describe('public endpoints', () => {
})
})
test('POST /api/PlayerReporting/v1/deviceId stores the new device id', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/PlayerReporting/v1/deviceId`, {
method: 'POST',
headers: {
...(await bearer()),
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
oldDeviceId: '491e8b9',
newDeviceId: '491e8b9566cb1b593367c72860e978b3d5765326',
platform: '0',
}),
})
expect(res.status).toBe(200)
expect(await res.json()).toEqual([])
const row = await env.DB.prepare(
"SELECT json_extract(data, '$.deviceId') AS deviceId FROM account WHERE account_id = 42"
).first<{ deviceId: string | null }>()
expect(row?.deviceId).toBe('491e8b9566cb1b593367c72860e978b3d5765326')
})
test('POST /api/PlayerReporting/v1/deviceId 401s without a bearer token', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/PlayerReporting/v1/deviceId`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ newDeviceId: 'abc' }),
})
expect(res.status).toBe(401)
})
test('POST /api/playerReputation/v2/bulk returns a reputation per id', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/playerReputation/v2/bulk`, {
method: 'POST',