main bac21c6

app_l4_test.go RawHistoryFolder

1package domain_test
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7	"github.com/stretchr/testify/require"
8
9	"github.com/bnema/gordon/internal/domain"
10)
11
12func TestValidatePublishForListener_ExactTupleAccepted(t *testing.T) {
13	cases := []struct {
14		name       string
15		publish    string
16		transport  domain.NetworkProtocol
17		listener   domain.EntryPointListener
18		entrypoint string
19	}{
20		{
21			name: "tcp wildcard explicit", publish: "0.0.0.0:25432", transport: domain.NetworkProtocolTCP,
22			listener: domain.EntryPointListener{Address: "0.0.0.0:25432", Protocol: domain.EntryPointProtocolTCP}, entrypoint: "tcp",
23		},
24		{
25			name: "tcp empty host equals wildcard listener", publish: "25432", transport: domain.NetworkProtocolTCP,
26			listener: domain.EntryPointListener{Address: ":25432", Protocol: domain.EntryPointProtocolTCP}, entrypoint: "tcp",
27		},
28		{
29			name: "tcp smart entrypoint", publish: "0.0.0.0:25432", transport: domain.NetworkProtocolTCP,
30			listener: domain.EntryPointListener{Address: "0.0.0.0:25432", Protocol: domain.EntryPointProtocolSmartTCP}, entrypoint: "edge",
31		},
32		{
33			name: "udp", publish: "0.0.0.0:28015", transport: domain.NetworkProtocolUDP,
34			listener: domain.EntryPointListener{Address: "0.0.0.0:28015", Protocol: domain.EntryPointProtocolUDP}, entrypoint: "udp",
35		},
36		{
37			name: "loopback listener with loopback publish", publish: "127.0.0.1:1543", transport: domain.NetworkProtocolTCP,
38			listener: domain.EntryPointListener{Address: "127.0.0.1:1543", Protocol: domain.EntryPointProtocolTCP}, entrypoint: "local",
39		},
40	}
41	for _, tc := range cases {
42		t.Run(tc.name, func(t *testing.T) {
43			require.NoError(t, domain.ValidatePublishForListener(tc.publish, tc.transport, tc.listener, tc.entrypoint))
44		})
45	}
46}
47
48func TestValidatePublishForListener_RejectsMismatch(t *testing.T) {
49	wildcard := domain.EntryPointListener{Address: "0.0.0.0:25432", Protocol: domain.EntryPointProtocolTCP}
50	cases := []struct {
51		name      string
52		publish   string
53		transport domain.NetworkProtocol
54		listener  domain.EntryPointListener
55	}{
56		{name: "loopback publish on wildcard listener", publish: "127.0.0.1:25432", transport: domain.NetworkProtocolTCP, listener: wildcard},
57		{name: "port mismatch", publish: "0.0.0.0:15432", transport: domain.NetworkProtocolTCP, listener: wildcard},
58		{name: "loopback vs wildcard host", publish: "127.0.0.1:25432", transport: domain.NetworkProtocolTCP, listener: wildcard},
59		{name: "udp on tcp entrypoint", publish: "0.0.0.0:25432", transport: domain.NetworkProtocolUDP, listener: wildcard},
60		{name: "tcp on udp entrypoint", publish: "0.0.0.0:25432", transport: domain.NetworkProtocolTCP, listener: domain.EntryPointListener{Address: "0.0.0.0:25432", Protocol: domain.EntryPointProtocolUDP}},
61		{name: "hostname publish", publish: "db.internal:25432", transport: domain.NetworkProtocolTCP, listener: wildcard},
62		{name: "missing port", publish: "0.0.0.0", transport: domain.NetworkProtocolTCP, listener: wildcard},
63		{name: "invalid listener address", publish: "0.0.0.0:25432", transport: domain.NetworkProtocolTCP, listener: domain.EntryPointListener{Address: "25432", Protocol: domain.EntryPointProtocolTCP}},
64	}
65	for _, tc := range cases {
66		t.Run(tc.name, func(t *testing.T) {
67			assert.ErrorIs(t, domain.ValidatePublishForListener(tc.publish, tc.transport, tc.listener, "tcp"), domain.ErrInvalidAppSpec)
68		})
69	}
70}
71
72func TestCanonicalBindHost(t *testing.T) {
73	assert.Equal(t, "0.0.0.0", domain.CanonicalBindHost(""))
74	assert.Equal(t, "0.0.0.0", domain.CanonicalBindHost("   "))
75	assert.Equal(t, "127.0.0.1", domain.CanonicalBindHost("127.0.0.1"))
76	assert.Equal(t, "::1", domain.CanonicalBindHost("::1"))
77}

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