provider: a remote magpie that holds this key says so, where its Claude card went missing with no word (yi_time on Discord)
yi_time on Discord: "没变化 还是不显示通过局域网添加的Claude额度".c7bbd3faf(v0.1.2908) drew a Remote magpie's cards on Routing. It did not cover a remote that answers 403 gateway_key_held. That is a key held to a budget, models or accounts there, without the key's Quotas on (#1981, #2216). For such a key, keepRemoteCards dropped the cards and remoteCards returned nothing. The remote's Claude then vanished from Usage, the tray panel and Routing, with no reason shown anywhere; only the key's own Limit card stayed. The remote's own card now carries errRemoteHeld. quotaError words it as "That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there", in en, zh, zh-TW, ja and de. Routing's existing "Allowance unavailable — hover for why" shows it too. A failed read since the hold (unreachable, refused) still leads with that read's own error. Only the computer that shows the quota needs this release. The computer that holds the account needs nothing new, but its owner turns on Quotas for the key, or lifts the key's hold. app.js pays for its one line with four quotaError comments cut. The core weighs 1,534,001 against 1,534,022 on origin/main, so it grows nothing and raises no budget. TestCoreScriptBudget stays red as on main (#5139, owned there). Run (mote, worktree on origin/main69eb93e0a): - Real two-magpie repro, sandbox HOMEs. A (old binary) on 3561/3562 had a Claude account and LAN on. B (this change) on 3571/3572 added A with `provider add remote-magpie <key> url=http://<lan ip>:3561`. A's key was held to claude/* models. - Before: B's Usage, panel and Routing had no Claude card and no reason. - After: Usage and the panel's Allowances show the new line; Routing shows "Allowance unavailable — hover for why". - With `gateway-key quotas <id> on` on A: B shows remote-magpie/claude, 5 hours 40%, 7 days 12%. - go test -run 'Remote|Quota' ./internal/provider: ok. gofmt -l clean. GOOS=windows and GOOS=linux go vet ./internal/provider: ok. - usage-remote-cards.test.cjs (now en, zh, zh-TW, ja, de; chromium and webkit) and i18n-keys.test.cjs: 14 of 14 pass. Broken by hand: - remoteCards' held branch put back: TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard red with 3 errors. - quotaError's new line removed: usage-remote-cards went 0 pass, 5 fail. Not tried: yi_time's own two computers, a real Claude account on the remote (the repro's account is a fake token with a kept reading), the Windows and Linux app engines (WebView2, WebKitGTK). Whether yi_time's key is held is not known. Sibling, filed rather than changed here: with Quotas on and a key held to only some of a provider's models, the remote answers [] and this side says "Nothing read on that computer yet" (#5217).
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -13577,14 +13577,10 @@ function loginUsageOf(agent) {
|
||||
const SIGN_IN_GONE = /sign-in has (expired|lapsed)|sign in again/i;
|
||||
|
||||
function quotaError(err, q) {
|
||||
// first-run screens the helper can't pass (#4817)
|
||||
if (/^Claude Code: claude-tui: .{0,40}(stays on its first-run screens|shows its first-run notes)/.test(err)) return t("Finish Claude Code's first-run setup, then refresh. Run magpie claude-code to find its executable.");
|
||||
// the /usage helper's other reasons, on the card (#4830)
|
||||
const tui = /^Claude Code: claude-tui: (.+?)(?:: |$)/m.exec(err) || /^(Claude Code's interactive mode said nothing[^(]*?) \(/.exec(err);
|
||||
if (tui) return t("Allowance unavailable: {why}", { why: tui[1].slice(0, 160) });
|
||||
// signed in again in place from the row's Sign in again (blue12345655)
|
||||
if (/sign-in has expired/.test(err)) return t("Signed out — choose Sign in again on this account under Providers");
|
||||
// Copilot's refused token (copilot_lapsed.go), in either language
|
||||
const copilotLapsed = "GitHub refused this Copilot sign-in; sign in again";
|
||||
if (err === copilotLapsed || err === t(copilotLapsed)) return t(copilotLapsed);
|
||||
// an account whose sign-in its vendor revoked (signin_revoked.go, #1793)
|
||||
@@ -13611,6 +13607,7 @@ function quotaError(err, q) {
|
||||
if (/^nothing read on that magpie yet/.test(err)) return t("Nothing read on that computer yet — refresh this card to have it read");
|
||||
if (/^remote magpie doesn't share its quotas/.test(err)) return t("That computer's magpie doesn't share its quotas yet — update magpie there");
|
||||
if (/^remote magpie isn't shared/.test(err)) return t("That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there");
|
||||
if (/^remote magpie tells this key none of its quotas/.test(err)) return t("That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there");
|
||||
if (/^remote magpie didn't take this key/.test(err)) return t("That computer's magpie didn't take this key — use one of its gateway keys in this provider");
|
||||
if (/^couldn't reach the remote magpie/.test(err)) return t("Couldn't reach that computer's magpie — check that it is running and its address");
|
||||
// a remote magpie's gateway key card (#1547, remote_key_limits.go)
|
||||
|
||||
@@ -3303,6 +3303,7 @@ const I18N = {
|
||||
"That computer's magpie doesn't share its quotas yet — update magpie there": "那台电脑的 magpie 还不能共享额度 — 请在那台电脑上更新 magpie",
|
||||
"That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there": "那台电脑的 magpie 没有共享 — 请在那台电脑上打开 设置 → 网络与共享 → 局域网共享",
|
||||
"That computer's magpie didn't take this key — use one of its gateway keys in this provider": "那台电脑的 magpie 不认这个密钥 — 请在这个服务商里填它的一个网关密钥",
|
||||
"That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there": "那台电脑的 magpie 不向这个密钥显示额度:那边给它限定了预算、模型或账号 — 请在那台电脑的「网关密钥」里打开这个密钥的「额度」",
|
||||
"Couldn't reach that computer's magpie — check that it is running and its address": "连不上那台电脑的 magpie — 请确认它在运行、地址正确",
|
||||
"The magpie on {computer}, where this account is signed in, uses it.": "由 {computer} 上的 magpie 使用,这个账号登录在那里。",
|
||||
"This key is read-only on that computer's magpie — give this provider a key with full access to use a reset from here": "这个密钥在那台电脑的 magpie 上是只读的 — 想在这里使用重置,请给这个服务商填一个完全权限的密钥",
|
||||
@@ -7864,6 +7865,7 @@ const I18N = {
|
||||
"That computer's magpie doesn't share its quotas yet — update magpie there": "那臺電腦的 magpie 還不能共享額度 — 請在那臺電腦上更新 magpie",
|
||||
"That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there": "那臺電腦的 magpie 沒有共享 — 請在那臺電腦上開啟 設定 → 網路與共享 → 區域網共享",
|
||||
"That computer's magpie didn't take this key — use one of its gateway keys in this provider": "那臺電腦的 magpie 不認這個金鑰 — 請在這個服務商裡填它的一個閘道金鑰",
|
||||
"That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there": "那臺電腦的 magpie 不向這個金鑰顯示額度:那邊給它限定了預算、模型或帳號 — 請在那臺電腦的「閘道金鑰」裡打開這個金鑰的「額度」",
|
||||
"Couldn't reach that computer's magpie — check that it is running and its address": "連不上那臺電腦的 magpie — 請確認它在執行、位址正確",
|
||||
"The magpie on {computer}, where this account is signed in, uses it.": "由 {computer} 上的 magpie 使用,這個帳號登入在那裡。",
|
||||
"This key is read-only on that computer's magpie — give this provider a key with full access to use a reset from here": "這個密鑰在那臺電腦的 magpie 上是唯讀的 — 想在這裡使用重置,請給這個供應商填一個完整權限的密鑰",
|
||||
@@ -12429,6 +12431,7 @@ const I18N = {
|
||||
"That computer's magpie doesn't share its quotas yet — update magpie there": "そのコンピューターの magpie はまだ利用枠を共有できません — そちらの magpie を更新してください",
|
||||
"That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there": "そのコンピューターの magpie は共有されていません — そちらで 設定 → ネットワークと共有 → ローカルネットワークで共有 をオンにしてください",
|
||||
"That computer's magpie didn't take this key — use one of its gateway keys in this provider": "そのコンピューターの magpie はこのキーを受け付けませんでした — このプロバイダーにそちらのゲートウェイキーを入れてください",
|
||||
"That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there": "そのコンピューターの magpie はこのキーに利用枠を伝えません:そちらで予算・モデル・アカウントが制限されています — そちらの「ゲートウェイキー」でこのキーの「残量」をオンにしてください",
|
||||
"Couldn't reach that computer's magpie — check that it is running and its address": "そのコンピューターの magpie に接続できません — 起動しているか、アドレスが正しいか確認してください",
|
||||
"The magpie on {computer}, where this account is signed in, uses it.": "このアカウントがサインインしている {computer} の magpie が使います。",
|
||||
"This key is read-only on that computer's magpie — give this provider a key with full access to use a reset from here": "このキーはそのコンピューターの magpie では読み取り専用です — ここからリセットを使うには、このプロバイダーにフルアクセスのキーを設定してください",
|
||||
@@ -17005,6 +17008,7 @@ const I18N = {
|
||||
"That computer's magpie doesn't share its quotas yet — update magpie there": "Das magpie dieses Computers teilt seine Kontingente noch nicht — aktualisiere magpie dort",
|
||||
"That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there": "Das magpie dieses Computers ist nicht freigegeben — schalte dort Einstellungen → Netzwerk und Freigabe → Im lokalen Netzwerk freigeben ein",
|
||||
"That computer's magpie didn't take this key — use one of its gateway keys in this provider": "Das magpie dieses Computers hat diesen Schlüssel nicht angenommen — trage bei diesem Anbieter einen seiner Zugangsschlüssel ein",
|
||||
"That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there": "Das magpie dieses Computers nennt diesem Schlüssel keine Kontingente: Er ist dort auf ein Budget, Modelle oder Konten beschränkt — schalte dort unter „Zugangsschlüssel“ bei ihm „Kontingente“ ein",
|
||||
"Couldn't reach that computer's magpie — check that it is running and its address": "Das magpie dieses Computers ist nicht erreichbar — prüfe, ob es läuft und die Adresse stimmt",
|
||||
"The magpie on {computer}, where this account is signed in, uses it.": "Das magpie auf {computer}, wo dieses Konto angemeldet ist, verwendet ihn.",
|
||||
"This key is read-only on that computer's magpie — give this provider a key with full access to use a reset from here": "Dieser Schlüssel ist im magpie dieses Computers schreibgeschützt — gib diesem Anbieter einen Schlüssel mit vollem Zugriff, um von hier einen Reset zu verwenden",
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
// another's magpie (remote-magpie) shows that magpie's cards, each named
|
||||
// with the computer ("Codex · Office"), without the buttons that would act
|
||||
// on this computer's accounts. The remote's own card says why it has none
|
||||
// (nothing read there yet, or a magpie too old to share) in the reader's
|
||||
// (nothing read there yet, a magpie too old to share, or a key it holds
|
||||
// to models or a budget and tells no quotas) in the reader's
|
||||
// language, and its refresh asks for it by its id (?provider=office), the
|
||||
// remote's card by its own (?provider=office/codex). English, Chinese,
|
||||
// Japanese and German; no backend, the API is faked here.
|
||||
// remote's card by its own (?provider=office/codex). English, Chinese
|
||||
// (both scripts), Japanese and German; no backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -32,6 +33,10 @@ function fixtures(now) {
|
||||
error: "remote magpie isn't shared; turn on Share on local network on that computer" },
|
||||
{ provider: "osprey", name: "Osprey", icon: "magpie", from: "Osprey", kind: "subscription", windows: [],
|
||||
error: "remote magpie didn't take this key; use one of its enabled gateway keys" },
|
||||
// yi_time on Discord: a key held to models there was told no quotas,
|
||||
// and the remote's Claude showed nowhere here, with no word why
|
||||
{ provider: "egret", name: "Egret", icon: "magpie", from: "Egret", kind: "subscription", windows: [],
|
||||
error: "remote magpie tells this key none of its quotas, as it holds the key to a budget, models or accounts; turn on Quotas for the key under Gateway keys on that computer" },
|
||||
{ provider: "heron", name: "Heron", icon: "magpie", from: "Heron", kind: "subscription", windows: [],
|
||||
error: "couldn't reach the remote magpie Heron: dial tcp 10.0.0.9:3425: connect: connection refused" },
|
||||
];
|
||||
@@ -69,14 +74,15 @@ function serve(lang, state) {
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { none: "Nothing read on that computer yet — refresh this card to have it read", old: "That computer's magpie doesn't share its quotas yet — update magpie there", shed: "That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there", den: "That computer's magpie didn't take this key — use one of its gateway keys in this provider", barn: "Couldn't reach that computer's magpie — check that it is running and its address" },
|
||||
zh: { none: "那台电脑还没有读过额度 — 刷新这张卡片让它读取", old: "那台电脑的 magpie 还不能共享额度 — 请在那台电脑上更新 magpie", shed: "那台电脑的 magpie 没有共享 — 请在那台电脑上打开 设置 → 网络与共享 → 局域网共享", den: "那台电脑的 magpie 不认这个密钥 — 请在这个服务商里填它的一个网关密钥", barn: "连不上那台电脑的 magpie — 请确认它在运行、地址正确" },
|
||||
ja: { none: "そのコンピューターではまだ読み取っていません — このカードを更新すると読み取ります", old: "そのコンピューターの magpie はまだ利用枠を共有できません — そちらの magpie を更新してください", shed: "そのコンピューターの magpie は共有されていません — そちらで 設定 → ネットワークと共有 → ローカルネットワークで共有 をオンにしてください", den: "そのコンピューターの magpie はこのキーを受け付けませんでした — このプロバイダーにそちらのゲートウェイキーを入れてください", barn: "そのコンピューターの magpie に接続できません — 起動しているか、アドレスが正しいか確認してください" },
|
||||
de: { none: "Auf diesem Computer wurde noch nichts gelesen — diese Karte aktualisieren, um es lesen zu lassen", old: "Das magpie dieses Computers teilt seine Kontingente noch nicht — aktualisiere magpie dort", shed: "Das magpie dieses Computers ist nicht freigegeben — schalte dort Einstellungen → Netzwerk und Freigabe → Im lokalen Netzwerk freigeben ein", den: "Das magpie dieses Computers hat diesen Schlüssel nicht angenommen — trage bei diesem Anbieter einen seiner Zugangsschlüssel ein", barn: "Das magpie dieses Computers ist nicht erreichbar — prüfe, ob es läuft und die Adresse stimmt" },
|
||||
en: { none: "Nothing read on that computer yet — refresh this card to have it read", old: "That computer's magpie doesn't share its quotas yet — update magpie there", shed: "That computer's magpie isn't shared — turn on Settings → Network and sharing → Share on local network there", den: "That computer's magpie didn't take this key — use one of its gateway keys in this provider", held: "That computer's magpie tells this key no quotas: it holds the key to a budget, models or accounts — turn on Quotas for the key under Gateway keys there", barn: "Couldn't reach that computer's magpie — check that it is running and its address" },
|
||||
zh: { none: "那台电脑还没有读过额度 — 刷新这张卡片让它读取", old: "那台电脑的 magpie 还不能共享额度 — 请在那台电脑上更新 magpie", shed: "那台电脑的 magpie 没有共享 — 请在那台电脑上打开 设置 → 网络与共享 → 局域网共享", den: "那台电脑的 magpie 不认这个密钥 — 请在这个服务商里填它的一个网关密钥", held: "那台电脑的 magpie 不向这个密钥显示额度:那边给它限定了预算、模型或账号 — 请在那台电脑的「网关密钥」里打开这个密钥的「额度」", barn: "连不上那台电脑的 magpie — 请确认它在运行、地址正确" },
|
||||
ja: { none: "そのコンピューターではまだ読み取っていません — このカードを更新すると読み取ります", old: "そのコンピューターの magpie はまだ利用枠を共有できません — そちらの magpie を更新してください", shed: "そのコンピューターの magpie は共有されていません — そちらで 設定 → ネットワークと共有 → ローカルネットワークで共有 をオンにしてください", den: "そのコンピューターの magpie はこのキーを受け付けませんでした — このプロバイダーにそちらのゲートウェイキーを入れてください", held: "そのコンピューターの magpie はこのキーに利用枠を伝えません:そちらで予算・モデル・アカウントが制限されています — そちらの「ゲートウェイキー」でこのキーの「残量」をオンにしてください", barn: "そのコンピューターの magpie に接続できません — 起動しているか、アドレスが正しいか確認してください" },
|
||||
de: { none: "Auf diesem Computer wurde noch nichts gelesen — diese Karte aktualisieren, um es lesen zu lassen", old: "Das magpie dieses Computers teilt seine Kontingente noch nicht — aktualisiere magpie dort", shed: "Das magpie dieses Computers ist nicht freigegeben — schalte dort Einstellungen → Netzwerk und Freigabe → Im lokalen Netzwerk freigeben ein", den: "Das magpie dieses Computers hat diesen Schlüssel nicht angenommen — trage bei diesem Anbieter einen seiner Zugangsschlüssel ein", held: "Das magpie dieses Computers nennt diesem Schlüssel keine Kontingente: Er ist dort auf ein Budget, Modelle oder Konten beschränkt — schalte dort unter „Zugangsschlüssel“ bei ihm „Kontingente“ ein", barn: "Das magpie dieses Computers ist nicht erreichbar — prüfe, ob es läuft und die Adresse stimmt" },
|
||||
"zh-TW": { none: "那臺電腦還沒有讀過額度 — 重新整理這張卡片讓它讀取", old: "那臺電腦的 magpie 還不能共享額度 — 請在那臺電腦上更新 magpie", shed: "那臺電腦的 magpie 沒有共享 — 請在那臺電腦上開啟 設定 → 網路與共享 → 區域網共享", den: "那臺電腦的 magpie 不認這個金鑰 — 請在這個服務商裡填它的一個閘道金鑰", held: "那臺電腦的 magpie 不向這個金鑰顯示額度:那邊給它限定了預算、模型或帳號 — 請在那臺電腦的「閘道金鑰」裡打開這個金鑰的「額度」", barn: "連不上那臺電腦的 magpie — 請確認它在執行、位址正確" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "ja", "de"]) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
const w = words[lang];
|
||||
test(`${engine} ${lang}: another computer's quota cards`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
@@ -97,7 +103,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal((await home.locator(".subscription-error").textContent()).trim(), w.none);
|
||||
const attic = page.locator(".subscription-card", { hasText: "Attic" });
|
||||
assert.equal((await attic.locator(".subscription-error").textContent()).trim(), w.old);
|
||||
for (const [k, name] of [["shed", "Kestrel"], ["den", "Osprey"], ["barn", "Heron"]]) {
|
||||
for (const [k, name] of [["shed", "Kestrel"], ["den", "Osprey"], ["held", "Egret"], ["barn", "Heron"]]) {
|
||||
const card = page.locator(".subscription-card", { hasText: name });
|
||||
assert.equal((await card.locator(".subscription-error").textContent()).trim(), w[k], k);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,14 @@ const errRemoteNoShare = "remote magpie doesn't share its quotas; update magpie
|
||||
// every other machine and, given one, answers the quotas too.
|
||||
const errRemoteNotShared = "remote magpie isn't shared; turn on Share on local network on that computer"
|
||||
|
||||
// errRemoteHeld is the remote's own card while it holds this provider's
|
||||
// key to a budget, models or accounts (errKeyHeld): its accounts' cards
|
||||
// aren't told to the key, and the card says so and where that is turned
|
||||
// on, rather than leaving the remote's Claude or Codex out with no word
|
||||
// (yi_time on Discord: a Claude shared from another computer showed no
|
||||
// usage on any page here, its key held to Claude's models there).
|
||||
const errRemoteHeld = "remote magpie tells this key none of its quotas, as it holds the key to a budget, models or accounts; turn on Quotas for the key under Gateway keys on that computer"
|
||||
|
||||
// errRemoteKey is a remote magpie that didn't take this provider's key (401).
|
||||
const errRemoteKey = "remote magpie didn't take this key; use one of its enabled gateway keys"
|
||||
|
||||
@@ -88,7 +96,7 @@ const KeyHeldCode = "gateway_key_held"
|
||||
// errKeyHeld is a remote magpie that holds this provider's key to a
|
||||
// budget, models or accounts: it tells the key's own card (remoteKeyCards)
|
||||
// and none of its accounts', so none is shown, not even one kept from
|
||||
// before the key was held.
|
||||
// before the key was held; the remote's own card says why (errRemoteHeld).
|
||||
var errKeyHeld = errors.New("remote magpie holds this key to a budget, models or accounts")
|
||||
|
||||
// errRemoteUnreachable starts the error of a remote magpie that couldn't
|
||||
@@ -240,12 +248,13 @@ func remoteCards(ctx context.Context, p Provider, fresh bool) []SubscriptionQuot
|
||||
r = keepRemoteCards(id, asked, cards, err)
|
||||
}
|
||||
name := remoteName(p)
|
||||
if r.held {
|
||||
return nil
|
||||
}
|
||||
if len(r.cards) == 0 {
|
||||
if len(r.cards) == 0 || r.held {
|
||||
// the latest read's failure first: one since the key was held
|
||||
// says the remote can't be read now
|
||||
msg := r.err
|
||||
if msg == "" {
|
||||
if msg == "" && r.held {
|
||||
msg = errRemoteHeld
|
||||
} else if msg == "" {
|
||||
msg = errRemoteNothingRead
|
||||
}
|
||||
return []SubscriptionQuota{{Provider: p.ID, Name: name, Icon: "magpie", Kind: "subscription", From: name, Windows: []QuotaWindow{}, Error: msg}}
|
||||
|
||||
@@ -3,6 +3,7 @@ package provider
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@@ -414,8 +415,10 @@ func TestRemoteKeyNames(t *testing.T) {
|
||||
|
||||
// #1981: a remote magpie that holds this computer's key to a budget,
|
||||
// models or accounts tells it none of its accounts. The cards read before
|
||||
// the key was held go, and only the key's own card stays; a 403 for that
|
||||
// reason doesn't say the remote isn't shared.
|
||||
// the key was held go: the key's own card stays, and the remote's own card
|
||||
// says the key is told no quotas and where that is turned on (yi_time on
|
||||
// Discord: a Claude shared over the network showed no usage anywhere, with
|
||||
// no word why). A 403 for that reason doesn't say the remote isn't shared.
|
||||
func TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard(t *testing.T) {
|
||||
peer := &fakePeer{
|
||||
cards: []SubscriptionQuota{{Provider: "codex", Name: "Codex", User: "boss@x.com", Kind: "subscription", Windows: []QuotaWindow{{Name: "5h", Used: 40}}}},
|
||||
@@ -435,8 +438,8 @@ func TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard(t *testing.T) {
|
||||
}
|
||||
remoteCards(ctx, *p, true)
|
||||
all := RemoteCards(ctx)
|
||||
if cs := peerCards(all); len(cs) != 0 {
|
||||
t.Errorf("a held key still shows the remote's accounts: %+v", cs)
|
||||
if cs := peerCards(all); len(cs) != 1 || cs[0].Provider != "office" || cs[0].Error != errRemoteHeld || cs[0].User != "" || len(cs[0].Windows) != 0 {
|
||||
t.Errorf("a held key: want the remote's own card saying why, and none of its accounts: %+v", cs)
|
||||
}
|
||||
for _, q := range all {
|
||||
if strings.Contains(q.Error, "isn't shared") || strings.Contains(q.User, "boss") {
|
||||
@@ -450,9 +453,14 @@ func TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard(t *testing.T) {
|
||||
}
|
||||
// a read asked before the held one came back after it: not kept
|
||||
keepRemoteCards(remoteCardsID(*p), time.Now().Add(-time.Hour), peer.cards, nil)
|
||||
if cs := peerCards(RemoteCards(ctx)); len(cs) != 0 {
|
||||
if cs := peerCards(RemoteCards(ctx)); len(cs) != 1 || cs[0].Error != errRemoteHeld {
|
||||
t.Errorf("a slow earlier read brought the cards back: %+v", cs)
|
||||
}
|
||||
// the remote can't be reached since: that is what its card says now
|
||||
keepRemoteCards(remoteCardsID(*p), time.Now(), nil, errors.New(errRemoteUnreachable+": refused"))
|
||||
if cs := peerCards(RemoteCards(ctx)); len(cs) != 1 || !strings.HasPrefix(cs[0].Error, errRemoteUnreachable) {
|
||||
t.Errorf("unreachable after held: %+v", cs)
|
||||
}
|
||||
}
|
||||
|
||||
// #1981: cards are kept by provider and key, so a key changed to another
|
||||
|
||||
Reference in New Issue
Block a user