forked from mtusi2026/mtusi2026lab7
166 lines
12 KiB
Plaintext
166 lines
12 KiB
Plaintext
Running as unit: run-p4137786-i25079307.scope; invocation ID: 33f1824ec2a04055b1b2555590a2845b
|
|
bun test v1.4.4 (38afee6c8)
|
|
|
|
student-tests/openobserve-accounts.test.ts:
|
|
4 | create: (path: string, body: {email: string; first_name: string; last_name: string}) => Promise<{status: number; data: unknown}>;
|
|
5 | save: (principal: Principal, account: Account) => Promise<void>;
|
|
6 | }
|
|
7 | export function createAccountProvisioner(ports: AccountPorts) {
|
|
8 | if(typeof ports.create!=="function" || typeof ports.save!=="function")throw new Error("OPENOBSERVE_ACCOUNT_PORTS_REQUIRED");
|
|
9 | return async (principal: Principal): Promise<Account> => { throw new Error("OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"); };
|
|
^
|
|
error: OPENOBSERVE_ACCOUNT_UNIMPLEMENTED
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/scripts/openobserve-accounts.ts:9:72)
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:7:15)
|
|
(fail) native service-account success saves exact credential before returning without a human-user API [0.31ms]
|
|
7 | expect(await provision("query")).toEqual({user:native.user,token:native.token});
|
|
8 | expect(events).toEqual(["/api/default/service_accounts","saved:query"]);
|
|
9 | });
|
|
10 | for(const status of [401,403,500])test(`native HTTP${status} never publishes an account`,async()=>{
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_CREATE_REJECTED"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:12:43)
|
|
(fail) native HTTP401 never publishes an account [0.18ms]
|
|
7 | expect(await provision("query")).toEqual({user:native.user,token:native.token});
|
|
8 | expect(events).toEqual(["/api/default/service_accounts","saved:query"]);
|
|
9 | });
|
|
10 | for(const status of [401,403,500])test(`native HTTP${status} never publishes an account`,async()=>{
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_CREATE_REJECTED"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:12:43)
|
|
(fail) native HTTP403 never publishes an account [0.04ms]
|
|
7 | expect(await provision("query")).toEqual({user:native.user,token:native.token});
|
|
8 | expect(events).toEqual(["/api/default/service_accounts","saved:query"]);
|
|
9 | });
|
|
10 | for(const status of [401,403,500])test(`native HTTP${status} never publishes an account`,async()=>{
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_CREATE_REJECTED"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:12:43)
|
|
(fail) native HTTP500 never publishes an account [0.03ms]
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
13 | });
|
|
14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_INVALID_RESPONSE"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:16:43)
|
|
(fail) invalid native result fails closed code 3 [0.12ms]
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
13 | });
|
|
14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_INVALID_RESPONSE"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:16:43)
|
|
(fail) invalid native result fails closed token 0 [0.04ms]
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
13 | });
|
|
14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_INVALID_RESPONSE"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:16:43)
|
|
(fail) invalid native result fails closed token 4097 [0.03ms]
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
13 | });
|
|
14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_INVALID_RESPONSE"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:16:43)
|
|
(fail) invalid native result fails closed user 23 [0.03ms]
|
|
11 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status,data:native}),save:async()=>{saves++}});
|
|
12 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_CREATE_REJECTED");expect(saves).toBe(0);
|
|
13 | });
|
|
14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
^
|
|
error: expect(received).toThrow(expected)
|
|
|
|
Expected substring: "OPENOBSERVE_ACCOUNT_INVALID_RESPONSE"
|
|
Received message: "OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:16:43)
|
|
(fail) invalid native result fails closed token 4 [0.03ms]
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
17 | });
|
|
18 | test("account persistence failure stays primary and prevents a success result",async()=>{
|
|
19 | const failure=new Error("FIXTURE_STORAGE_FAILED");const provision=createAccountProvisioner({create:async()=>({status:200,data:native}),save:async()=>{throw failure}});
|
|
20 | try{await provision("query");throw new Error("UNEXPECTED_SUCCESS")}catch(error){expect(error).toBe(failure)}
|
|
^
|
|
error: expect(received).toBe(expected)
|
|
|
|
Expected: 14 | for(const patch of [{code:403},{token:""},{token:"x".repeat(4097)},{user:"foreign@example.invalid"},{token:null}])test(`invalid native result fails closed ${Object.keys(patch)[0]} ${String(Object.values(patch)[0]).length}`,async()=>{
|
|
15 | let saves=0;const provision=createAccountProvisioner({create:async()=>({status:200,data:{...native,...patch}}),save:async()=>{saves++}});
|
|
16 | await expect(provision("query")).rejects.toThrow("OPENOBSERVE_ACCOUNT_INVALID_RESPONSE");expect(saves).toBe(0);
|
|
17 | });
|
|
18 | test("account persistence failure stays primary and prevents a success result",async()=>{
|
|
19 | const failure=new Error("FIXTURE_STORAGE_FAILED");const provision=createAccountProvisioner({create:async()=>({status:200,data:native}),save:async()=>{throw failure}});
|
|
^
|
|
error: FIXTURE_STORAGE_FAILED
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:19:20)
|
|
|
|
Received: 4 | create: (path: string, body: {email: string; first_name: string; last_name: string}) => Promise<{status: number; data: unknown}>;
|
|
5 | save: (principal: Principal, account: Account) => Promise<void>;
|
|
6 | }
|
|
7 | export function createAccountProvisioner(ports: AccountPorts) {
|
|
8 | if(typeof ports.create!=="function" || typeof ports.save!=="function")throw new Error("OPENOBSERVE_ACCOUNT_PORTS_REQUIRED");
|
|
9 | return async (principal: Principal): Promise<Account> => { throw new Error("OPENOBSERVE_ACCOUNT_UNIMPLEMENTED"); };
|
|
^
|
|
error: OPENOBSERVE_ACCOUNT_UNIMPLEMENTED
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/scripts/openobserve-accounts.ts:9:72)
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:20:12)
|
|
|
|
|
|
at <anonymous> (/mnt/data/home/bench-saves/mtuci-vp7-security-20261115/student-tests/openobserve-accounts.test.ts:20:96)
|
|
(fail) account persistence failure stays primary and prevents a success result [0.16ms]
|
|
|
|
0 pass
|
|
10 fail
|
|
9 expect() calls
|
|
Ran 10 tests across 1 file. [5.00ms]
|