fix(qzone): delete_v6 uses format=fs, drop bogus json param, harden success check
Adversarial review (NEEDS-FIXES) — two wrong-constant defects (same family as the publish t1_tid bug) + a destructive-write hardening: - format=json → format=fs. Every working reference (silica-github/ qq_zone_delete, zhihu, daimagongfang) uses fs for the delete CGI; the tests re-codified the wrong value. - Removed the invented json=1 body param (no source includes it); test now asserts it's absent. - Also throw on a non-zero subcode (not just code), and documented that the code/subcode success signal is EXTRAPOLATED from sibling CGIs pending a live capture (public delete impls only check HTTP 2xx). Added subcode-throw and code-absent-resolves tests to lock the branch.
This commit is contained in:
2 files changed
+31
-4
No files matched your search
@@ -247,7 +247,10 @@ describe('qzone / publishQzoneMsg (HTTP layer)', () => {
|
||||
describe('qzone / deleteQzoneMsg (HTTP layer)', () => {
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
it('POSTs the tid form body to the proxied delete CGI and resolves on code 0', async () => {
|
||||
it('POSTs the tid form body (format=fs) to the proxied delete CGI and resolves on code 0', async () => {
|
||||
// NB: the success-body shape is a guess extrapolated from sibling CGIs —
|
||||
// no public delete impl parses the response — so this mock pins our
|
||||
// success contract, not a verified server envelope (see helper comment).
|
||||
const spy = vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":0,"subcode":0,"message":""}');
|
||||
|
||||
await expect(deleteQzoneMsg(cookies, '10000', 'TID123')).resolves.toBeUndefined();
|
||||
@@ -263,7 +266,9 @@ describe('qzone / deleteQzoneMsg (HTTP layer)', () => {
|
||||
const form = new URLSearchParams(body as string);
|
||||
expect(form.get('tid')).toBe('TID123');
|
||||
expect(form.get('hostuin')).toBe('10000');
|
||||
expect(form.get('format')).toBe('json');
|
||||
// delete_v6 wants format=fs (NOT json), per the working community script
|
||||
expect(form.get('format')).toBe('fs');
|
||||
expect(form.get('json')).toBeNull(); // no bogus json param
|
||||
});
|
||||
|
||||
it('rejects an empty tid before any request', async () => {
|
||||
@@ -276,4 +281,14 @@ describe('qzone / deleteQzoneMsg (HTTP layer)', () => {
|
||||
vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":-4001,"message":"no permission"}');
|
||||
await expect(deleteQzoneMsg(cookies, '10000', 'TID123')).rejects.toThrow('code=-4001');
|
||||
});
|
||||
|
||||
it('throws on a non-zero subcode even when code is 0', async () => {
|
||||
vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":0,"subcode":-12,"message":"sub error"}');
|
||||
await expect(deleteQzoneMsg(cookies, '10000', 'TID123')).rejects.toThrow('subcode=-12');
|
||||
});
|
||||
|
||||
it('resolves when neither code nor subcode is present (extrapolated success branch)', async () => {
|
||||
vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"message":""}');
|
||||
await expect(deleteQzoneMsg(cookies, '10000', 'TID123')).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user