detached 0b996ab

test direct HTTP onboarding HEAD routes

commit
0b996ab2137889a98b945458f8295fd47dd6d3c5
author
brice · · 2026-04-01 14:01 UTC
parent
7fff706
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +36 -0
M internal/app/run_http_handlers_test.go +36 -0
@@ -2,6 +2,7 @@ package app
22
33 import (
44 "context"
5+ "io"
56 "net/http"
67 "net/http/httptest"
78 "testing"
@@ -249,6 +250,41 @@ func TestCreateHTTPHandlers_HTTPSOnboarding_HEADRoutesRemainAvailable(t *testing
249250 }
250251 }
251252
253+func TestCreateHTTPHandlers_DirectHTTPOnboarding_HEADRoutesRemainAvailable(t *testing.T) {
254+ t.Parallel()
255+ ca := newTestCA(t)
256+ cfg := newOnboardingConfig()
257+ svc := &services{caAdapter: ca}
258+
259+ _, httpHandler, _ := createHTTPHandlers(svc, cfg, zerowrap.Default())
260+
261+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
262+ r.RemoteAddr = directAddr
263+ r.Host = "o2.bnema.dev"
264+ httpHandler.ServeHTTP(w, r)
265+ }))
266+ defer ts.Close()
267+
268+ for _, tc := range []struct {
269+ path string
270+ contentType string
271+ }{
272+ {path: "/ca", contentType: "text/html"},
273+ {path: "/ca.crt", contentType: "application/x-x509-ca-cert"},
274+ } {
275+ resp, err := ts.Client().Head(ts.URL + tc.path)
276+ require.NoError(t, err)
277+
278+ body, err := io.ReadAll(resp.Body)
279+ require.NoError(t, err)
280+ require.NoError(t, resp.Body.Close())
281+
282+ assert.Equal(t, http.StatusOK, resp.StatusCode, "HEAD %s should return 200", tc.path)
283+ assert.Contains(t, resp.Header.Get("Content-Type"), tc.contentType)
284+ assert.Empty(t, body, "HEAD %s should have empty body", tc.path)
285+ }
286+}
287+
252288 func TestCreateHTTPHandlers_DirectHTTPForbiddenHEAD_ReturnsForbidden(t *testing.T) {
253289 t.Parallel()
254290 ca := newTestCA(t)
@@ -2,6 +2,7 @@ package app
2 2
3 import (3 import (
4 "context"4 "context"
5+ "io"
5 "net/http"6 "net/http"
6 "net/http/httptest"7 "net/http/httptest"
7 "testing"8 "testing"
@@ -249,6 +250,41 @@ func TestCreateHTTPHandlers_HTTPSOnboarding_HEADRoutesRemainAvailable(t *testing
249 }250 }
250 }251 }
251 252
253+func TestCreateHTTPHandlers_DirectHTTPOnboarding_HEADRoutesRemainAvailable(t *testing.T) {
254+ t.Parallel()
255+ ca := newTestCA(t)
256+ cfg := newOnboardingConfig()
257+ svc := &services{caAdapter: ca}
258+
259+ _, httpHandler, _ := createHTTPHandlers(svc, cfg, zerowrap.Default())
260+
261+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
262+ r.RemoteAddr = directAddr
263+ r.Host = "o2.bnema.dev"
264+ httpHandler.ServeHTTP(w, r)
265+ }))
266+ defer ts.Close()
267+
268+ for _, tc := range []struct {
269+ path string
270+ contentType string
271+ }{
272+ {path: "/ca", contentType: "text/html"},
273+ {path: "/ca.crt", contentType: "application/x-x509-ca-cert"},
274+ } {
275+ resp, err := ts.Client().Head(ts.URL + tc.path)
276+ require.NoError(t, err)
277+
278+ body, err := io.ReadAll(resp.Body)
279+ require.NoError(t, err)
280+ require.NoError(t, resp.Body.Close())
281+
282+ assert.Equal(t, http.StatusOK, resp.StatusCode, "HEAD %s should return 200", tc.path)
283+ assert.Contains(t, resp.Header.Get("Content-Type"), tc.contentType)
284+ assert.Empty(t, body, "HEAD %s should have empty body", tc.path)
285+ }
286+}
287+
252 func TestCreateHTTPHandlers_DirectHTTPForbiddenHEAD_ReturnsForbidden(t *testing.T) {288 func TestCreateHTTPHandlers_DirectHTTPForbiddenHEAD_ReturnsForbidden(t *testing.T) {
253 t.Parallel()289 t.Parallel()
254 ca := newTestCA(t)290 ca := newTestCA(t)

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