mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(server): staff tools, player-made items, picture safety, chat, multiplayer games
Staff and moderation
- Invisible staff (!invisible, "xiv"): hidden from players, half see-through
to other staff, cannot chat while hidden. New permission staff.invisible.
- Summon and goto land on the player's exact spot ("xgt" before the move).
- Custom warnings (!warn PLAYER custom TEXT), shown in the warning popup.
- Mod notes (!note, !notes; lib/modnotes.js), on the player page and the
dashboard.
- Granular permissions: per-role overrides (setting rolePermissions) and
per-account grants and denies, applied live to staff who are playing
(refreshStaff re-sends "xsp").
- Item control (lib/itemcontrol.js): lock items out of the item finder
(!lock, !unlock, !locked), take an item from a player (!take), delete a
custom item from the game and every inventory.
- GET items/find: search any item by name or id, marked locked, for the
dashboards' quick lock.
Player-made items (lib/playeritems.js, "xcm")
- The Item Maker: make, rename, set the worn look, delete. 5 a day, 20 in all;
names go through the name filter.
- Admin switches: Item Maker on/off, new items wait for approval, and a
separate switch (on by default) that holds every player-uploaded picture
for a moderator. Review queue for items.approve (moderator and up).
- Pictures (lib/itemart.js): PNG, JPEG and GIF cleaned of metadata, BMP
converted to PNG; 512px and 300KB at most once cleaned.
- Worn as the maker chooses: a sticker (the picture) or a texture (the
item's shape painted with the picture).
Picture safety
- A picture waiting for approval is never served publicly: /itemart/ 404s it,
and it is only shown through /account|/mod|/admin/api/itemart to its maker
and to staff who review or make items.
- A picture turned away or taken off is remembered by SHA-256 and cannot be
uploaded again.
- Three strikes: three pictures turned away stops a player's uploads until a
moderator lets them again. Staff can stop or allow uploads by hand.
- Accounts under 24 hours old cannot upload pictures (AJ_ITEM_ART_MIN_HOURS);
uploads capped at 10 a day.
- Optional Google Cloud Vision SafeSearch (lib/image-moderation.js) for item
pictures and Art Studio paintings when AJ_GOOGLE_VISION_API_KEY is set;
fails closed when the scanner is unreachable.
Chat
- Emoji: Twemoji pictures served at /emoji/<codepoints>.png and cached in
data/emoji (lib/emoji.js).
- Smart spam filtering before the word filter (lib/chatspam.js): long runs of
one character, repeated words and lines, huge words and emoji floods are
tidied, and repeats within 20 seconds are dropped.
- Typing indicator: "xty" is passed on to everyone in the room who can see
the player, at most every 2 seconds.
Games (lib/minigames.js)
- Room games can be played together: a MULTIPLAYER table gives a game a
waiting list (Single Player / Multiplayer). Players in the same room are
matched, taken into the game together, and each one's moves are relayed to
the others. Gem Breaker is the first: two players, "pos", "shoot" and
"playerLost" relayed.
- Gem Breaker's start message now lists each player's id. Without it no
player counted as local, so even single player could not aim.
Other
- Players stay connected through the client's new 75-minute AFK limit
(idleTimeoutMs 80 minutes).
- Jam-a-Grams carry custom items and colours; Jammer Wall avatar photos are
validated (walls.js photoParam).
- Weak passwords refused (common words, or containing the username).
- Code-scanning fixes: every logged value goes through logText
(lib/logtext.js) against log injection, HSTS, path-only error logs, a
single file read in lib/names.js.
Tests: items (pictures, approval, strikes, re-upload refusal, the hidden
waiting picture, the dashboard search), staff (invisibility, goto and summon
spots, custom warnings, notes), buddygames (two-player Gem Breaker, the
typing relay), and updates for main's verified badge and spawn rooms.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da7eb9af58
commit
e05565787f
50 files changed
+2904
-277
No files matched your search
+22
-22
@@ -44,7 +44,7 @@ const panel = page("admin");
|
||||
|
||||
const run = async () => {
|
||||
const register = (username, avatarType) => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({username, password: "Password01", avatarType, agreed: true})});
|
||||
body: JSON.stringify({username, password: "KettlePass01", avatarType, agreed: true})});
|
||||
assert.strictEqual((await register("Ann", 4)).status, 200);
|
||||
assert.strictEqual((await register("Ben", 24)).status, 200);
|
||||
// what a client shows beside its login form.
|
||||
@@ -55,8 +55,8 @@ const run = async () => {
|
||||
assert.match(await (await fetch(`${BASE}/account`)).text(), /Your account/);
|
||||
assert.strictEqual((await mine("me")).status, 401);
|
||||
assert.strictEqual((await mine("login", {username: "Ann", password: "wrong"})).status, 401);
|
||||
assert.strictEqual((await mine("login", {username: "Nobody", password: "Password01"})).status, 401);
|
||||
const signedIn = await mine("login", {username: "ann", password: "Password01"});
|
||||
assert.strictEqual((await mine("login", {username: "Nobody", password: "KettlePass01"})).status, 401);
|
||||
const signedIn = await mine("login", {username: "ann", password: "KettlePass01"});
|
||||
assert.strictEqual(signedIn.status, 200);
|
||||
assert.match(signedIn.cookie, /^ajc_account=[0-9a-f]{48}$/);
|
||||
const ann = signedIn.cookie;
|
||||
@@ -67,8 +67,8 @@ const run = async () => {
|
||||
assert.deepStrictEqual(me.history.map(login => [login.via, login.ok]), [["web", true], ["web", false]]);
|
||||
|
||||
// --- parts of the game switched off
|
||||
const {client: a, roomId} = await arrive("Ann", "Password01");
|
||||
const {client: b} = await arrive("Ben", "Password01");
|
||||
const {client: a, roomId} = await arrive("Ann", "KettlePass01");
|
||||
const {client: b} = await arrive("Ben", "KettlePass01");
|
||||
await a.untilXt("ac");
|
||||
const set = async (feature, on) => assert.strictEqual((await mine("act", {action: "feature", feature, on}, ann)).status, 200);
|
||||
assert.strictEqual((await mine("act", {action: "feature", feature: "flying", on: false}, ann)).status, 400);
|
||||
@@ -144,7 +144,7 @@ const run = async () => {
|
||||
}
|
||||
b.xt("ts", roomId, 0, 1, 0, benHas[9]); // ben puts his scarf up for trade, in the game
|
||||
await b.untilXt("tl");
|
||||
const benPageCookie = (await mine("login", {username: "Ben", password: "Password01"})).cookie;
|
||||
const benPageCookie = (await mine("login", {username: "Ben", password: "KettlePass01"})).cookie;
|
||||
const tradable = (await mine("tradable?of=ben", undefined, ann)).data;
|
||||
assert.deepStrictEqual([tradable.found, tradable.theirs.map(item => item.name), tradable.mine.map(item => item.name)], [true, [scarfName], [hatName]]);
|
||||
assert.strictEqual((await mine("act", {action: "offer", to: "Ben", wanted: tradable.theirs[0], offered: []}, ann)).status, 400);
|
||||
@@ -182,27 +182,27 @@ const run = async () => {
|
||||
assert.strictEqual((await panel("support", {action: "approve", id: waiting.names[0].id}, admin)).status, 200);
|
||||
assert.strictEqual((await panel("support", {action: "approve", id: waiting.names[0].id}, admin)).status, 400); // only once
|
||||
assert.strictEqual((await mine("me", undefined, ann)).status, 401); // renamed: sign in again, with the new name
|
||||
assert.strictEqual((await authenticate("Ann", "Password01")).status, 401);
|
||||
const annabel = (await mine("login", {username: "Annabel", password: "Password01"})).cookie;
|
||||
assert.strictEqual((await authenticate("Ann", "KettlePass01")).status, 401);
|
||||
const annabel = (await mine("login", {username: "Annabel", password: "KettlePass01"})).cookie;
|
||||
me = (await mine("me", undefined, annabel)).data;
|
||||
assert.deepStrictEqual([me.username, me.nameRequests[0].status, me.feedback[0].handledAt > 0], ["Annabel", "approved", true]);
|
||||
|
||||
// --- the lock: out of the game, and no way back in until it is undone
|
||||
const {token} = await arrive("Annabel", "Password01");
|
||||
const {token} = await arrive("Annabel", "KettlePass01");
|
||||
assert.strictEqual((await mine("act", {action: "lock", locked: true}, annabel)).status, 200);
|
||||
assert.strictEqual((await authenticate("Annabel", "Password01")).status, 401);
|
||||
assert.strictEqual((await authenticate("Annabel", "KettlePass01")).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: token})).status, 401); // the saved sign-in is gone
|
||||
assert.strictEqual((await panel("accounts", undefined, admin)).data.accounts.find(account => account.username === "Annabel").locked, true);
|
||||
assert.strictEqual((await mine("login", {username: "Annabel", password: "Password01"})).status, 200); // the page still lets her in
|
||||
assert.strictEqual((await mine("login", {username: "Annabel", password: "KettlePass01"})).status, 200); // the page still lets her in
|
||||
assert.strictEqual((await mine("act", {action: "lock", locked: false}, annabel)).status, 200);
|
||||
assert.strictEqual((await authenticate("Annabel", "Password01")).status, 200);
|
||||
assert.strictEqual((await authenticate("Annabel", "KettlePass01")).status, 200);
|
||||
|
||||
// --- the password: the old one is asked for, and stops working
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "wrong", password: "Password02"}, annabel)).status, 400);
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "Password01", password: "short"}, annabel)).status, 400);
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "Password01", password: "Password02"}, annabel)).status, 200);
|
||||
assert.strictEqual((await authenticate("Annabel", "Password01")).status, 401);
|
||||
assert.strictEqual((await authenticate("Annabel", "Password02")).status, 200);
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "wrong", password: "KettlePass02"}, annabel)).status, 400);
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "KettlePass01", password: "short"}, annabel)).status, 400);
|
||||
assert.strictEqual((await mine("act", {action: "password", current: "KettlePass01", password: "KettlePass02"}, annabel)).status, 200);
|
||||
assert.strictEqual((await authenticate("Annabel", "KettlePass01")).status, 401);
|
||||
assert.strictEqual((await authenticate("Annabel", "KettlePass02")).status, 200);
|
||||
me = (await mine("me", undefined, annabel)).data;
|
||||
assert.ok(me.history.some(login => login.via === "launcher" && !login.ok) && me.history.some(login => login.via === "game" && login.ok));
|
||||
|
||||
@@ -210,14 +210,14 @@ const run = async () => {
|
||||
assert.strictEqual((await mine("me", undefined, annabel)).status, 401);
|
||||
|
||||
// --- deleting one's own account: the password and the name, then it is gone
|
||||
const {client: b2} = await arrive("Ben", "Password01");
|
||||
const ben = (await mine("login", {username: "Ben", password: "Password01"})).cookie;
|
||||
const {client: b2} = await arrive("Ben", "KettlePass01");
|
||||
const ben = (await mine("login", {username: "Ben", password: "KettlePass01"})).cookie;
|
||||
assert.strictEqual((await mine("act", {action: "delete", current: "wrong", confirm: "Ben"}, ben)).status, 400);
|
||||
assert.strictEqual((await mine("act", {action: "delete", current: "Password01", confirm: "Annabel"}, ben)).status, 400);
|
||||
const gone = await mine("act", {action: "delete", current: "Password01", confirm: "ben"}, ben);
|
||||
assert.strictEqual((await mine("act", {action: "delete", current: "KettlePass01", confirm: "Annabel"}, ben)).status, 400);
|
||||
const gone = await mine("act", {action: "delete", current: "KettlePass01", confirm: "ben"}, ben);
|
||||
assert.deepStrictEqual([gone.status, gone.data.deleted, gone.data.account], [200, true, undefined]);
|
||||
assert.strictEqual((await mine("me", undefined, ben)).status, 401);
|
||||
assert.strictEqual((await authenticate("Ben", "Password01")).status, 401);
|
||||
assert.strictEqual((await authenticate("Ben", "KettlePass01")).status, 401);
|
||||
assert.ok(!(await panel("accounts", undefined, admin)).data.accounts.some(account => account.username === "Ben"));
|
||||
// the name is held for a while (lib/accounts.js, NAME_HELD_DAYS): the
|
||||
// players Ben met still know him by it.
|
||||
|
||||
+52
-2
@@ -14,7 +14,7 @@ const {postJson} = harness;
|
||||
const GAMES = {ticTacToe: 89, fourGems: 90, rockPaperScissors: 91, shellGame: 92, pairs: 93, scooped: 95, bowling: 98, marbles: 101};
|
||||
|
||||
const arrive = async username => {
|
||||
const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "Password01"})).json();
|
||||
const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "KettlePass01"})).json();
|
||||
const client = new harness.GameClient(GAME_PORT);
|
||||
await client.connect();
|
||||
const login = await client.logIn(username, auth.auth_token);
|
||||
@@ -28,7 +28,7 @@ const arrive = async username => {
|
||||
|
||||
const run = async () => {
|
||||
for (const username of ["Ann", "Ben", "Cat"]) {
|
||||
const response = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username, password: "Password01", avatarType: 1, agreed: true})});
|
||||
const response = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username, password: "KettlePass01", avatarType: 1, agreed: true})});
|
||||
assert.strictEqual(response.status, 200);
|
||||
}
|
||||
const ann = await arrive("Ann");
|
||||
@@ -301,6 +301,56 @@ const run = async () => {
|
||||
a.socket.destroy();
|
||||
assert.deepStrictEqual((await b.untilXt("mp")).slice(2), ["101", "1"]);
|
||||
|
||||
// --- a room game played together (lib/minigames.js MULTIPLAYER): Gem
|
||||
// Breaker offers its waiting list, Ben waits in the room, Cat joins, both
|
||||
// are taken in, and each one's moves reach the other
|
||||
// (and first, typing: Cat's "..." reaches Ben, said again too soon is not
|
||||
// passed on, and stopping is)
|
||||
c.xt("xty", cat.roomId, 1);
|
||||
assert.deepStrictEqual((await b.untilXt("xty")).slice(2), [cat.id, "1"]);
|
||||
c.xt("xty", cat.roomId, 1);
|
||||
c.xt("xty", cat.roomId, 0);
|
||||
assert.deepStrictEqual((await b.nextXt("xty")).slice(2), [cat.id, "0"]);
|
||||
|
||||
const GEM_BREAKER = 30;
|
||||
b.xt("mi", ben.roomId, GEM_BREAKER);
|
||||
const gemInfo = (await b.untilXt("mi")).slice(3);
|
||||
assert.deepStrictEqual([gemInfo[0], gemInfo[4], gemInfo[5]], ["30", "2", "2"]);
|
||||
b.xt("mj", ben.roomId, GEM_BREAKER, 1, 0, -1);
|
||||
assert.deepStrictEqual((await b.untilXt("mj")).slice(1), [ben.roomId, ben.id]);
|
||||
c.xt("mj", cat.roomId, GEM_BREAKER, 1, 0, -1);
|
||||
for (const client of [b, c]) {
|
||||
assert.deepStrictEqual((await client.untilXt("mj")).slice(1), [ben.roomId, ben.id, cat.id]);
|
||||
}
|
||||
const gemRoom = (await b.untilXt("rj"))[4];
|
||||
for (const client of [b, c]) {
|
||||
assert.deepStrictEqual((await client.untilXt("mj")).slice(1), [gemRoom, ben.id, cat.id]);
|
||||
assert.deepStrictEqual((await client.untilXt("ms")).slice(2, 5), ["2", ben.id, cat.id]);
|
||||
}
|
||||
b.xt("mm", gemRoom, GEM_BREAKER, "ready");
|
||||
c.xt("mm", gemRoom, GEM_BREAKER, "ready");
|
||||
for (const client of [b, c]) {
|
||||
const go = await client.untilXt("mm");
|
||||
assert.deepStrictEqual([go[2], ...go.slice(4)], ["start", "2", ben.id, "0", cat.id, "0"]);
|
||||
}
|
||||
b.xt("mm", gemRoom, GEM_BREAKER, "pos", "-45");
|
||||
assert.deepStrictEqual((await c.nextXt("mm")).slice(2), ["pos", ben.id, "-45"]);
|
||||
c.xt("mm", gemRoom, GEM_BREAKER, "shoot", "0.5", "-0.8", "210", "40", "3", "1", "300", "0", "5");
|
||||
assert.deepStrictEqual((await b.nextXt("mm")).slice(2), ["shoot", "0.5", "-0.8", "210", "40", "3", "1", "300", "0", "5"]);
|
||||
c.xt("mm", gemRoom, GEM_BREAKER, "pos", "<b>");
|
||||
c.xt("mm", gemRoom, GEM_BREAKER, "playerLost", "12345");
|
||||
assert.deepStrictEqual((await b.nextXt("mm")).slice(2), ["playerLost", "12345"]); // and not the one with markup
|
||||
// one leaving: the other is told, as the game expects
|
||||
c.xt("ml", gemRoom);
|
||||
assert.deepStrictEqual((await b.untilXt("ml")).slice(1), [gemRoom, cat.id]);
|
||||
// alone, the start names its one player, whose cannon it is
|
||||
b.xt("rj", gemRoom, TOWNSHIP, 1, 0, 0);
|
||||
const back = (await b.untilXt("rj"))[4];
|
||||
b.xt("mj", back, GEM_BREAKER, 0, 0, -1);
|
||||
const soloRoom = (await b.untilXt("mj"))[1];
|
||||
b.xt("mm", soloRoom, GEM_BREAKER, "ready");
|
||||
assert.deepStrictEqual((await b.untilXt("mm")).slice(4), ["1", ben.id, "0"]);
|
||||
|
||||
b.socket.destroy();
|
||||
c.socket.destroy();
|
||||
};
|
||||
|
||||
+16
-17
@@ -46,7 +46,7 @@ const wall = async body => (await postJson(`${BASE}/wall`, body)).json();
|
||||
const run = async () => {
|
||||
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
|
||||
for (const username of ["Ann", "Ben", "Cat", "Scout"]) {
|
||||
assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200);
|
||||
assert.strictEqual((await registerJson({username, password: "KettlePass01"})).status, 200);
|
||||
}
|
||||
|
||||
// --- the admin panel's message of the day reaches a player once their first room has loaded
|
||||
@@ -62,7 +62,7 @@ const run = async () => {
|
||||
assert.strictEqual((await panel("motd", {text: "Welcome to the test server"}, admin)).status, 200);
|
||||
assert.strictEqual((await panel("messages", undefined, admin)).data.motd, "Welcome to the test server");
|
||||
|
||||
const {client: a, login: annLogin, roomId} = await arrive("Ann", "Password01");
|
||||
const {client: a, login: annLogin, roomId} = await arrive("Ann", "KettlePass01");
|
||||
// "ua": the text sits where a room id usually does, then 1 = system message.
|
||||
assert.deepStrictEqual((await a.untilXt("ua")).slice(1), ["Welcome to the test server", "1"]);
|
||||
assert.strictEqual((await panel("motd", {text: ""}, admin)).status, 200);
|
||||
@@ -81,7 +81,7 @@ const run = async () => {
|
||||
a.xt("pad", roomId, "Ann");
|
||||
assert.deepStrictEqual((await a.nextXt("pad")).slice(2), ["1", "1", String(annLogin.params.usableAdoptAPetDefs[0].defId), String(annLogin.params.usableAdoptAPetDefs[0].invId)]);
|
||||
|
||||
const {client: b, login: benLogin} = await arrive("Ben", "Password01");
|
||||
const {client: b, login: benLogin} = await arrive("Ben", "KettlePass01");
|
||||
await a.untilXt("ac");
|
||||
await a.nextXt("il");
|
||||
|
||||
@@ -90,7 +90,7 @@ const run = async () => {
|
||||
// path. a scout goes in first and comes back until the file has been read,
|
||||
// so that what follows does not depend on what an earlier run left in the
|
||||
// cache. (the scout never enters the township, so a and b see nothing.)
|
||||
const scoutAuth = await (await postJson(`${BASE}/authenticate`, {username: "Scout", password: "Password01"})).json();
|
||||
const scoutAuth = await (await postJson(`${BASE}/authenticate`, {username: "Scout", password: "KettlePass01"})).json();
|
||||
const scout = new harness.GameClient(GAME_PORT);
|
||||
await scout.connect();
|
||||
assert.strictEqual((await scout.logIn("Scout", scoutAuth.auth_token)).status, "1");
|
||||
@@ -200,7 +200,7 @@ const run = async () => {
|
||||
// --- name tags: the colour and badge go with a colour change, reach the room, and stay
|
||||
a.xt("gl", roomId, 110);
|
||||
const badges = await a.nextXt("gl");
|
||||
assert.deepStrictEqual([badges[3], badges[8], badges[9], badges[70]], ["1049", "75", "1", "62"]); // every badge, in id order: the game's 62 and the thirteen the admin gives
|
||||
assert.deepStrictEqual([badges[3], badges[8], badges[9], badges[70]], ["1049", "76", "1", "62"]); // every badge, in id order: the game's 62 and the fourteen the admin gives (verified among them)
|
||||
const tag = 6 | 11 << 8; // colour 6, the twelfth badge
|
||||
a.xt("ap", roomId, 1, 2, 3, tag);
|
||||
assert.deepStrictEqual((await a.nextXt("ap")).slice(2), ["1"]);
|
||||
@@ -435,18 +435,9 @@ const run = async () => {
|
||||
b.xt("ei", own[4], 0);
|
||||
await b.nextXt("ei");
|
||||
|
||||
// A secret valentine: the receiver is not told who sent it, the server knows.
|
||||
// secret valentines are off (lib/ecards.js): one asked for is refused
|
||||
a.xt("es", own[4], "Ben", cards[9], stamps[9], 2, "GUESS WHO", 0, 0, 1);
|
||||
assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["1"]);
|
||||
const valentine = await b.nextXt("ep");
|
||||
assert.deepStrictEqual([valentine[3], valentine[7], valentine[18]], ["", "GUESS WHO", "1"]); // no name; special type 1
|
||||
b.xt("fr", own[4], "Secret Valentine", 14); // reported under the name the game shows
|
||||
assert.deepStrictEqual((await b.nextXt("fr")).slice(2), ["1"]);
|
||||
const aboutValentine = (await panel("reports", undefined, admin)).data.reports;
|
||||
assert.deepStrictEqual([aboutValentine[0].reporter, aboutValentine[0].target, aboutValentine[0].reason], ["Ben", "Ann", "Inappropriate Jam-A-Gram"]);
|
||||
await panel("report", {id: aboutValentine[0].id}, admin);
|
||||
b.xt("ed", own[4], valentine[2]);
|
||||
await b.nextXt("ed");
|
||||
assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["0"]);
|
||||
|
||||
// --- Jammer Walls: the wallpapers a wall cannot be drawn without, and their buttons
|
||||
a.xt("gl", own[4], 314);
|
||||
@@ -488,6 +479,14 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["1"]);
|
||||
const mine = await wall({cmd: "GET", t: ownToken});
|
||||
assert.deepStrictEqual([mine.p.bg, mine.p.tag, mine.p.visits, mine.r.length], ["7", "hello there", 1, 1]); // visits are not the owner's to set
|
||||
// the photo booth picture: its animal, its pet and what it wears, kept
|
||||
const photo = {avatar: {id: 4, color1: 1463028479, color2: 603979776, color3: 83885823, eyes: 4, pattern: 25}, bgid: 3,
|
||||
pet: {ts: 1792133948, lbits: 25, uBits: 0, eBits: 0}, items: [{id: 101, color: 1463028479}, {id: 202, color: 0}]};
|
||||
b.xt("wps", own[4], JSON.stringify({pb: photo}));
|
||||
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["1"]);
|
||||
assert.deepStrictEqual((await wall({cmd: "GET", t: ownToken})).p.pb, photo);
|
||||
b.xt("wps", own[4], JSON.stringify({pb: {avatar: {deep: {deeper: 1}}}})); // but no deeper than that
|
||||
assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["0"]);
|
||||
assert.deepStrictEqual(await wall({cmd: "CLW", t: token[3]}), {s: false}); // only the owner clears a wall
|
||||
assert.deepStrictEqual(await wall({cmd: "DEL", t: ownToken, x: put.x}), {s: true});
|
||||
assert.strictEqual((await wall({cmd: "GET", t: ownToken})).r.length, 0);
|
||||
@@ -515,7 +514,7 @@ const run = async () => {
|
||||
assert.strictEqual((await panel("overview", undefined, admin)).data.stats.reports, 1);
|
||||
assert.strictEqual((await panel("report", {id: waiting.reports[0].id}, admin)).status, 200);
|
||||
assert.strictEqual((await panel("reports", undefined, admin)).data.open, 0);
|
||||
assert.strictEqual((await panel("reports?handled=1", undefined, admin)).data.reports.length, 2); // this one and the valentine
|
||||
assert.strictEqual((await panel("reports?handled=1", undefined, admin)).data.reports.length, 1); // this one (secret valentines, reported before, are off)
|
||||
|
||||
// --- blocking: no chat from them, out of my party and my den, and out of sight if I say so
|
||||
a.xt("bb", own[4], "Ben");
|
||||
|
||||
+240
-3
@@ -80,7 +80,7 @@ const arrive = async (username, password, totp, onLogin = async () => {}) => {
|
||||
client.xt("rj", 1, TOWNSHIP, 1, 0, 0);
|
||||
const rj = await client.untilXt("rj");
|
||||
await client.untilXt("rp");
|
||||
return {client, roomId: rj[4]};
|
||||
return {client, roomId: rj[4], token: auth.auth_token};
|
||||
};
|
||||
|
||||
// a pack as the clients get it.
|
||||
@@ -103,7 +103,7 @@ const shopList = async (client, roomId, shop) => {
|
||||
return (await client.untilXt("gl")).slice(9);
|
||||
};
|
||||
|
||||
const people = {Dev: "Password21", Hal: "Password22", Pat: "Password23", Lou: "Password24"};
|
||||
const people = {Dev: "KettlePass21", Hal: "KettlePass22", Pat: "KettlePass23", Lou: "KettlePass24"};
|
||||
const secret = {};
|
||||
let usedStep = 0;
|
||||
let made = {};
|
||||
@@ -229,10 +229,247 @@ const first = async () => {
|
||||
}
|
||||
assert.strictEqual((await dev("/mod/api/items")).data.items.length, 3);
|
||||
|
||||
// --- locked out of the item finder (lib/itemcontrol.js): players do not
|
||||
// find it or take it; the owner here, and staff who may lock, still do
|
||||
const searchAs = async (q, who) => (await (await fetch(`${BASE}/api/search?kind=clothing&q=${q}${who ? `&username=${who.name}&token=${who.token}` : ""}`)).json()).results;
|
||||
// (as the item finder page and the client send it: no Origin of another site)
|
||||
const giveAs = (body, token) => fetch(`${BASE}/api/give`, {method: "POST", headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({...body, ...(token ? {token} : {})})});
|
||||
const patAs = {name: "Pat", token: pat.token};
|
||||
assert.ok((await searchAs(50001, patAs)).some(entry => entry.id === 50001));
|
||||
assert.match((await dev("/mod/api/items", {action: "lock", kind: "clothing", id: 50001})).data.ok, /^Quick Hat \(clothing 50001\) is locked out of the item finder\.$/);
|
||||
assert.match((await dev("/mod/api/items", {action: "lock", kind: "clothing", id: 50001})).data.error, /already locked/);
|
||||
assert.ok(!(await searchAs(50001, patAs)).some(entry => entry.id === 50001));
|
||||
const refused = await giveAs({username: "Pat", kind: "clothing", id: 50001}, pat.token);
|
||||
assert.deepStrictEqual([refused.status, (await refused.json()).error], [403, "That item is locked out of the item finder."]);
|
||||
assert.deepStrictEqual((await searchAs(50001)).filter(entry => entry.id === 50001).map(entry => [entry.name, entry.locked]), [["Quick Hat (locked)", true]]);
|
||||
assert.strictEqual((await searchAs(50001, {name: "Dev", token: devGame.token})).find(entry => entry.id === 50001).name, "Quick Hat (locked)");
|
||||
assert.deepStrictEqual((await dev("/mod/api/items")).data.locked, [{kind: "clothing", id: 50001, name: "Quick Hat"}]);
|
||||
// the dashboards' lock finds it by name, marked locked, with the count
|
||||
const findLock = (await dev("/mod/api/items/find?q=quick%20hat&kind=clothing")).data;
|
||||
assert.deepStrictEqual([findLock.lockedCount, findLock.results.find(entry => entry.id === 50001)],
|
||||
[1, {kind: "clothing", id: 50001, cost: findLock.results.find(entry => entry.id === 50001).cost, name: "Quick Hat", locked: true, custom: true}]);
|
||||
say(devGame.client, devGame.roomId, "!locked");
|
||||
assert.strictEqual(await nextBox(devGame.client), "Locked out of the item finder: clothing 50001 Quick Hat");
|
||||
|
||||
// --- taken from a player: every one of it, their game told
|
||||
assert.strictEqual((await giveAs({username: "Pat", kind: "clothing", id: 50001, colorIndex: 0})).status, 200); // the owner, here
|
||||
assert.strictEqual((await giveAs({username: "Pat", kind: "clothing", id: 50001, colorIndex: 0})).status, 200);
|
||||
say(devGame.client, devGame.roomId, "!take Pat clothing 50001");
|
||||
assert.strictEqual(await nextBox(devGame.client), "Took 2 of Quick Hat (clothing 50001) from Pat.");
|
||||
for (;;) {
|
||||
const changed = await pat.client.untilXt("il");
|
||||
if (changed[2] === "2" && changed[8] === "2") { // two removed
|
||||
break;
|
||||
}
|
||||
}
|
||||
say(devGame.client, devGame.roomId, "!take Pat clothing 50001");
|
||||
assert.strictEqual(await nextBox(devGame.client), "Pat has no Quick Hat (clothing 50001).");
|
||||
assert.strictEqual((await giveAs({username: "Pat", kind: "den", id: 50000})).status, 200);
|
||||
assert.match((await dev("/mod/api/items", {action: "take", username: "Pat", kind: "den", id: 50000})).data.ok, /^Took 1 of Test Chair \(den item 50000\) from Pat\.$/);
|
||||
assert.match((await dev("/mod/api/items", {action: "unlock", kind: "clothing", id: 50001})).data.ok, /back in the item finder/);
|
||||
assert.ok((await searchAs(50001, patAs)).some(entry => entry.id === 50001));
|
||||
|
||||
// --- a custom item deleted: out of the game and every inventory
|
||||
say(devGame.client, devGame.roomId, `!item clothing ${base.id} Doomed Hat`);
|
||||
assert.strictEqual(await nextBox(devGame.client), "Made Doomed Hat, clothing 50002. It is in the item finder now.");
|
||||
assert.strictEqual((await giveAs({username: "Pat", kind: "clothing", id: 50002, colorIndex: 0})).status, 200);
|
||||
assert.match((await dev("/mod/api/items", {action: "delete", kind: "clothing", id: 50002})).data.ok, /^Deleted Doomed Hat \(clothing 50002\), and took 1 from players\.$/);
|
||||
assert.ok(!(await searchAs(50002)).some(entry => entry.id === 50002));
|
||||
assert.strictEqual((await giveAs({username: "Pat", kind: "clothing", id: 50002, colorIndex: 0})).status, 400);
|
||||
assert.ok(!byId(await pack(1000), 50002));
|
||||
assert.strictEqual((await dev("/mod/api/items")).data.items.length, 3);
|
||||
|
||||
// --- a player's own items (lib/playeritems.js, the client's Item Maker):
|
||||
// free, given to them, found by them only, at most five a day
|
||||
const maker = async (...params) => {
|
||||
pat.client.xt("xcm", pat.roomId, ...params);
|
||||
const answer = await pat.client.untilXt("xcm");
|
||||
return {ok: answer[2] === "1", said: answer[3], today: Number(answer[4]), inAll: Number(answer[5]), mine: JSON.parse(answer[6])};
|
||||
};
|
||||
assert.deepStrictEqual(await maker("info"), {ok: true, said: "", today: 5, inAll: 20, mine: []});
|
||||
const own = await maker("make", "clothing", base.id, "Pat Hat");
|
||||
assert.deepStrictEqual([own.ok, own.said, own.today, own.inAll], [true, "Made Pat Hat. It is in your clothing now.", 4, 19]);
|
||||
const patHat = own.mine[0];
|
||||
assert.deepStrictEqual([patHat.kind, patHat.name, patHat.base], ["clothing", "Pat Hat", Number(base.id)]);
|
||||
assert.ok((await searchAs(patHat.id, patAs)).some(entry => entry.id === patHat.id));
|
||||
const halAs = {name: "Hal", token: hal.token};
|
||||
assert.ok(!(await searchAs(patHat.id, halAs)).some(entry => entry.id === patHat.id));
|
||||
assert.strictEqual((await giveAs({username: "Hal", kind: "clothing", id: patHat.id, colorIndex: 0}, hal.token)).status, 403);
|
||||
assert.ok((await searchAs(patHat.id, {name: "Dev", token: devGame.token})).some(entry => entry.id === patHat.id)); // staff who make items
|
||||
assert.match((await maker("make", "clothing", base.id, "Admin Hat")).said, /not allowed/);
|
||||
assert.match((await maker("make", "clothing", bodyPart.id, "Body")).said, /cannot be made into one of your own/);
|
||||
// the base list offers only what can be copied
|
||||
assert.ok(!(await (await fetch(`${BASE}/api/search?base=1&kind=clothing&q=${bodyPart.id}`)).json()).results.some(entry => entry.id === bodyPart.id));
|
||||
for (let count = 2; count <= 5; count++) {
|
||||
assert.ok((await maker("make", "den", 1, `Pat Chair ${count}`)).ok);
|
||||
}
|
||||
const full = await maker("make", "den", 1, "One Too Many");
|
||||
assert.deepStrictEqual([full.ok, full.today], [false, 0]);
|
||||
assert.match(full.said, /made 5 items today/);
|
||||
// --- its own picture (lib/itemart.js): checked and cleaned, served, and
|
||||
// every game told; only by its maker or staff who make items
|
||||
const crc32 = buf => {
|
||||
let c = ~0;
|
||||
for (const byte of buf) {
|
||||
c ^= byte;
|
||||
for (let k = 0; k < 8; k++) {
|
||||
c = (c >>> 1) ^ (0xEDB88320 & -(c & 1));
|
||||
}
|
||||
}
|
||||
return (~c) >>> 0;
|
||||
};
|
||||
const chunk = (type, data) => {
|
||||
const head = Buffer.alloc(8);
|
||||
head.writeUInt32BE(data.length);
|
||||
head.write(type, 4, "latin1");
|
||||
const crc = Buffer.alloc(4);
|
||||
crc.writeUInt32BE(crc32(Buffer.concat([head.subarray(4), data])));
|
||||
return Buffer.concat([head, data, crc]);
|
||||
};
|
||||
const png = (side, extra = []) => {
|
||||
const ihdr = Buffer.alloc(13);
|
||||
ihdr.writeUInt32BE(side, 0);
|
||||
ihdr.writeUInt32BE(side, 4);
|
||||
ihdr[8] = 8;
|
||||
ihdr[9] = 2;
|
||||
const raw = Buffer.alloc((side * 3 + 1) * side, 0x7F);
|
||||
return Buffer.concat([Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]), chunk("IHDR", ihdr), ...extra,
|
||||
chunk("IDAT", zlib.deflateSync(raw)), chunk("IEND", Buffer.alloc(0))]);
|
||||
};
|
||||
const upload = (who, entry, body, extra = "") => fetch(`${BASE}/api/itemart?kind=${entry.kind}&id=${entry.id}&token=${who.token}${extra}`,
|
||||
{method: "POST", headers: {"Content-Type": "application/octet-stream"}, body}).then(response => response.json());
|
||||
const hatEntry = (await maker("info")).mine.find(entry => entry.name === "Pat Hat");
|
||||
// by default a player's picture waits for a moderator, even with items
|
||||
// let in at once: nobody else is shown it, not even by its address
|
||||
assert.match((await upload(pat, hatEntry, png(30))).ok, /waiting for a moderator/);
|
||||
assert.strictEqual((await maker("info")).mine.find(entry => entry.kind === hatEntry.kind && entry.id === hatEntry.id).art, "");
|
||||
assert.strictEqual((await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png`)).status, 404);
|
||||
const pendingUrl = (await admin("/admin/api/review")).data.waiting.find(entry => entry.id === hatEntry.id).artUrl;
|
||||
assert.match(pendingUrl, /^\/admin\/api\/itemart\?kind=clothing&id=\d+&v=p[0-9a-f]{12}$/);
|
||||
assert.strictEqual((await admin(pendingUrl)).status, 200);
|
||||
assert.strictEqual((await fetch(`${BASE}${pendingUrl}`)).status, 404); // signed in to nothing
|
||||
assert.match((await admin("/admin/api/review", {kind: "clothing", id: hatEntry.id, approve: true})).data.ok, /picture is shown now/);
|
||||
assert.strictEqual((await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png`)).status, 200);
|
||||
while (!(await untilDefs(pat.client, "clothing")).some(row => row.art)) {
|
||||
// every game is told of it waiting (no picture), then of it shown
|
||||
}
|
||||
// the rest of these, shown at once (the admin's switch)
|
||||
assert.strictEqual((await admin("/admin/api/item-switches", {artApproval: false})).status, 200);
|
||||
assert.strictEqual((await admin("/admin/api/review")).data.artApproval, false);
|
||||
assert.match((await upload(pat, hatEntry, png(32, [chunk("tEXt", Buffer.from("Author\x00Pat at home"))]))).ok, /new picture/);
|
||||
const told = (await untilDefs(pat.client, "clothing")).map(row => [row.id, row.art]);
|
||||
const sameItem = entry => entry.kind === hatEntry.kind && entry.id === hatEntry.id;
|
||||
const withArt = (await maker("info")).mine.find(sameItem);
|
||||
assert.match(withArt.art, /^p[0-9a-f]{12}$/);
|
||||
assert.deepStrictEqual(told, [[String(hatEntry.id), withArt.art]]);
|
||||
const served = await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png?v=${withArt.art}`);
|
||||
assert.deepStrictEqual([served.status, served.headers.get("content-type"), served.headers.get("x-content-type-options")], [200, "image/png", "nosniff"]);
|
||||
const bytes = Buffer.from(await served.arrayBuffer());
|
||||
assert.ok(!bytes.includes(Buffer.from("tEXt")) && !bytes.includes(Buffer.from("Pat at home")), "the text chunk was left in");
|
||||
assert.match((await upload(pat, hatEntry, Buffer.from("<html><script>alert(1)</script></html>"))).error, /not a PNG, JPEG, GIF or BMP/);
|
||||
// a GIF is kept a GIF (without its comment); a BMP is made a PNG
|
||||
const gif = Buffer.concat([Buffer.from("GIF89a"), Buffer.from([16, 0, 16, 0, 0x80, 0, 0]), Buffer.alloc(6, 0x55),
|
||||
Buffer.from([0x21, 0xFE, 4]), Buffer.from("Bob!"), Buffer.from([0]), Buffer.from([0x2C, 0, 0, 0, 0, 16, 0, 16, 0, 0, 2, 3, 1, 2, 3, 0, 0x3B])]);
|
||||
assert.match((await upload(pat, hatEntry, gif)).ok, /new picture/);
|
||||
const gifArt = (await maker("info")).mine.find(entry => entry.kind === hatEntry.kind && entry.id === hatEntry.id).art;
|
||||
const gifServed = await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png?v=${gifArt}`);
|
||||
assert.strictEqual(gifServed.headers.get("content-type"), "image/gif");
|
||||
assert.ok(!Buffer.from(await gifServed.arrayBuffer()).includes(Buffer.from("Bob!")), "the GIF comment was left in");
|
||||
const bmp = Buffer.alloc(54 + 32 * 3 * 32);
|
||||
bmp.write("BM");
|
||||
bmp.writeUInt32LE(bmp.length, 2);
|
||||
bmp.writeUInt32LE(54, 10);
|
||||
bmp.writeUInt32LE(40, 14);
|
||||
bmp.writeInt32LE(32, 18);
|
||||
bmp.writeInt32LE(32, 22);
|
||||
bmp.writeUInt16LE(1, 26);
|
||||
bmp.writeUInt16LE(24, 28);
|
||||
assert.match((await upload(pat, hatEntry, bmp)).ok, /new picture/);
|
||||
const bmpArt = (await maker("info")).mine.find(entry => entry.kind === hatEntry.kind && entry.id === hatEntry.id).art;
|
||||
assert.strictEqual((await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png?v=${bmpArt}`)).headers.get("content-type"), "image/png");
|
||||
assert.match((await upload(pat, hatEntry, png(600))).error, /512 pixels/);
|
||||
assert.match((await upload(hal, hatEntry, png(16))).error, /not one of your items/);
|
||||
assert.match((await fetch(`${BASE}/api/itemart?kind=clothing&id=${hatEntry.id}`, {method: "POST", body: png(16)}).then(r => r.json())).error, /Sign in/);
|
||||
// a JPEG keeps its picture and loses its EXIF (where a photo was taken)
|
||||
const segment = (marker, data) => Buffer.concat([Buffer.from([0xFF, marker, (data.length + 2) >> 8, (data.length + 2) & 0xFF]), data]);
|
||||
const jpeg = Buffer.concat([Buffer.from([0xFF, 0xD8]), segment(0xE0, Buffer.from("JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00", "latin1")),
|
||||
segment(0xE1, Buffer.from("Exif\x00\x00GPS 51.5N 0.12W", "latin1")), segment(0xC0, Buffer.from([8, 0, 20, 0, 30, 1, 1, 0x11, 0])),
|
||||
segment(0xDA, Buffer.from([1, 1, 0, 0, 0x3F, 0])), Buffer.from([0x12, 0x34, 0xFF, 0xD9])]);
|
||||
assert.match((await upload(pat, hatEntry, jpeg)).ok, /new picture/);
|
||||
const jpegArt = (await maker("info")).mine.find(sameItem).art;
|
||||
const jpegBytes = Buffer.from(await (await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png?v=${jpegArt}`)).arrayBuffer());
|
||||
assert.ok(jpegBytes.includes(Buffer.from("JFIF")) && !jpegBytes.includes(Buffer.from("GPS")), "the EXIF was left in");
|
||||
assert.match((await upload(pat, hatEntry, Buffer.alloc(0), "&remove=1")).ok, /taken away/);
|
||||
assert.strictEqual((await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png`)).status, 404);
|
||||
assert.match((await upload(pat, hatEntry, png(24))).ok, /new picture/); // deleted with the item, below
|
||||
assert.match((await maker("rename", "clothing", hatEntry.id, "Party Hat")).said, /^Renamed it Party Hat\.$/);
|
||||
// how it is worn: a sticker by default, a texture when its maker says so, every game told
|
||||
pat.client.xt("xcm", pat.roomId, "look", "clothing", hatEntry.id, "texture");
|
||||
assert.strictEqual((await untilDefs(pat.client, "clothing"))[0].artMode, "texture");
|
||||
assert.strictEqual((await pat.client.untilXt("xcm"))[2], "1"); // its own answer, after every game was told
|
||||
const wornAs = await maker("info");
|
||||
assert.strictEqual(wornAs.mine.find(entry => entry.kind === "clothing" && entry.id === hatEntry.id).artMode, "texture");
|
||||
assert.match((await maker("look", "clothing", hatEntry.id, "melted")).said, /sticker or texture/);
|
||||
|
||||
// deleting: their own only, and gone from everyone
|
||||
assert.match((await maker("delete", "clothing", 50001)).said, /not one of your items/);
|
||||
for (const entry of full.mine) {
|
||||
assert.match((await maker("delete", entry.kind, entry.id)).said, /^Deleted /);
|
||||
}
|
||||
assert.deepStrictEqual((await maker("info")).mine, []);
|
||||
assert.strictEqual((await fetch(`${BASE}/itemart/clothing/${hatEntry.id}.png`)).status, 404);
|
||||
assert.strictEqual((await dev("/mod/api/items")).data.items.length, 3);
|
||||
|
||||
// --- the admin's switches: what players make waits for a moderator first,
|
||||
// out of the game till then; or the Item Maker is off
|
||||
assert.strictEqual((await admin("/admin/api/item-switches", {enabled: true, approval: true})).status, 200);
|
||||
const asked = await maker("make", "clothing", base.id, "Waiting Hat");
|
||||
assert.match(asked.said, /waiting for a moderator/);
|
||||
const waitingHat = asked.mine.find(entry => entry.name === "Waiting Hat");
|
||||
assert.strictEqual(waitingHat.waiting, "item");
|
||||
assert.ok(!(await searchAs(waitingHat.id)).some(entry => entry.id === waitingHat.id)); // not in the game yet
|
||||
const queue = (await admin("/admin/api/review")).data;
|
||||
assert.deepStrictEqual([queue.enabled, queue.approval, queue.waiting.map(entry => `${entry.name} ${entry.waiting} ${entry.maker}`)],
|
||||
[true, true, ["Waiting Hat item Pat"]]);
|
||||
assert.strictEqual((await dev("/mod/api/review")).status, 403); // a developer approves nothing
|
||||
assert.match((await admin("/admin/api/review", {kind: "clothing", id: waitingHat.id, approve: true})).data.ok, /in the game, and Pat has one/);
|
||||
for (;;) {
|
||||
const changed = await pat.client.untilXt("il");
|
||||
if (changed[2] === "2" && changed[10] === String(waitingHat.id)) { // given to Pat
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert.ok((await searchAs(waitingHat.id, patAs)).some(entry => entry.id === waitingHat.id));
|
||||
// a new picture waits too, and is not shown till then
|
||||
assert.match((await upload(pat, waitingHat, png(20))).ok, /waiting for a moderator/);
|
||||
assert.strictEqual((await maker("info")).mine.find(entry => entry.id === waitingHat.id && entry.kind === "clothing").waiting, "picture");
|
||||
assert.match((await admin("/admin/api/review", {kind: "clothing", id: waitingHat.id, approve: false})).data.ok,
|
||||
/picture was turned away\. Pat has had 1 of 3 pictures turned away\.$/);
|
||||
assert.strictEqual((await admin("/admin/api/review")).data.waiting.length, 0);
|
||||
// the same picture cannot come back; after three turned away, uploads stop
|
||||
assert.match((await upload(pat, waitingHat, png(20))).error, /turned that picture away before/);
|
||||
assert.match((await upload(pat, waitingHat, png(21))).ok, /waiting/);
|
||||
assert.match((await admin("/admin/api/review", {kind: "clothing", id: waitingHat.id, approve: false})).data.ok, /2 of 3/);
|
||||
assert.match((await upload(pat, waitingHat, png(22))).ok, /waiting/);
|
||||
assert.match((await admin("/admin/api/review", {action: "takePicture", kind: "clothing", id: waitingHat.id})).data.ok,
|
||||
/taken away\. That is 3 for Pat: their picture uploads are stopped\.$/);
|
||||
assert.match((await upload(pat, waitingHat, png(23))).error, /turned off picture uploads/);
|
||||
assert.deepStrictEqual((await admin("/admin/api/review")).data.stopped, ["Pat"]);
|
||||
assert.match((await admin("/admin/api/review", {action: "uploads", username: "Pat", blocked: false})).data.ok, /Pat can upload pictures again/);
|
||||
assert.match((await upload(pat, waitingHat, png(23))).ok, /waiting/);
|
||||
assert.match((await admin("/admin/api/review", {kind: "clothing", id: waitingHat.id, approve: true})).data.ok, /shown now/);
|
||||
// off: nothing is made
|
||||
assert.strictEqual((await admin("/admin/api/item-switches", {enabled: false, approval: false})).status, 200);
|
||||
assert.match((await maker("make", "clothing", base.id, "No Hat")).said, /turned off/);
|
||||
assert.strictEqual((await admin("/admin/api/item-switches", {enabled: true})).status, 200);
|
||||
assert.match((await maker("delete", "clothing", waitingHat.id)).said, /^Deleted /);
|
||||
|
||||
// written down under the maker's name
|
||||
const log = (await admin("/admin/api/moderators")).data.log.map(entry => `${entry.by} ${entry.action} ${entry.detail}`);
|
||||
for (const line of ["Dev item made clothing 50000 Test Crown", "Dev item made den 50000 Test Chair", "Dev item changed clothing 50000 Gold Crown",
|
||||
"Dev item made (in game) clothing 50001 Quick Hat"]) {
|
||||
"Dev item made (in game) clothing 50001 Quick Hat", "Dev item locked clothing 50001", "Dev item taken (in game) clothing 50001 x2",
|
||||
"Dev item taken den 50000 x1", "Dev item deleted clothing 50002"]) {
|
||||
assert.ok(log.includes(line), `missing from the log: ${line}\n${log.join("\n")}`);
|
||||
}
|
||||
made = {base};
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ const told = async client => (await client.untilXt("xtl"))[2];
|
||||
// logs in and asks for the township, as the game always does first.
|
||||
// returns where the server put them.
|
||||
const arrive = async username => {
|
||||
const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "Password01"})).json();
|
||||
const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "KettlePass01"})).json();
|
||||
const client = new harness.GameClient(GAME_PORT);
|
||||
await client.connect();
|
||||
const login = await client.logIn(username, auth.auth_token);
|
||||
@@ -36,7 +36,7 @@ const arrive = async username => {
|
||||
const run = async () => {
|
||||
for (const username of ["Ann", "Ben"]) {
|
||||
const response = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({username, password: "Password01", avatarType: 1, agreed: true})});
|
||||
body: JSON.stringify({username, password: "KettlePass01", avatarType: 1, agreed: true})});
|
||||
assert.strictEqual(response.status, 200);
|
||||
}
|
||||
let {client: a, login, roomId, room} = await arrive("Ann");
|
||||
@@ -190,7 +190,7 @@ const run = async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
// --- "start in your own den" (asked for at sign-in): the game asks for the township and is put in the den
|
||||
const denAuth = await (await postJson(`${BASE}/authenticate`, {username: "Ann", password: "Password01", login_choices: {startInDen: true}})).json();
|
||||
const denAuth = await (await postJson(`${BASE}/authenticate`, {username: "Ann", password: "KettlePass01", login_choices: {startInDen: true}})).json();
|
||||
const home = new harness.GameClient(GAME_PORT);
|
||||
await home.connect();
|
||||
await home.logIn("Ann", denAuth.auth_token);
|
||||
|
||||
+6
-6
@@ -38,9 +38,9 @@ const byId = (rows, id) => rows.find(row => String(row.id) === String(id));
|
||||
const run = async () => {
|
||||
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
|
||||
for (const username of ["Ann", "Ben"]) {
|
||||
assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200);
|
||||
assert.strictEqual((await registerJson({username, password: "KettlePass01"})).status, 200);
|
||||
}
|
||||
const {client: a, roomId} = await arrive("Ann", "Password01");
|
||||
const {client: a, roomId} = await arrive("Ann", "KettlePass01");
|
||||
|
||||
// --- Epic Dens: twenty names; asking for the den of one leads into its room
|
||||
a.xt("dh", roomId);
|
||||
@@ -147,7 +147,7 @@ const run = async () => {
|
||||
a.xt("di", den);
|
||||
assert.deepStrictEqual((await a.nextXt("di")).slice(13, 24), ["111", "222", "0", "333", "0", "0", "0", "0", "0", hat, "0"]);
|
||||
// A visitor is told what the hat is: its def and colour, then its id.
|
||||
const {client: b, roomId: benRoom} = await arrive("Ben", "Password01");
|
||||
const {client: b, roomId: benRoom} = await arrive("Ben", "KettlePass01");
|
||||
b.xt("dj", benRoom, "denAnn", 1, -1);
|
||||
const seen = await b.untilXt("ds");
|
||||
assert.deepStrictEqual(seen.slice(5), [mannequin, "3433", "1", "300", "400", "0", "0", "", "", "-1", "",
|
||||
@@ -177,8 +177,8 @@ const run = async () => {
|
||||
assert.strictEqual((await a.nextXt("di"))[22], "0");
|
||||
|
||||
// --- a player who is not in the game: their card still shows who they are
|
||||
assert.strictEqual((await registerJson({username: "Cat", password: "Password01"})).status, 200);
|
||||
const {client: c, roomId: catRoom} = await arrive("Cat", "Password01");
|
||||
assert.strictEqual((await registerJson({username: "Cat", password: "KettlePass01"})).status, 200);
|
||||
const {client: c, roomId: catRoom} = await arrive("Cat", "KettlePass01");
|
||||
c.xt("pc", catRoom, 312, 1, 0, 0, 15386, 15428, 0); // a pet, so there is one to list
|
||||
await c.untilXt("pc");
|
||||
c.socket.destroy();
|
||||
@@ -204,7 +204,7 @@ const run = async () => {
|
||||
const stamps = (await b.nextXt("gl")).slice(9);
|
||||
b.xt("es", benRoom, "Cat", cards[0], stamps[0], 0, "see you soon", 0, 0, 0);
|
||||
assert.strictEqual((await b.untilXt("es"))[2], "1");
|
||||
const {client: c2, login: catLogin, roomId: catRoom2} = await arrive("Cat", "Password01");
|
||||
const {client: c2, login: catLogin, roomId: catRoom2} = await arrive("Cat", "KettlePass01");
|
||||
assert.strictEqual(catLogin.params.numUnreadECards, 1);
|
||||
assert.deepStrictEqual((await c2.untilXt("ba")).slice(2), ["0", "Ben", "1"]); // asked, now that Cat is here
|
||||
c2.xt("bc", catRoom2, "Ben", 1);
|
||||
|
||||
+28
-24
@@ -28,29 +28,29 @@ const run = async () => {
|
||||
// --- registration: the web form's API, and no accounts made by logging in
|
||||
assert.match(await (await fetch(`${BASE}/register`)).text(), /Create an account/);
|
||||
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01"})).status, 401);
|
||||
assert.strictEqual((await registerJson({username: "Alice", password: "Password01"})).status, 200);
|
||||
assert.deepStrictEqual(await (await registerJson({username: "alice", password: "Password01"})).json(), {error: "username_taken"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "a!", password: "Password01"})).json(), {error: "invalid_username"});
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01"})).status, 401);
|
||||
assert.strictEqual((await registerJson({username: "Alice", password: "KettlePass01"})).status, 200);
|
||||
assert.deepStrictEqual(await (await registerJson({username: "alice", password: "KettlePass01"})).json(), {error: "username_taken"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "a!", password: "KettlePass01"})).json(), {error: "invalid_username"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Shorty", password: "pw"})).json(), {error: "invalid_password"});
|
||||
// no default animal: whoever signs up picks one of the nine on the page.
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: undefined})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: 2})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "KettlePass01", avatarType: undefined})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "KettlePass01", avatarType: 2})).json(), {error: "choose_animal"});
|
||||
assert.match(await (await fetch(`${BASE}/register`)).text(), /Choose an animal/);
|
||||
assert.strictEqual((await fetch(`${BASE}/signup/thumb_wolf.svg`)).headers.get("content-type"), "image/svg+xml");
|
||||
assert.strictEqual((await fetch(`${BASE}/signup/..%2Faccount.html`)).status, 404);
|
||||
for (const [username, password] of [["Bob", "Password02"], ["Carol", "Password03"], ["foo", "Password04"]]) {
|
||||
for (const [username, password] of [["Bob", "KettlePass02"], ["Carol", "KettlePass03"], ["foo", "KettlePass04"]]) {
|
||||
assert.strictEqual((await registerJson({username, password})).status, 200);
|
||||
}
|
||||
|
||||
let res = await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", domain: "flash", df: "x"});
|
||||
let res = await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01", domain: "flash", df: "x"});
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.headers.get("access-control-allow-origin"), "null");
|
||||
const alice = await res.json();
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "alice", password: "wrong"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "constructor", password: "Password01"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "constructor", password: "KettlePass01"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: alice.refresh_token})).status, 200);
|
||||
const bob = await (await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).json();
|
||||
const bob = await (await postJson(`${BASE}/authenticate`, {username: "Bob", password: "KettlePass02"})).json();
|
||||
|
||||
res = await fetch(`${BASE}/player?domain=flash&client_version=1830`, {headers: {Authorization: `Bearer ${alice.auth_token}`}});
|
||||
assert.strictEqual((await res.json()).screen_name, "Alice");
|
||||
@@ -83,11 +83,11 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await guest.nextXt("la")).slice(2), ["1"]);
|
||||
const iv = crypto.randomBytes(16);
|
||||
const cipher = crypto.createCipheriv("aes-256-cbc", crypto.createHash("sha256").update(guestKey).digest(), iv);
|
||||
const encrypted = Buffer.concat([iv, cipher.update("DavePass01"), cipher.final()]).toString("base64");
|
||||
const encrypted = Buffer.concat([iv, cipher.update("TulipKettle01"), cipher.final()]).toString("base64");
|
||||
guest.xt("lc", 1, "Dave", encrypted, "2000-01-01", 0, "", 15136, 15224, 15299, 4, 0, "US", 1830);
|
||||
assert.deepStrictEqual((await guest.nextXt("lc")).slice(2, 3), ["1"]);
|
||||
guest.socket.destroy();
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Dave", password: "TulipKettle01"})).status, 200);
|
||||
|
||||
// --- first player: login and world entry
|
||||
const a = new GameClient();
|
||||
@@ -158,6 +158,10 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await b.nextXt("uc")).slice(1), [roomId, String(bobId), "hi & bye", "0"]);
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[7%2]]></txt></body></msg>`); // emote: not echoed
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(3), ["7", "2"]);
|
||||
// Actions are sent to every other player in the room. The sender has
|
||||
// already applied the action locally, so it is not echoed back to them.
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[:sitS:%3%m1]]></txt></body></msg>`);
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(3), [":sitS:", "3", "m1"]);
|
||||
|
||||
// --- player cards
|
||||
a.xt("ag", roomId, "bob", 1);
|
||||
@@ -234,7 +238,7 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await a.nextXt("ds")).slice(2), ["0", "0", "1"]);
|
||||
|
||||
// --- shops, clothing, animals and pets (Carol watches from the same den)
|
||||
const carol = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "Password03"})).json();
|
||||
const carol = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "KettlePass03"})).json();
|
||||
const c = new GameClient();
|
||||
await c.connect();
|
||||
await c.logIn("Carol", carol.auth_token);
|
||||
@@ -394,7 +398,7 @@ const run = async () => {
|
||||
{
|
||||
const stranger = new GameClient();
|
||||
await stranger.connect();
|
||||
await stranger.logIn("Dave", (await (await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).json()).auth_token);
|
||||
await stranger.logIn("Dave", (await (await postJson(`${BASE}/authenticate`, {username: "Dave", password: "TulipKettle01"})).json()).auth_token);
|
||||
stranger.xt("dj", 1, "denAlice", 1, -1);
|
||||
assert.strictEqual((await stranger.nextXt("rj"))[2], "0");
|
||||
stranger.socket.destroy();
|
||||
@@ -429,7 +433,7 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await a.nextXt("di")).slice(3, 4), ["1"]);
|
||||
|
||||
// --- no game account has admin powers: "foo" is an ordinary player now
|
||||
const foo = await (await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).json();
|
||||
const foo = await (await postJson(`${BASE}/authenticate`, {username: "foo", password: "KettlePass04"})).json();
|
||||
const f = new GameClient();
|
||||
await f.connect();
|
||||
const fooLogin = await f.logIn("foo", foo.auth_token);
|
||||
@@ -521,14 +525,14 @@ const run = async () => {
|
||||
// names sign-up would refuse are fine from the panel, and can log in.
|
||||
for (const odd of ["x", "~*Bob*~ <3", "Ünïcødé 名前", "a name well past twenty characters"]) {
|
||||
assert.strictEqual((await panel("account", {username: "Bob", action: "rename", newName: odd}, admin)).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: odd, password: "Password02"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: odd, password: "KettlePass02"})).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: odd, action: "rename", newName: "Bob"}, admin)).status, 200);
|
||||
}
|
||||
assert.strictEqual((await registerJson({username: "x", password: "Password09"})).status, 400); // sign-up rules unchanged
|
||||
assert.strictEqual((await registerJson({username: "x", password: "KettlePass09"})).status, 400); // sign-up rules unchanged
|
||||
const renamed = await panel("account", {username: "Bob", action: "rename", newName: "Robert"}, admin);
|
||||
assert.deepStrictEqual([renamed.status, renamed.data.username], [200, "Robert"]);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "robert", password: "Password02"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Bob", password: "KettlePass02"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "robert", password: "KettlePass02"})).status, 200);
|
||||
assert.ok(!(await panel("accounts", undefined, admin)).data.accounts.some(account => account.username === "Bob"));
|
||||
assert.strictEqual((await panel("account", {username: "Robert", action: "rename", newName: "ROBERT"}, admin)).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: "robert", action: "rename", newName: "Bob"}, admin)).status, 200);
|
||||
@@ -536,7 +540,7 @@ const run = async () => {
|
||||
// A new password for a player: the old one and old tokens stop working.
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "short"}, admin)).status, 400);
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "New-password-4"}, admin)).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "KettlePass04"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: foo.refresh_token})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "New-password-4"})).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "delete"}, admin)).status, 200);
|
||||
@@ -624,13 +628,13 @@ const run = async () => {
|
||||
assert.strictEqual((await (await fetch(`${BASE}/flashvars`)).json()).loginChoices, true);
|
||||
// (a fresh account: Carol is banned by now, and a banned account's
|
||||
// sign-in is refused with "account_banned", so it gets no token.)
|
||||
assert.strictEqual((await registerJson({username: "Erin", password: "Password05"})).status, 200);
|
||||
const chosen = await (await postJson(`${BASE}/authenticate`, {username: "Erin", password: "Password05",
|
||||
assert.strictEqual((await registerJson({username: "Erin", password: "KettlePass05"})).status, 200);
|
||||
const chosen = await (await postJson(`${BASE}/authenticate`, {username: "Erin", password: "KettlePass05",
|
||||
login_choices: {accountType: 0, isGuide: true, membershipDays: 12, isModerator: "yes"}})).json();
|
||||
assert.strictEqual((await (await fetch(`${BASE}/player`, {headers: {Authorization: `Bearer ${chosen.auth_token}`}})).json()).game_account_type, 0);
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["0", "1"]); // account type, guide
|
||||
await postJson(`${BASE}/authenticate`, {username: "Erin", password: "Password05"}); // and back to normal
|
||||
await postJson(`${BASE}/authenticate`, {username: "Erin", password: "KettlePass05"}); // and back to normal
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["2", "0"]);
|
||||
|
||||
@@ -645,7 +649,7 @@ const run = async () => {
|
||||
assert.strictEqual((await a.untilXt("ap"))[2], "1");
|
||||
const late = new GameClient();
|
||||
await late.connect();
|
||||
const dev = await (await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", login_choices: {accountType: 4, membershipDays: 7}})).json();
|
||||
const dev = await (await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01", login_choices: {accountType: 4, membershipDays: 7}})).json();
|
||||
const devLogin = await late.logIn("Alice", dev.auth_token);
|
||||
assert.deepStrictEqual([devLogin.params.accountType, devLogin.params.numDaysLeftOnSubscription, devLogin.params.isGuide, devLogin.params.isModerator], [4, 7, false, false]);
|
||||
assert.deepStrictEqual((await late.untilXt("xcc")).slice(2, 4), ["1", String(0xFD000000)]); // the table at login
|
||||
|
||||
+87
-3
@@ -73,8 +73,14 @@ const arrive = async (username, password, room, totp, onLogin = async () => {})
|
||||
assert.strictEqual(login.status, "1");
|
||||
await onLogin(client);
|
||||
client.xt("rj", 1, room, 1, 0, 0);
|
||||
const rj = await client.untilXt("rj");
|
||||
let rj = await client.untilXt("rj");
|
||||
await client.untilXt("rp");
|
||||
// a session's first room is always a spawn room (lib/world.js joinRoom)
|
||||
if (rj[3] !== room) {
|
||||
client.xt("rj", rj[4], room, 1, 0, 0);
|
||||
rj = await client.untilXt("rj");
|
||||
await client.untilXt("rp");
|
||||
}
|
||||
client.xt("au", rj[4], 1, 400, 400, 14, 1);
|
||||
return {client, login, roomId: rj[4], room: rj[3]};
|
||||
};
|
||||
@@ -106,7 +112,7 @@ const untilChat = async (client, text) => {
|
||||
|
||||
const run = async () => {
|
||||
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
|
||||
const people = {Mira: "Password11", Hal: "Password12", Pip: "Password13", Ann: "Password14"};
|
||||
const people = {Mira: "KettlePass11", Hal: "KettlePass12", Pip: "KettlePass13", Ann: "KettlePass14"};
|
||||
for (const [username, password] of Object.entries(people)) {
|
||||
assert.strictEqual((await registerJson({username, password})).status, 200);
|
||||
}
|
||||
@@ -163,6 +169,8 @@ const run = async () => {
|
||||
|
||||
// summon: Pip is brought from Sarepia to Mira in the township
|
||||
say(mira.client, mira.roomId, "!summon Pip");
|
||||
// ... onto the spot where Mira stands, when the room has loaded ("xgt")
|
||||
assert.deepStrictEqual((await pip.client.untilXt("xgt")).slice(2), ["400", "400", "0"]);
|
||||
assert.strictEqual((await pip.client.untilXt("rj"))[3], TOWNSHIP);
|
||||
assert.strictEqual(await nextBox(mira.client), "Pip was brought here.");
|
||||
|
||||
@@ -179,7 +187,11 @@ const run = async () => {
|
||||
|
||||
// goto: Mira goes to Ann in Sarepia
|
||||
say(mira.client, mira.roomId, "!goto Ann");
|
||||
assert.deepStrictEqual((await mira.client.untilXt("xgt")).slice(2), ["400", "400", "0"]);
|
||||
assert.strictEqual((await mira.client.untilXt("rj"))[3], SAREPIA);
|
||||
// in the same room already: straight onto her
|
||||
say(mira.client, ann.roomId, "!goto Ann");
|
||||
assert.deepStrictEqual((await mira.client.untilXt("xgt")).slice(2), ["400", "400", "1"]);
|
||||
|
||||
// a warning: the game's own popup for the reason ("fw", 1 = bullying),
|
||||
// kept on the account; a message box; the count; then kick disconnects
|
||||
@@ -243,6 +255,22 @@ const run = async () => {
|
||||
assert.deepStrictEqual([pipPage.warningList[0].reason, pipPage.warningList[0].note, pipPage.warningList[0].by], ["scamming", "fake trade", "Mira"]);
|
||||
assert.strictEqual(pipPage.warningList[0].seen, true);
|
||||
|
||||
// mod notes: for staff, never the player; removed by their writer or an admin
|
||||
assert.strictEqual((await modPage("/mod/api/act", {username: "Pip", action: "note", text: " talked about trading, seemed fine "})).data.ok, "Note added.");
|
||||
assert.match((await modPage("/mod/api/act", {username: "Pip", action: "note", text: " "})).data.error, /Write the note first/);
|
||||
assert.strictEqual((await halPage("/mod/api/act", {username: "Pip", action: "note", text: "keeps asking for free items"})).data.ok, "Note added.");
|
||||
const notes = (await modPage("/mod/api/player?username=Pip")).data.notes;
|
||||
assert.deepStrictEqual(notes.map(note => `${note.by}: ${note.text}`), ["Hal: keeps asking for free items", "Mira: talked about trading, seemed fine"]);
|
||||
assert.match((await modPage("/mod/api/act", {username: "Pip", action: "deleteNote", id: notes[0].id})).data.error, /Only whoever wrote a note/);
|
||||
assert.strictEqual((await halPage("/mod/api/act", {username: "Pip", action: "deleteNote", id: notes[0].id})).data.ok, "Note removed.");
|
||||
assert.match((await halPage("/mod/api/act", {username: "Mira", action: "note", text: "x"})).data.error, /your rank or above/);
|
||||
say(mira.client, ann.roomId, "!note Pip asked about the rules");
|
||||
assert.strictEqual(await nextBox(mira.client), "Note on Pip added.");
|
||||
say(mira.client, ann.roomId, "!notes Pip");
|
||||
assert.match(await nextBox(mira.client), /^Notes on Pip: \S+ Mira: asked about the rules \| \S+ Mira: talked about trading, seemed fine$/);
|
||||
say(mira.client, ann.roomId, "!notes Nobody");
|
||||
assert.strictEqual(await nextBox(mira.client), "No player called Nobody.");
|
||||
|
||||
// warnings while away (Ann was disconnected): kept for her next visit;
|
||||
// the fifth in 30 days silences for a day; one is taken back
|
||||
assert.match((await modPage("/mod/api/act", {username: "Ann", action: "warn", reason: "bullying"})).data.ok,
|
||||
@@ -265,11 +293,67 @@ const run = async () => {
|
||||
assert.match((await modPage("/mod/api/act", {username: "Pip", action: "summon"})).data.ok || "", /^Pip was brought to /);
|
||||
assert.strictEqual((await pip.client.untilXt("rj"))[3], SAREPIA);
|
||||
|
||||
// a custom warning: the staff member's words are what the player sees
|
||||
mira.client.xt("xmd", ann.roomId, "warn", "Pip", "custom", "no spamming please");
|
||||
assert.deepStrictEqual((await untilPopup(pip.client, "fp")).slice(2, 4), ["fp", "Warning: no spamming please"]);
|
||||
assert.strictEqual(await nextBox(mira.client), "Pip warned (custom): warning 2.");
|
||||
say(mira.client, ann.roomId, "!warn Pip custom");
|
||||
assert.match(await nextBox(mira.client), /^Use: !warn PLAYER custom TEXT/);
|
||||
assert.match((await modPage("/mod/api/act", {username: "Pip", action: "warn", reason: "custom", note: " "})).data.error, /custom warning needs its words/);
|
||||
|
||||
// invisible: gone from players' screens, still seen by staff (half
|
||||
// see-through: "xiv"), and seen moving by them; not for a helper
|
||||
// ("ac": [.., room, id, x, y, anim, username, ...]; others' may be waiting)
|
||||
const untilDrawn = async (client, username, x) => {
|
||||
for (;;) {
|
||||
const fields = await client.untilXt("ac");
|
||||
if (fields[6] === username && fields[3] === x) {
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
};
|
||||
const untilRemoved = async (client, id) => {
|
||||
for (;;) {
|
||||
if ((await client.untilXt("ar"))[2] === id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
mira.client.xt("au", ann.roomId, 1, 300, 300, 14, 1);
|
||||
const miraId = (await untilDrawn(pip.client, "Mira", "300"))[2];
|
||||
hal.client.xt("rj", 1, SAREPIA, 1, 0, 0);
|
||||
const halRj = await hal.client.untilXt("rj");
|
||||
await hal.client.untilXt("rp");
|
||||
hal.client.xt("au", halRj[4], 1, 410, 410, 14, 1);
|
||||
await untilDrawn(hal.client, "Mira", "300");
|
||||
say(mira.client, ann.roomId, "!invisible");
|
||||
await untilRemoved(pip.client, miraId);
|
||||
assert.deepStrictEqual((await hal.client.untilXt("xiv")).slice(2), [miraId, "1"]);
|
||||
assert.deepStrictEqual((await mira.client.untilXt("xiv")).slice(2), [miraId, "1"]);
|
||||
assert.match(await nextBox(mira.client), /^You are invisible: only staff see you/);
|
||||
mira.client.xt("au", ann.roomId, 1, 350, 350, 14, 0);
|
||||
for (;;) {
|
||||
const moved = await hal.client.untilXt("au");
|
||||
if (moved[3] === miraId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// a helper may not: the window's request does nothing, the command is chat
|
||||
hal.client.xt("xiv", halRj[4]);
|
||||
say(hal.client, halRj[4], "!invisible");
|
||||
await untilChat(pip.client, "!invisible");
|
||||
// back again, where she walked to
|
||||
mira.client.xt("xiv", ann.roomId);
|
||||
assert.deepStrictEqual((await untilDrawn(pip.client, "Mira", "350")).slice(2, 5), [miraId, "350", "350"]);
|
||||
assert.deepStrictEqual((await hal.client.untilXt("xiv")).slice(2), [miraId, "0"]);
|
||||
assert.strictEqual(await nextBox(mira.client), "You can be seen again.");
|
||||
|
||||
// everything above is in the moderators' log, the in-game ones marked so
|
||||
const log = (await admin("/admin/api/moderators")).data.log.map(entry => `${entry.by} ${entry.action} ${entry.target}`);
|
||||
for (const line of ["Mira summon (in game) Pip", "Hal silence (in game) Pip", "Mira goto (in game) Ann", "Mira warn (in game) Ann",
|
||||
"Mira message (in game) Ann", "Mira kick (in game) Ann", "Mira warn Pip", "Mira summon Pip", "Mira warn Ann", "Mira unwarn Ann",
|
||||
"Mira unwarn (in game) Ann"]) {
|
||||
"Mira unwarn (in game) Ann", "Mira went invisible (in game) ", "Mira became visible (in game) ", "Mira note Pip", "Hal deleteNote Pip",
|
||||
"Mira note (in game) Pip"]) {
|
||||
assert.ok(log.includes(line), `missing from the log: ${line}\n${log.join("\n")}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user