Change ir/beatorajas client check to a graylist rather than a whitelist

Fixes #632
This commit is contained in:
zkldi
2022-01-21 14:11:42 +00:00
parent 4601297316
commit 67ad321e72
2 changed files with 12 additions and 13 deletions
@@ -126,18 +126,17 @@ export function ParseBeatorajaSingle(
const score = body.score as BeatorajaScore;
const chart = body.chart as BeatorajaChart;
if (chart.mode === "BEAT_14K" || chart.mode === "BEAT_7K") {
if (!SUPPORTED_BMS_CLIENTS.includes(client)) {
throw new ScoreImportFatalError(400, `Unsupported BMS client ${client}`);
}
} else if (chart.mode === "POPN_9K") {
if (!SUPPORTED_PMS_CLIENTS.includes(client)) {
throw new ScoreImportFatalError(400, `Unsupported PMS client ${client}`);
}
}
const isPMS = chart.mode === "POPN_9K";
const expectedClient = isPMS ? "beatoraja" : "LR2oraja";
if (!client.startsWith(expectedClient)) {
throw new ScoreImportFatalError(
400,
`Unsupported client ${client} -- Expected a variant of ${expectedClient}.`
);
}
return {
context: {
client: isPMS ? "beatoraja" : "lr2oraja",
@@ -150,7 +150,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
t.equal(res.status, 400);
t.equal(res.body.success, false);
t.match(res.body.description, /Unsupported BMS client/u);
t.match(res.body.description, /Unsupported client/u);
t.end();
});
@@ -165,7 +165,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
t.equal(res.status, 400);
t.equal(res.body.success, false);
t.match(res.body.description, /Unsupported BMS client/u);
t.match(res.body.description, /Unsupported client/u);
t.end();
});
@@ -180,7 +180,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
t.equal(res.status, 400);
t.equal(res.body.success, false);
t.match(res.body.description, /Unsupported PMS client/u);
t.match(res.body.description, /Unsupported client/u);
t.end();
});