Parent directory

web-ui.txtar

4533 bytes
  1# vi: set ft=conf
  2
  3# FIXME: curl makes GitHub Actions hang on Windows.
  4[windows] skip 'curl makes github actions hang'
  5
  6# The UI is opt-in and must coexist with all HTTP infrastructure routes.
  7env SOFT_SERVE_HTTP_WEB_UI_ENABLED=true
  8exec soft serve &
  9ensureserverrunning SSH_PORT
 10ensureserverrunning HTTP_PORT
 11
 12# Build the required public, private, hidden, nested, empty, and profile data.
 13soft repo create public
 14soft repo create private
 15soft repo private private true
 16soft repo create hidden
 17soft repo hidden hidden true
 18soft repo create team/nested
 19soft repo create empty
 20soft repo create .soft-serve
 21
 22mkdir nested
 23# Use a known default ref for stable page URLs.
 24git -c init.defaultBranch=main -C nested init
 25mkfile ./nested/README.md '# Nested project\n\n![Logo](images/logo.png)'
 26mkfile ./nested/hello.txt 'hello from source'
 27mkdir nested/images
 28mkfile ./nested/images/logo.png 'not a real PNG, but safe media routing is extension based'
 29git -C nested lfs install --local
 30git -C nested lfs track '*.png'
 31git -C nested add -A
 32git -C nested commit -m 'initial nested project'
 33git -C nested tag v1.0.0
 34git -C nested remote add origin ssh://localhost:$SSH_PORT/team/nested
 35git -C nested push origin HEAD --tags
 36
 37mkdir profile
 38git -c init.defaultBranch=main -C profile init
 39mkfile ./profile/README.md '# Profile\n\nPublic profile content'
 40git -C profile add -A
 41git -C profile commit -m 'profile README'
 42git -C profile remote add origin ssh://localhost:$SSH_PORT/.soft-serve
 43git -C profile push origin HEAD
 44
 45# The homepage lists only visible public cards and renders the profile README.
 46curl http://localhost:$HTTP_PORT/
 47stdout 'public'
 48stdout 'team/nested'
 49stdout 'Public profile content'
 50! stdout 'private'
 51! stdout 'hidden'
 52! stdout '.soft-serve'
 53
 54# Nested overview, tree, source, raw, history, commit, and refs routes work.
 55curl http://localhost:$HTTP_PORT/team/nested
 56stdout 'Nested project'
 57curl http://localhost:$HTTP_PORT/team/nested/@/tree
 58stdout 'README.md'
 59stdout 'hello.txt'
 60curl http://localhost:$HTTP_PORT/team/nested/@/tree?path=hello.txt
 61stdout 'hello from source'
 62curl http://localhost:$HTTP_PORT/team/nested
 63stdout '/team/nested/@/raw[?]path=images%2Flogo.png&ref=refs%2Fheads%2Fmain'
 64curl -v http://localhost:$HTTP_PORT/team/nested/@/raw?path=images%2Flogo.png
 65stderr '.*200 OK.*'
 66stderr '.*Content-Type: image/png.*'
 67stderr '.*X-Content-Type-Options: nosniff.*'
 68stderr '.*Referrer-Policy: same-origin.*'
 69curl http://localhost:$HTTP_PORT/team/nested/@/commits
 70stdout 'initial nested project'
 71git -C nested rev-parse HEAD
 72cp stdout hash
 73envfile HASH=hash
 74curl http://localhost:$HTTP_PORT/team/nested/@/commit?hash=$HASH
 75stdout 'initial nested project'
 76curl http://localhost:$HTTP_PORT/team/nested/@/refs
 77stdout 'v1.0.0'
 78
 79# Empty repositories render, hidden public repositories remain directly readable,
 80# and private routes return 404 without content disclosure.
 81curl http://localhost:$HTTP_PORT/empty
 82stdout 'This repository is empty.'
 83curl http://localhost:$HTTP_PORT/hidden
 84stdout 'This repository is empty.'
 85curl -v http://localhost:$HTTP_PORT/private
 86stderr '.*404 Not Found.*'
 87! stdout 'private'
 88curl -v http://localhost:$HTTP_PORT/private/@/tree
 89stderr '.*404 Not Found.*'
 90! stdout 'private'
 91
 92# Existing anonymous HTTP fetch, authenticated push, LFS transfer, go-get, and
 93# health routes continue to work while the UI is enabled.
 94git clone http://localhost:$HTTP_PORT/team/nested.git nested-http
 95exists nested-http/images/logo.png
 96soft token create --expires-in '1h' 'nested'
 97stdout 'ss_*'
 98cp stdout tokenfile
 99envfile TOKEN=tokenfile
100git -C nested-http remote set-url origin http://$TOKEN@localhost:$HTTP_PORT/team/nested.git
101mkfile ./nested-http/pushed-over-http.txt 'pushed over HTTP'
102git -C nested-http add pushed-over-http.txt
103git -C nested-http commit -m 'push over HTTP'
104git -C nested-http push origin HEAD
105git -C nested fetch origin
106grep 'pushed over HTTP' nested-http/pushed-over-http.txt
107curl http://localhost:$HTTP_PORT/team/nested?go-get=1
108stdout 'name="go-import"'
109curl -v http://localhost:$HTTP_PORT/livez
110stderr '.*200 OK.*'
111curl -v http://localhost:$HTTP_PORT/readyz
112stderr '.*200 OK.*'
113
114# Disabling the UI restores the existing page-path 404 behavior while health
115# routes remain available.
116stopserver
117env SOFT_SERVE_HTTP_WEB_UI_ENABLED=false
118exec soft serve &
119ensureserverrunning HTTP_PORT
120curl -v http://localhost:$HTTP_PORT/team/nested
121stderr '.*404 Not Found.*'
122curl -v http://localhost:$HTTP_PORT/livez
123stderr '.*200 OK.*'
124
125# stop the server
126[windows] stopserver
127[windows] ! stderr .