The Grok plugin's sign-in said only "grok login gave no link to open". The plugin host has magpie's proxy only as MAGPIE_*_PROXY, so the `grok login` the plugin runs went out with none, where the built-in's had it (netproxy.Env); where x.ai is reached only through a proxy, it failed. host.js's spawn wrapper now gives a started program HTTPS_PROXY and HTTP_PROXY (the account's own proxy, none for direct, else magpie's) when the plugin set none. grok 1.0.46, unable to reach x.ai, prints "Error: error sending request for url (https://auth.x.ai/oauth2/device/code): …", whose URL the built-in's runCLISignIn took for the page to open; a line saying error gives no link, and a login with none ends with the CLI's last line. The plugin does the same from 0.1.8, which the grok mover now asks for. plugin_cliproxy_test.go and TestCLISignInSaysWhyNoLink fail before this. Checked with grok 1.0.46 itself through the plugin host and the published plugin's code, given a proxy that refuses: the CLI goes through it and the error names what it said.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package plugin
|
||
|
||
import (
|
||
"context"
|
||
"net/url"
|
||
"path/filepath"
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
// 𝕏 on Discord: the Grok plugin's sign-in said "grok login gave no link
|
||
// to open". The plugin runs `grok login`, and the host has magpie's proxy
|
||
// only as MAGPIE_*_PROXY, so the CLI went out with none where x.ai is
|
||
// reached only through one. A program a plugin starts has it, as the
|
||
// built-in's `grok login` had it.
|
||
func TestPluginCLIHasTheProxy(t *testing.T) {
|
||
sandbox(t)
|
||
const proxy = "http://127.0.0.1:7890"
|
||
t.Setenv("HTTPS_PROXY", proxy)
|
||
t.Setenv("HTTP_PROXY", proxy)
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||
defer cancel()
|
||
abs, _ := filepath.Abs("testdata/cliproxy/index.js")
|
||
if _, err := Add(ctx, abs); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
a, err := Authorize(ctx, "cliproxy", 0, nil, NewAccount)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
u, err := url.Parse(a.URL)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
for _, k := range []string{"inherited", "copied"} {
|
||
if got := u.Query().Get(k); got != proxy {
|
||
t.Errorf("a CLI started with the %s environment has HTTPS_PROXY %q, want %q", k, got, proxy)
|
||
}
|
||
}
|
||
}
|