fix: bind qdreader cookies to real autman user
This commit is contained in:
@@ -22,6 +22,7 @@ function runPlugin({ content = '', store = {}, bucketStore = {}, requests = [],
|
||||
console,
|
||||
Buffer,
|
||||
sender: { ...baseSender, ...senderOverrides },
|
||||
GetUserID: () => userId,
|
||||
GetContent: () => content,
|
||||
getContent: () => content,
|
||||
get: (key) => store[key] || '',
|
||||
@@ -142,6 +143,18 @@ test('mis-keyed ywguid remark is migrated to saved uid on account list', () => {
|
||||
assert.equal(JSON.parse(r.store.qdreader_remark_json)['120098575768'], undefined);
|
||||
});
|
||||
|
||||
test('quick submit can bind user from official global GetUserID', () => {
|
||||
const r = runPlugin({
|
||||
content: '启点ck ' + cookie,
|
||||
userId: '',
|
||||
senderOverrides: { getUserID: undefined },
|
||||
globals: { GetUserID: () => 'official-100' },
|
||||
listens: ['n'],
|
||||
});
|
||||
assert.match(r.replies.join('\n'), /CK新增成功/);
|
||||
assert.equal(JSON.parse(r.store.qdreader_user_bind_json)['12345'], 'official-100');
|
||||
});
|
||||
|
||||
test('quick submit can bind user from alternate Autman sender fields', () => {
|
||||
const r = runPlugin({
|
||||
content: '启点ck ' + cookie,
|
||||
@@ -153,16 +166,17 @@ test('quick submit can bind user from alternate Autman sender fields', () => {
|
||||
assert.equal(JSON.parse(r.store.qdreader_user_bind_json)['12345'], 'sender-42');
|
||||
});
|
||||
|
||||
test('quick submit uses default local owner when Autman JS has no user identity', () => {
|
||||
test('quick submit rejects save when Autman JS has no user identity', () => {
|
||||
const r = runPlugin({
|
||||
content: '启点ck ' + cookie,
|
||||
userId: '',
|
||||
senderOverrides: { getUserID: undefined },
|
||||
globals: { GetUserID: undefined },
|
||||
listens: ['n'],
|
||||
});
|
||||
assert.match(r.replies.join('\n'), /CK新增成功/);
|
||||
assert.doesNotMatch(r.replies.join('\n'), /无法识别当前用户/);
|
||||
assert.equal(JSON.parse(r.store.qdreader_user_bind_json)['12345'], '__qdreader_default_owner__');
|
||||
assert.match(r.replies.join('\n'), /无法识别当前用户/);
|
||||
assert.doesNotMatch(r.replies.join('\n'), /CK新增成功/);
|
||||
assert.equal(r.store.qdreader_user_bind_json, undefined);
|
||||
});
|
||||
|
||||
test('manual sign and cron sign both call sign gateway then qidian checkin', () => {
|
||||
@@ -189,7 +203,7 @@ test('manual sign and cron sign both call sign gateway then qidian checkin', ()
|
||||
assert.equal(JSON.parse(cron.store.qdreader_last_run_json).source, 'cron');
|
||||
});
|
||||
|
||||
test('bucketGet/bucketSet fallback saves with default owner when user identity is absent', () => {
|
||||
test('bucketGet/bucketSet fallback rejects when user identity is absent', () => {
|
||||
const replies = [];
|
||||
const bucketStore = {};
|
||||
const ctx = {
|
||||
@@ -202,9 +216,9 @@ test('bucketGet/bucketSet fallback saves with default owner when user identity i
|
||||
};
|
||||
vm.createContext(ctx);
|
||||
vm.runInContext(code, ctx, { filename: pluginPath });
|
||||
assert.match(replies.join('\n'), /CK新增成功/);
|
||||
assert.equal(JSON.parse(bucketStore['hermes_qidian.qdreader_cookie_json'])['12345'], cookie);
|
||||
assert.equal(JSON.parse(bucketStore['hermes_qidian.qdreader_user_bind_json'])['12345'], '__qdreader_default_owner__');
|
||||
assert.match(replies.join('\n'), /无法识别当前用户/);
|
||||
assert.equal(bucketStore['hermes_qidian.qdreader_cookie_json'], undefined);
|
||||
assert.equal(bucketStore['hermes_qidian.qdreader_user_bind_json'], undefined);
|
||||
});
|
||||
|
||||
test('hermes_qidian bucket values are read and written without legacy bucket fallback', () => {
|
||||
|
||||
Reference in New Issue
Block a user