Zane on Discord: in Settings' proxy, Off saves "direct" and Auto saves "", so the Custom address and its user and password were gone the next time Custom was picked. settings.Save now keeps the last proxy of the user's own as proxyCustom (set only from Proxy, never from the page; the POST /api/settings handler copies the saved one over what the page sends). It is stored as Proxy is: plainly in settings.json, as before, the same as the proxy itself, nowhere more plainly. KeepOwn keeps it this computer's own, as Proxy, so sync and restore never carry another computer's. Custom picked after Off or Auto fills its fields from it; nothing that reads settings.proxy changes, and Off and Auto still send requests as they did. Run at base61b92529e(this tree): - go test ./internal/settings ./internal/backup ./internal/davsync ./internal/netproxy: ok. TestProxyCustomRemembered (gui, through Handler) and TestProxyCustomOwn (settings): ok. - settings-proxy-remember.test.cjs (new; en, zh, zh-TW, ja, de, chromium and webkit): Custom with user "名 a@b" and password "p@ss 密" -> Off -> Custom shows the same address and user; the same after a reload and after Auto; an unsaved draft is not what comes back; the page never posts proxyCustom. 10/10. - TestSettingsSaveKeepsWhatItDoesNotSend (the guard that every field the page doesn't send outlives its save) now sets ProxyCustom; red without the api.go line. - settings-proxy-auth, proxy-test, proxy-own-wording: 54 pass. - Full GUI suite (make test-ui, both engines) on a copy of this tree: 11735 tests, 70 red over 23 files at load ~150-260. Run again two at a time, 15 of those files pass; the other 8 are red on origin/main8278fd9b0too, run the same way, and are filed: mobile-web (#2658), quota-count-wrap and quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide and usage-fold (#2399), usage-checkin (#2549, #3091), usage-ledger (#3104). - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok. Broken by hand, each red, then put back: - no proxyCustom in save(): TestProxyCustomRemembered red. - no KeepOwn line: TestProxyCustomOwn red. - no api.go line (page's value taken): the GUI test red. - renderProxy filling from "" again: the GUI test red in chromium. Not tried: the real app with a real SOCKS proxy that needs a login; a sync between two real computers.
19 lines
647 B
Go
19 lines
647 B
Go
package settings
|
|
|
|
import "testing"
|
|
|
|
// The remembered custom proxy holds the proxy's login, so it is this
|
|
// computer's own as the proxy is: a sync or a restored backup keeps the
|
|
// one here and never brings another computer's.
|
|
func TestProxyCustomOwn(t *testing.T) {
|
|
from := Settings{Theme: "dark", Proxy: "direct", ProxyCustom: "socks5://a:b@there:1080"}
|
|
from.KeepOwn(Settings{ProxyCustom: "socks5://c:d@here:1080"})
|
|
if from.ProxyCustom != "socks5://c:d@here:1080" || from.Theme != "dark" {
|
|
t.Fatalf("KeepOwn: %+v", from)
|
|
}
|
|
from.KeepOwn(Settings{})
|
|
if from.ProxyCustom != "" {
|
|
t.Fatal("another computer's proxy login taken here")
|
|
}
|
|
}
|