♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-16 14:07:45 +08:00
1 parent 0907702861
commit b45d47aea5
8 files changed
+38 -38

No files matched your search

+28 -28
View File
@@ -159,16 +159,16 @@ do
end
package.loaded["moonsource_xiaoxiang.client"] = nil
local Settings = require("utils.settings")
local cfg = Settings.getSource("ext.xiaoxiang")
local cfg = Settings.getSource("xiaoxiang")
cfg.cookie = "csrfToken=C1; ywKey=K"
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
local Client = require("moonsource_xiaoxiang.client")
require("source.auth").reset()
seen.reply = '{"code":0,"data":{"isLogin":0}}'
local err
Client.shelfRemoveAsync("35554414603847007", function(_wire, e) err = e end)
Assert.is_true(require("source.auth").expired("ext.xiaoxiang"))
Assert.is_true(require("source.auth").expired("xiaoxiang"))
Assert.is_nil(seen.post_url)
seen.reply = '{"code":0,"data":{"isLogin":1,"user":{"guid":"42"}}}'
@@ -210,7 +210,7 @@ do
Assert.is_true(ok)
Assert.eq(n, 1, "校验结果复用")
cfg.cookie = "csrfToken=C2; ywKey=K2"
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
Client.shelfRemoveAsync("35554414603847007", function(wire) ok = wire ~= nil end)
Assert.eq(n, 2, "换了 Cookie 重新校验")
Client.AUTH_TTL = 0
@@ -231,7 +231,7 @@ do
.. '"fontResponse":{"fixedFontTtf":"https://cdn.test/f.ttf"}}]}}'
replies[1] = "<html>Not Found</html>"
cfg.cookie = "csrfToken=C1; ywKey=K; ywGuid=42"
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
local fock_called = false
package.loaded["moonsource_xiaoxiang.fock"] = { chapterAsync = function() fock_called = true; return { cancel = function() end } end }
local ferr
@@ -242,7 +242,7 @@ do
Assert.is_false(fock_called, "坏字体不进解密")
package.loaded["moonsource_xiaoxiang.fock"] = nil
cfg.cookie = nil
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
package.loaded["moonsource_xiaoxiang.client"] = nil
end
@@ -252,18 +252,18 @@ do
Assert.eq(CpSetting.parseCookie(" "), "")
local Settings = require("utils.settings")
local Auth = require("source.auth")
local cfg = Settings.getSource("ext.changpei")
local cfg = Settings.getSource("changpei")
Auth.reset()
cfg.cookie = nil
Settings.saveSource("ext.changpei", cfg)
Settings.saveSource("changpei", cfg)
Assert.eq(#CpSetting.rows(), 4, "未登录:账号 + 浏览器 + 粘贴 + 章评")
cfg.cookie = "PHPSESSID=T1"
Settings.saveSource("ext.changpei", cfg)
Settings.saveSource("changpei", cfg)
Assert.eq(#CpSetting.rows(), 5, "已登录:账号 + 浏览器 + 粘贴 + 退出 + 章评")
Auth.expire("ext.changpei", "x")
Auth.expire("changpei", "x")
Assert.eq(#CpSetting.rows(), 5, "失效后仍保留浏览器与粘贴入口")
cfg.cookie = nil
Settings.saveSource("ext.changpei", cfg)
Settings.saveSource("changpei", cfg)
Auth.reset()
local XxSetting = require("moonsource_xiaoxiang.setting")
@@ -279,9 +279,9 @@ do
end
package.loaded["moonsource_changpei.client"] = nil
local Settings = require("utils.settings")
local cfg = Settings.getSource("ext.changpei")
local cfg = Settings.getSource("changpei")
cfg.cookie = "PHPSESSID=T1"
Settings.saveSource("ext.changpei", cfg)
Settings.saveSource("changpei", cfg)
local Client = require("moonsource_changpei.client")
local Auth = require("source.auth")
Auth.reset()
@@ -290,13 +290,13 @@ do
Assert.eq(seen.cookie, "PHPSESSID=T1")
Assert.eq(seen.headers.Client, "pc")
Assert.matches(err, "扫码登录")
Assert.is_true(Auth.expired("ext.changpei"))
Assert.is_true(Auth.expired("changpei"))
cfg.cookie = nil
Settings.saveSource("ext.changpei", cfg)
Settings.saveSource("changpei", cfg)
Auth.reset()
Client.searchAsync("x", function() end)
Assert.is_nil(seen.cookie)
Assert.is_true(not Auth.expired("ext.changpei"))
Assert.is_true(not Auth.expired("changpei"))
package.preload["http.request"] = nil
end
@@ -416,7 +416,7 @@ do
local Client = require("moonsource_changpei.client")
local Auth = require("source.auth")
local settings = require("utils.settings")
settings.saveSource("ext.changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD; moon_refresh=RF" })
settings.saveSource("changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD; moon_refresh=RF" })
Auth.reset()
local wire
@@ -424,25 +424,25 @@ do
Assert.not_nil(wire)
Assert.eq(renew_calls, 1)
Assert.eq(tokens[#tokens], "NEW1")
Assert.matches(settings.getSource("ext.changpei").cookie, "moon_token=NEW1")
Assert.matches(settings.getSource("ext.changpei").cookie, "moon_refresh=RF")
Assert.is_false(Auth.expired("ext.changpei"))
Assert.matches(settings.getSource("changpei").cookie, "moon_token=NEW1")
Assert.matches(settings.getSource("changpei").cookie, "moon_refresh=RF")
Assert.is_false(Auth.expired("changpei"))
settings.saveSource("ext.changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD; moon_refresh=RF" })
settings.saveSource("changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD; moon_refresh=RF" })
grpc_status = "16"
local failed
Client.historyAsync(function(w, err) failed = { w, err } end)
Assert.is_nil(failed[1])
Assert.matches(failed[2], "moon%-cookie%-storage")
Assert.is_true(Auth.expired("ext.changpei"))
Assert.is_true(Auth.expired("changpei"))
settings.saveSource("ext.changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD" })
settings.saveSource("changpei", { cookie = "PHPSESSID=a; _c_n_=dev; moon_token=OLD" })
Auth.reset()
renew_calls = 0
Client.historyAsync(function() end)
Assert.eq(renew_calls, 0, "没有 refresh_token 不请求")
Assert.is_true(Auth.expired("ext.changpei"))
settings.saveSource("ext.changpei", {})
Assert.is_true(Auth.expired("changpei"))
settings.saveSource("changpei", {})
Auth.reset()
package.preload["http.request"] = nil
end
@@ -523,9 +523,9 @@ do
}
end
local Settings = require("utils.settings")
local cfg = Settings.getSource("ext.xiaoxiang")
local cfg = Settings.getSource("xiaoxiang")
cfg.cookie = "csrfToken=C1; ywKey=K"
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
package.loaded["moonsource_xiaoxiang.client"] = nil
local Deep = require("moonsource_xiaoxiang.client")
require("source.auth").reset()
@@ -535,7 +535,7 @@ do
Assert.len(rows, 60)
Assert.eq(pages, 60)
cfg.cookie = nil
Settings.saveSource("ext.xiaoxiang", cfg)
Settings.saveSource("xiaoxiang", cfg)
package.loaded["moonsource_xiaoxiang.client"] = nil
package.preload["http.request"] = nil
end
+3 -3
View File
@@ -44,17 +44,17 @@ network = "failure"
C.shelfAsync(function(value, reason) result, err = value, reason end)
A.is_nil(result)
A.eq(err, "timeout")
A.is_false(Auth.expired("ext.xiaoxiang"), "暂时网络失败保留登录")
A.is_false(Auth.expired("xiaoxiang"), "暂时网络失败保留登录")
network = "expired"
C.shelfAsync(function(value, reason) result, err = value, reason end)
A.is_true(Auth.expired("ext.xiaoxiang"))
A.is_true(Auth.expired("xiaoxiang"))
A.eq(posts, 0)
Auth.reset()
network = "wait"
C.shelfAsync(function(value, reason) result, err = value, reason end)
cfg.cookie = "csrfToken=new; ywguid=43"
pending('{"code":0,"data":{"isLogin":0}}')
A.is_false(Auth.expired("ext.xiaoxiang"), "旧请求不能注销新账号")
A.is_false(Auth.expired("xiaoxiang"), "旧请求不能注销新账号")
A.eq(err, "账号已变化,请重新登录")
cfg.cookie = "csrfToken=x%26; ywguid=42"
network, cancelled, info = "wait", false, nil
+1 -1
View File
@@ -28,7 +28,7 @@ function source:loadTocAsync(_identity, cb)
if not delayed then cb(toc) end
return { cancel = function() stopped = true end }
end
local identity = { source_id = "ext.xiaoxiang", stable_id = "123" }
local identity = { source_id = "xiaoxiang", stable_id = "123" }
local result, err
source:getProgressAsync(identity, function(data) result = data end)
A.eq(result.chapter_idx, 2)
+1 -1
View File
@@ -24,7 +24,7 @@ end
package.preload["reader.session"] = function() return { current = function() return nil end } end
package.preload["book.books_db"] = function()
return { prepareAccountSync = function(id, shelf_add)
Assert.eq(id, "ext.xiaoxiang")
Assert.eq(id, "xiaoxiang")
Assert.is_true(shelf_add)
Assert.eq(cfg.cookie, "session=old")
prepared = prepared + 1