Something went wrong. Try again.
forked from charmbracelet/soft-serve
Something went wrong. Try again.
11 kB · 255 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256# vi: set ft=conf
# FIXME: don't skip windows[windows] skip 'curl makes github actions hang'
# convert crlf to lf on windows[windows] dos2unix http1.txt http2.txt http3.txt goget.txt gitclone.txt
# start soft serveexec soft serve &# wait for SSH server to startensureserverrunning SSH_PORT
# create usersoft user create user1 --key "$USER1_AUTHORIZED_KEY"
# create access tokensoft token create --expires-in '1h' 'repo2'stdout 'ss_*'cp stdout tokenfileenvfile TOKEN=tokenfilesoft token create --expires-in '1ns' 'repo2'stdout 'ss_*'cp stdout etokenfileenvfile ETOKEN=etokenfileusoft token create 'repo2'stdout 'ss_*'cp stdout utokenfileenvfile UTOKEN=utokenfile
# push & create repo with some files, commits, tags...mkdir ./repo2git -c init.defaultBranch=master -C repo2 initmkfile ./repo2/README.md '# Project\nfoo'mkfile ./repo2/foo.png 'foo'mkfile ./repo2/bar.png 'bar'git -C repo2 remote add origin http://$TOKEN@localhost:$HTTP_PORT/repo2git -C repo2 lfs install --localgit -C repo2 lfs track '*.png'git -C repo2 add -Agit -C repo2 commit -m 'first'git -C repo2 tag v0.1.0git -C repo2 push origin HEADgit -C repo2 push origin HEAD --tags
# dumb http gitcurl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refsstdout '[0-9a-z]{40} refs/heads/master\n[0-9a-z]{40} refs/tags/v0.1.0'
# http errorscurl -XGET http://localhost:$HTTP_PORT/repo2111foobar.git/foo/barstdout '404.*'curl -XGET http://localhost:$HTTP_PORT/repo2111/foobar.git/foo/barstdout '404.*'curl -XGET http://localhost:$HTTP_PORT/repo2.git/foo/barstdout '404.*'curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/foostdout '404.*'curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*Method Not Allowed.*'curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*Not Acceptable.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*validation error.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{}' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*no objects found.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{"operation":"download","transfers":["foo"]}' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*unsupported transfer.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{"operation":"bar","objects":[{}]}' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*unsupported operation.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{"operation":"download","objects":[{}]}' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcmp stdout http1.txtcurl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{"operation":"upload","objects":[{}]}' http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*write access required.*'curl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' -d '{"operation":"upload","objects":[{}]}' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcmp stdout http1.txt
# go-get allow (public repo)curl http://localhost:$HTTP_PORT/repo2.git?go-get=1cmpenv stdout goget.txtcurl http://localhost:$HTTP_PORT/repo2.git/subpackage?go-get=1cmpenv stdout goget.txtcurl http://localhost:$HTTP_PORT/repo2/subpackage?go-get=1cmpenv stdout goget.txt
# go-get not found (invalid method)curl -XPOST http://localhost:$HTTP_PORT/repo2/subpackage?go-get=1stdout '404.*'
# go-get not found (invalid repo)curl -XPOST http://localhost:$HTTP_PORT/repo299/subpackage?go-get=1stdout '404.*'
# set privatesoft repo private repo2 true
# allow access privatecurl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' http://$TOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcmp stdout http2.txtcurl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' http://$ETOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcmp stdout http3.txt
# deny access privatecurl -XPOST http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*credentials needed.*'curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*repository not found.*'curl -XPOST http://0$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcmp stdout http3.txt
# a wrong method is refused before authorization, for any repocurl http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchstdout '.*Method Not Allowed.*'cp stdout private.txtcurl http://localhost:$HTTP_PORT/nope.git/info/lfs/objects/batchcmp stdout private.txt
# deny dumb http gitcurl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refsstdout '401.*'curl -XGET http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/refsstdout '404.*'
# private and missing repos get the same answercurl http://localhost:$HTTP_PORT/repo2.git/info/refs?service=git-upload-packstdout '401.*'cp stdout private.txtcurl http://localhost:$HTTP_PORT/nope.git/info/refs?service=git-upload-packcmp stdout private.txtcurl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/refs?service=git-upload-packstdout '404.*'cp stdout private.txtcurl http://$UTOKEN@localhost:$HTTP_PORT/nope.git/info/refs?service=git-upload-packcmp stdout private.txtcurl http://someuser:somepassword@localhost:$HTTP_PORT/repo2.git/info/refs?service=git-upload-packstdout '403.*'cp stdout private.txtcurl http://someuser:somepassword@localhost:$HTTP_PORT/nope.git/info/refs?service=git-upload-packcmp stdout private.txtcurl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batchcp stdout private.txtcurl -XPOST -H 'Accept: application/vnd.git-lfs+json' -H 'Content-Type: application/vnd.git-lfs+json' http://localhost:$HTTP_PORT/nope.git/info/lfs/objects/batchcmp stdout private.txtcurl -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/repo2.git/info/refs?service=git-upload-packstdout '403.*'cp stdout private.txtcurl -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/nope.git/info/refs?service=git-upload-packcmp stdout private.txtcurl -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/repo2.git/HEADcp stdout private.txtcurl -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/nope.git/HEADcmp stdout private.txtcurl -XPOST -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/repo2.git/info/lfs/lockscp stdout private.txtcurl -XPOST -H 'Authorization: Bearer garbage' http://localhost:$HTTP_PORT/nope.git/info/lfs/lockscmp stdout private.txtcurl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/locksstdout '.*repository not found.*'cp stdout private.txtcurl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/nope.git/info/lfs/lockscmp stdout private.txt
# a push by a signed-in user without access answers like a missing repo,# and ?service=git-receive-pack on other routes changes nothingcurl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/refs?service=git-receive-packstdout '404.*'curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/HEAD?service=git-receive-packstdout '404.*'cp stdout private.txtcurl http://$UTOKEN@localhost:$HTTP_PORT/nope.git/HEAD?service=git-receive-packcmp stdout private.txtcurl http://localhost:$HTTP_PORT/repo2.git/HEAD?service=git-receive-packstdout '401.*'cp stdout private.txtcurl http://localhost:$HTTP_PORT/nope.git/HEAD?service=git-receive-packcmp stdout private.txtcurl http://localhost:$HTTP_PORT/repo2.git/info/refs?service=git-receive-packcp stdout private.txtcurl http://localhost:$HTTP_PORT/nope.git/info/refs?service=git-receive-packcmp stdout private.txt
# deny access ask for credentials# this means the server responded with a 401 and prompted for credentials# but we disable git terminal prompting to we get a fatal instead of a 401 "Unauthorized"! git clone http://localhost:$HTTP_PORT/repo2 repo2_clonecmpenv stderr gitclone.txt! git clone http://someuser:somepassword@localhost:$HTTP_PORT/repo2 repo2_clonestderr '.*403.*'
# go-get not found (private repo)curl http://localhost:$HTTP_PORT/repo2.git?go-get=1stdout '404.*'
# go-get forbidden (private repo & expired token)curl http://$ETOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1stdout '403.*'
# go-get not found (private repo & different user)curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1stdout '404.*'
# go-get with credscurl http://$TOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1cmpenv stdout goget.txt
# go-get subpackage of a private repo does not reveal it (GHSA-fgxm-5hvv-x4vh)curl http://localhost:$HTTP_PORT/repo2/subpackage?go-get=1stdout '404.*'! stdout 'go-import'curl http://$UTOKEN@localhost:$HTTP_PORT/repo2/sub/package?go-get=1stdout '404.*'! stdout 'go-import'curl http://$TOKEN@localhost:$HTTP_PORT/repo2/subpackage?go-get=1cmpenv stdout goget.txt
# go-get resolves a readable repo nested under an unreadable onesoft repo create outer -psoft repo create outer/innercurl http://localhost:$HTTP_PORT/outer/inner/pkg?go-get=1stdout 'go-import.*/outer/inner git'curl http://localhost:$HTTP_PORT/outer/pkg?go-get=1stdout '404.*'
# go-get does not bypass repository checks on other routescurl http://localhost:$HTTP_PORT/nope.git/info/lfs/objects/basic/0000000000000000000000000000000000000000000000000000000000000000?go-get=1stdout '.*credentials needed.*'curl http://localhost:$HTTP_PORT/nope.git/objects/info/packs?go-get=1stdout '401.*'
# stop the server[windows] stopserver[windows] ! stderr .
-- http1.txt --{"transfer":"basic","objects":[{"oid":"","size":0,"error":{"code":422,"message":"invalid object"}}],"hash_algo":"sha256"}-- http2.txt --{"message":"validation error in request: EOF"}-- http3.txt --{"message":"bad credentials"}-- goget.txt --<!DOCTYPE html><html lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="refresh" content="0; url=https://godoc.org/localhost:$HTTP_PORT/repo2"> <meta name="go-import" content="localhost:$HTTP_PORT/repo2 git http://localhost:$HTTP_PORT/repo2.git"></head><body>Redirecting to docs at <a href="https://godoc.org/localhost:$HTTP_PORT/repo2">godoc.org/localhost:$HTTP_PORT/repo2</a>...</body></html>-- gitclone.txt --Cloning into 'repo2_clone'...fatal: could not read Username for 'http://localhost:$HTTP_PORT': terminal prompts disabled