v3.4.1 de8f68e

projection_visibility_test.go RawHistoryFolder

1package apptraffic_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	"github.com/bnema/gordon/internal/usecase/apptraffic"
11)
12
13// internalActive is one app whose only HTTP interface is internal.
14func internalActive() domain.AppActive {
15	return domain.AppActive{
16		App: "blog",
17		Services: map[string]domain.AppEffectiveService{
18			"api": {
19				EffectiveRevision: "rev-1",
20				Image:             "img:1",
21				Container:         "c-api",
22				Spec: domain.AppService{
23					HTTP: []domain.AppHTTPInterface{{Port: 8080, Visibility: domain.AppVisibilityInternal}},
24				},
25			},
26		},
27	}
28}
29
30// TestProject_InternalHTTPExcluded proves an internal HTTP interface
31// projects no route: it can never appear in the host index, so it also
32// yields no certificate host and no TLS mode.
33func TestProject_InternalHTTPExcluded(t *testing.T) {
34	entries, err := apptraffic.Project("blog", internalActive(), nil)
35	require.NoError(t, err)
36	assert.Empty(t, entries)
37}
38
39// TestProject_MixedVisibilityProjectsOnlyPublic proves a service with both
40// planes projects only the public interface.
41func TestProject_MixedVisibilityProjectsOnlyPublic(t *testing.T) {
42	active := internalActive()
43	svc := active.Services["api"]
44	svc.BackendBinds = map[int]int{8080: 18080}
45	svc.Spec.HTTP = []domain.AppHTTPInterface{
46		{Host: "blog.example.com", Port: 8080, TLS: "auto", Visibility: domain.AppVisibilityPublic},
47		{Port: 9090, Visibility: domain.AppVisibilityInternal},
48	}
49	active.Services["api"] = svc
50
51	entries, err := apptraffic.Project("blog", active, nil)
52	require.NoError(t, err)
53	require.Len(t, entries, 1)
54	assert.Equal(t, "blog.example.com", entries[0].Host)
55	assert.Equal(t, 8080, entries[0].Backend.ContainerPort)
56}

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