Non-working breaking changes

This commit is contained in:
2023-04-19 10:23:03 +02:00
parent 1fb4ff26c4
commit 9284cce0ed
10 changed files with 124 additions and 208 deletions
+3 -3
View File
@@ -16,9 +16,9 @@ describe('client', () => {
const request = await fetch("http://127.0.0.1:3000/servers")
const data = await request.json()
const first = Object.entries(data)[0]
expect(first).toHaveProperty('name')
expect(first).toHaveProperty('id')
expect(first).toHaveProperty('description')
expect(first[1]).toHaveProperty('name')
expect(first[1]).toHaveProperty('id')
expect(first[1]).toHaveProperty('description')
})
test('player list', async () => {
+3 -2
View File
@@ -14,6 +14,7 @@ let pgClient
const data = {
attacker_weapon_1_mods: 0,
victim_id: '0',
servername: 'testServer',
victim_name: 'TestVictim',
victim_offhand_weapon_2: 0,
attacker_offhand_weapon_3: '0',
@@ -67,7 +68,7 @@ beforeAll(async () => {
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Authorization': `Basic ${Buffer.from(process.env.SERVERAUTH_ID + ':' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
'Authorization': `Bearer ${Buffer.from('' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
},
body: JSON.stringify(data), // body data type must match "Content-Type" header
});
@@ -108,7 +109,7 @@ describe('realtime', () => {
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Authorization': `Basic ${Buffer.from(process.env.SERVERAUTH_ID + ':' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
'Authorization': `Bearer ${Buffer.from('' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
},
body: JSON.stringify(data), // body data type must match "Content-Type" header
});
+9 -6
View File
@@ -12,12 +12,12 @@ beforeAll(async () => {
describe('server', () => {
test('server auth prefetch', async () => {
const response = await fetch(`http://127.0.0.1:3001/${process.env.SERVERAUTH_ID}`, {
const response = await fetch(`http://127.0.0.1:3001/`, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Authorization': `Basic ${Buffer.from(process.env.SERVERAUTH_ID + ':' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
'Authorization': `Bearer ${Buffer.from('' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
}
});
expect(response.status).toBe(200)
@@ -25,6 +25,7 @@ describe('server', () => {
test('register a kill', async () => {
const data = {
servername: 'testserver',
attacker_weapon_1_mods: 0,
victim_id: '0',
victim_name: 'TestVictim',
@@ -60,21 +61,23 @@ describe('server', () => {
victim_weapon_3: 'defender',
attacker_name: 'TestAttacker'
}
const response = await fetch(`http://127.0.0.1:3001/${process.env.SERVERAUTH_ID}/kill`, {
const response = await fetch(`http://127.0.0.1:3001/kill`, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Authorization': `Basic ${Buffer.from(process.env.SERVERAUTH_ID + ':' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
'Authorization': `Bearer ${Buffer.from(process.env.SERVERAUTH_TOKEN + '').toString('base64')}`
},
body: JSON.stringify(data), // body data type must match "Content-Type" header
});
console.log(await response.text())
expect(response.status).toBe(201)
})
test('register a kill with missing data', async () => {
const data = {
servername: 'testserver',
attacker_weapon_1_mods: NaN,
victim_id: '0',
victim_name: 'TestVictim',
@@ -110,12 +113,12 @@ describe('server', () => {
victim_weapon_3: 'arc_launcher',
attacker_name: 'TestAttacker'
}
const response = await fetch(`http://127.0.0.1:3001/${process.env.SERVERAUTH_ID}/kill`, {
const response = await fetch(`http://127.0.0.1:3001/kill`, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Authorization': `Basic ${Buffer.from(process.env.SERVERAUTH_ID + ':' + process.env.SERVERAUTH_TOKEN).toString('base64')}`
'Authorization': `Bearer ${Buffer.from(process.env.SERVERAUTH_TOKEN + '').toString('base64')}`
},
body: JSON.stringify(data), // body data type must match "Content-Type" header
});