v2.16.0 ebd2ab3

controlplane_resolver_test.go RawHistoryFolder

1package cli
2
3import (
4	"os"
5	"path/filepath"
6	"strings"
7	"testing"
8)
9
10func TestResolveControlPlane_LocalDeniedWhenAuthEnabled(t *testing.T) {
11	tmpDir := t.TempDir()
12	t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpDir, "xdg"))
13	t.Setenv("GORDON_REMOTE", "")
14	t.Setenv("GORDON_TOKEN", "")
15	originalRemoteFlag, originalTokenFlag, originalInsecureTLSFlag := remoteFlag, tokenFlag, insecureTLSFlag
16	t.Cleanup(func() {
17		remoteFlag = originalRemoteFlag
18		tokenFlag = originalTokenFlag
19		insecureTLSFlag = originalInsecureTLSFlag
20	})
21
22	remoteFlag = ""
23	tokenFlag = ""
24	insecureTLSFlag = false
25
26	configPath := filepath.Join(tmpDir, "gordon.toml")
27	err := os.WriteFile(configPath, []byte(`[server]
28gordon_domain = "gordon.local"
29data_dir = "`+filepath.Join(tmpDir, "data")+`"
30
31[auth]
32enabled = true
33`), 0o600)
34	if err != nil {
35		t.Fatalf("failed to write config: %v", err)
36	}
37
38	handle, err := resolveControlPlane(configPath)
39	if err == nil {
40		if handle != nil {
41			handle.close()
42		}
43		t.Fatalf("expected error when auth.enabled=true and no remote target")
44	}
45	if !strings.Contains(err.Error(), "local control plane is disabled when auth.enabled=true") {
46		t.Fatalf("unexpected error: %v", err)
47	}
48}
49
50func TestResolveControlPlane_LocalAllowedWhenAuthDisabled(t *testing.T) {
51	tmpDir := t.TempDir()
52	t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpDir, "xdg"))
53	t.Setenv("GORDON_REMOTE", "")
54	t.Setenv("GORDON_TOKEN", "")
55	originalRemoteFlag, originalTokenFlag, originalInsecureTLSFlag := remoteFlag, tokenFlag, insecureTLSFlag
56	t.Cleanup(func() {
57		remoteFlag = originalRemoteFlag
58		tokenFlag = originalTokenFlag
59		insecureTLSFlag = originalInsecureTLSFlag
60	})
61
62	remoteFlag = ""
63	tokenFlag = ""
64	insecureTLSFlag = false
65
66	configPath := filepath.Join(tmpDir, "gordon.toml")
67	err := os.WriteFile(configPath, []byte(`[server]
68gordon_domain = "gordon.local"
69data_dir = "`+filepath.Join(tmpDir, "data")+`"
70
71[auth]
72enabled = false
73`), 0o600)
74	if err != nil {
75		t.Fatalf("failed to write config: %v", err)
76	}
77
78	handle, err := resolveControlPlane(configPath)
79	if err != nil {
80		t.Fatalf("expected local control-plane handle, got error: %v", err)
81	}
82	if handle == nil || handle.plane == nil {
83		t.Fatalf("expected non-nil local control-plane handle")
84	}
85	handle.close()
86}

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 7

Tags 106

↑↓ moveenter openesc close