LoKi's patch (lokic7123-star), picked onto origin/mainef6f3749d. A plugin's api method that has an authorize step and no prompts is reported as keyless: PluginAPIKey accepts an empty key for that method only, the CLI and the GUI skip the key field, and a plugin marked auth.single signs in again on its first account instead of adding another one. Zen Free needs magpie-community/plugins#205 (keyless and single on zen-free), merged and published, before its users see this. Added in review (yetone): TestPluginEmptyKeyOnlyKeyless, which checks that an empty key is refused for a non-keyless api method, an oauth method marked keyless, an out-of-range method and an unknown plugin. Run at the stacked tree (this commit plus #2554 and #2862, onef6f3749d): - gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui, and GOOS=windows: ok. - set -o pipefail; go test -count=1 -timeout 45m ./... under the suite lock: every package ok (SUITE_EXIT 0). - GUI: plugin-keyless-signin, account-models, i18n-keys and models-select-all-api, chromium and webkit, every language they cover: all pass. Red on the old code: TestPluginKeylessSingleIdentity "keyless metadata lost"; the GUI test 10/10 red; without signInKey's single line, "single identity duplicated"; TestPluginEmptyKeyOnlyKeyless red with the Keyless check replaced by false. Not tried: a real Zen Free sign-in (needs plugins#205 published).
26 lines
829 B
Go
26 lines
829 B
Go
package gui
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
)
|
|
|
|
func TestPluginSubscriptionCarriesSingleIdentity(t *testing.T) {
|
|
cfg := pluginsSandbox(t)
|
|
if err := os.MkdirAll(cfg, 0o700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(cfg, "plugins.json"), []byte(`{"plugins":[{"spec":"public-fixture-plugin"}]}`), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
plugin.UseCached([]plugin.Provider{{ID: "public-fixture", Spec: "public-fixture-plugin", Name: "Public fixture", Single: true, Methods: []plugin.Method{{Type: "api", Keyless: true}}}})
|
|
t.Cleanup(func() { plugin.UseCached(nil) })
|
|
subs := pluginSubs()
|
|
if len(subs) != 1 || !subs[0].Single || len(subs[0].Methods) != 1 || !subs[0].Methods[0].Keyless {
|
|
t.Fatalf("subscription lost metadata: %+v", subs)
|
|
}
|
|
}
|