v3.3.0 b164fe9

handler_retired_test.go RawHistoryFolder

1package admin
2
3import (
4	"encoding/json"
5	"net/http"
6	"net/http/httptest"
7	"testing"
8
9	"github.com/stretchr/testify/assert"
10	"github.com/stretchr/testify/require"
11
12	"github.com/bnema/gordon/internal/adapters/dto"
13	inmocks "github.com/bnema/gordon/internal/boundaries/in/mocks"
14)
15
16func retiredTestHandler(t *testing.T) *Handler {
17	t.Helper()
18	return NewHandler(HandlerDeps{
19		ConfigSvc:     inmocks.NewMockConfigService(t),
20		AuthSvc:       inmocks.NewMockAuthService(t),
21		ContainerSvc:  inmocks.NewMockContainerService(t),
22		HealthSvc:     inmocks.NewMockHealthService(t),
23		Log:           testLogger(),
24		ReloadTrigger: noopReloadTrigger{},
25	})
26}
27
28func TestHandler_RetiredMutations_Return410(t *testing.T) {
29	handler := retiredTestHandler(t)
30	targets := []struct {
31		method string
32		path   string
33	}{
34		{http.MethodPost, "/admin/deploy/example.com"},
35		{http.MethodPost, "/admin/restart/example.com"},
36		{http.MethodPost, "/admin/deploy-intent"},
37		{http.MethodPost, "/admin/routes"},
38		{http.MethodGet, "/admin/routes"},
39		{http.MethodDelete, "/admin/routes/example.com"},
40		{http.MethodPost, "/admin/attachments"},
41		{http.MethodGet, "/admin/attachments/by-image/x"},
42		{http.MethodPost, "/admin/attachments/prune"},
43		{http.MethodGet, "/admin/attachments/orphans"},
44		{http.MethodPost, "/admin/bootstrap"},
45		{http.MethodPost, "/admin/preview/blog"},
46		{http.MethodGet, "/admin/previews"},
47		{http.MethodPost, "/admin/autoroute/allowed-domains"},
48		{http.MethodGet, "/admin/secrets/example.com"},
49		{http.MethodPost, "/admin/secrets/example.com"},
50		{http.MethodDelete, "/admin/secrets/example.com/KEY"},
51	}
52	for _, target := range targets {
53		req := httptest.NewRequest(target.method, target.path, nil)
54		req = req.WithContext(ctxWithScopes("admin:*:*"))
55		rec := httptest.NewRecorder()
56		handler.ServeHTTP(rec, req)
57		require.Equal(t, http.StatusGone, rec.Code, "%s %s", target.method, target.path)
58		var envelope dto.AppError
59		require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &envelope), target.path)
60		assert.Equal(t, "endpoint-retired", envelope.Error, target.path)
61	}
62}

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