v0.3.97 c2267b3

config_proxy_test.go RawHistoryFolder

1package agent
2
3import (
4	"os"
5	"testing"
6)
7
8func TestApplyConfiguredHTTPProxy(t *testing.T) {
9	t.Setenv("ZOT_HOME", t.TempDir())
10	for _, key := range []string{"HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy"} {
11		t.Setenv(key, "")
12	}
13	if err := SaveConfig(Config{HTTPProxy: "  http://proxy.example:8080  "}); err != nil {
14		t.Fatal(err)
15	}
16
17	applyConfiguredHTTPProxy()
18
19	if got := getenvForTest("HTTP_PROXY"); got != "http://proxy.example:8080" {
20		t.Fatalf("HTTP_PROXY = %q", got)
21	}
22	if got := getenvForTest("HTTPS_PROXY"); got != "http://proxy.example:8080" {
23		t.Fatalf("HTTPS_PROXY = %q", got)
24	}
25}
26
27func TestApplyConfiguredHTTPProxyPreservesUppercaseEnvironment(t *testing.T) {
28	t.Setenv("ZOT_HOME", t.TempDir())
29	// Set lowercase first because environment variable names are
30	// case-insensitive on Windows.
31	t.Setenv("http_proxy", "")
32	t.Setenv("https_proxy", "")
33	t.Setenv("HTTP_PROXY", "http://http-env.example:8080")
34	t.Setenv("HTTPS_PROXY", "http://https-env.example:8080")
35	if err := SaveConfig(Config{HTTPProxy: "http://config.example:8080"}); err != nil {
36		t.Fatal(err)
37	}
38
39	applyConfiguredHTTPProxy()
40
41	if got := getenvForTest("HTTP_PROXY"); got != "http://http-env.example:8080" {
42		t.Fatalf("HTTP_PROXY = %q", got)
43	}
44	if got := getenvForTest("HTTPS_PROXY"); got != "http://https-env.example:8080" {
45		t.Fatalf("HTTPS_PROXY = %q", got)
46	}
47}
48
49func TestApplyConfiguredHTTPProxyPreservesLowercaseEnvironment(t *testing.T) {
50	t.Setenv("ZOT_HOME", t.TempDir())
51	// Set uppercase first because environment variable names are
52	// case-insensitive on Windows.
53	t.Setenv("HTTP_PROXY", "")
54	t.Setenv("HTTPS_PROXY", "")
55	t.Setenv("http_proxy", "http://http-env.example:8080")
56	t.Setenv("https_proxy", "http://https-env.example:8080")
57	if err := SaveConfig(Config{HTTPProxy: "http://config.example:8080"}); err != nil {
58		t.Fatal(err)
59	}
60
61	applyConfiguredHTTPProxy()
62
63	if got := getenvForTest("http_proxy"); got != "http://http-env.example:8080" {
64		t.Fatalf("http_proxy = %q", got)
65	}
66	if got := getenvForTest("https_proxy"); got != "http://https-env.example:8080" {
67		t.Fatalf("https_proxy = %q", got)
68	}
69}
70
71func TestApplyConfiguredHTTPProxyIgnoresEmptySetting(t *testing.T) {
72	t.Setenv("ZOT_HOME", t.TempDir())
73	for _, key := range []string{"HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy"} {
74		t.Setenv(key, "")
75	}
76	if err := SaveConfig(Config{HTTPProxy: "  "}); err != nil {
77		t.Fatal(err)
78	}
79
80	applyConfiguredHTTPProxy()
81
82	if got := getenvForTest("HTTP_PROXY"); got != "" {
83		t.Fatalf("HTTP_PROXY = %q", got)
84	}
85	if got := getenvForTest("HTTPS_PROXY"); got != "" {
86		t.Fatalf("HTTPS_PROXY = %q", got)
87	}
88}
89
90func getenvForTest(key string) string {
91	return os.Getenv(key)
92}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close