1# vi: set ft=conf23# FIXME: don't skip windows4[windows] skip 'curl makes github actions hang'56# convert crlf to lf on windows7[windows] dos2unix http1.txt http2.txt http3.txt goget.txt gitclone.txt89# start soft serve10exec soft serve &11# wait for SSH server to start12ensureserverrunning SSH_PORT1314# create user15soft user create user1 --key "$USER1_AUTHORIZED_KEY"1617# create access token18soft token create --expires-in '1h' 'repo2'19stdout 'ss_*'20cp stdout tokenfile21envfile TOKEN=tokenfile22soft token create --expires-in '1ns' 'repo2'23stdout 'ss_*'24cp stdout etokenfile25envfile ETOKEN=etokenfile26usoft token create 'repo2'27stdout 'ss_*'28cp stdout utokenfile29envfile UTOKEN=utokenfile3031# push & create repo with some files, commits, tags...32mkdir ./repo233git -c init.defaultBranch=master -C repo2 init34mkfile ./repo2/README.md '# Project\nfoo'35mkfile ./repo2/foo.png 'foo'36mkfile ./repo2/bar.png 'bar'37git -C repo2 remote add origin http://$TOKEN@localhost:$HTTP_PORT/repo238git -C repo2 lfs install --local39git -C repo2 lfs track '*.png'40git -C repo2 add -A41git -C repo2 commit -m 'first'42git -C repo2 tag v0.1.043git -C repo2 push origin HEAD44git -C repo2 push origin HEAD --tags4546# dumb http git47curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refs48stdout '[0-9a-z]{40} refs/heads/master\n[0-9a-z]{40} refs/tags/v0.1.0'4950# http errors51curl -XGET http://localhost:$HTTP_PORT/repo2111foobar.git/foo/bar52stdout '404.*'53curl -XGET http://localhost:$HTTP_PORT/repo2111/foobar.git/foo/bar54stdout '404.*'55curl -XGET http://localhost:$HTTP_PORT/repo2.git/foo/bar56stdout '404.*'57curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/foo58stdout '404.*'59curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch60stdout '.*Method Not Allowed.*'61curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch62stdout '.*Not Acceptable.*'63curl -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/batch64stdout '.*validation error.*'65curl -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/batch66stdout '.*no objects found.*'67curl -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/batch68stdout '.*unsupported transfer.*'69curl -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/batch70stdout '.*unsupported operation.*'71curl -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/batch72cmp stdout http1.txt73curl -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/batch74stdout '.*write access required.*'75curl -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/batch76cmp stdout http1.txt777879# go-get allow (public repo)80curl http://localhost:$HTTP_PORT/repo2.git?go-get=181cmpenv stdout goget.txt82curl http://localhost:$HTTP_PORT/repo2.git/subpackage?go-get=183cmpenv stdout goget.txt84curl http://localhost:$HTTP_PORT/repo2/subpackage?go-get=185cmpenv stdout goget.txt8687# go-get not found (invalid method)88curl -XPOST http://localhost:$HTTP_PORT/repo2/subpackage?go-get=189stdout '404.*'9091# go-get not found (invalid repo)92curl -XPOST http://localhost:$HTTP_PORT/repo299/subpackage?go-get=193stdout '404.*'9495# set private96soft repo private repo2 true9798# allow access private99curl -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/batch100cmp stdout http2.txt101curl -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/batch102cmp stdout http3.txt103104# deny access private105curl http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch106stdout '.*credentials needed.*'107curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch108stdout '.*credentials needed.*'109curl http://0$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch110cmp stdout http3.txt111112# deny dumb http git113curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refs114stdout '404.*'115116# deny access ask for credentials117# this means the server responded with a 401 and prompted for credentials118# but we disable git terminal prompting to we get a fatal instead of a 401 "Unauthorized"119! git clone http://localhost:$HTTP_PORT/repo2 repo2_clone120cmpenv stderr gitclone.txt121! git clone http://someuser:somepassword@localhost:$HTTP_PORT/repo2 repo2_clone122stderr '.*403.*'123124# go-get not found (private repo)125curl http://localhost:$HTTP_PORT/repo2.git?go-get=1126stdout '404.*'127128# go-get forbidden (private repo & expired token)129curl http://$ETOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1130stdout '403.*'131132# go-get not found (private repo & different user)133curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1134stdout '404.*'135136# go-get with creds137curl http://$TOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1138cmpenv stdout goget.txt139140# stop the server141[windows] stopserver142[windows] ! stderr .143144-- http1.txt --145{"transfer":"basic","objects":[{"oid":"","size":0,"error":{"code":422,"message":"invalid object"}}],"hash_algo":"sha256"}146-- http2.txt --147{"message":"validation error in request: EOF"}148-- http3.txt --149{"message":"bad credentials"}150-- goget.txt --151<!DOCTYPE html>152<html lang="en">153<head>154 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>155 <meta http-equiv="refresh" content="0; url=https://godoc.org/localhost:$HTTP_PORT/repo2">156 <meta name="go-import" content="localhost:$HTTP_PORT/repo2 git http://localhost:$HTTP_PORT/repo2.git">157</head>158<body>159Redirecting to docs at <a href="https://godoc.org/localhost:$HTTP_PORT/repo2">godoc.org/localhost:$HTTP_PORT/repo2</a>...160</body>161</html>162-- gitclone.txt --163Cloning into 'repo2_clone'...164fatal: could not read Username for 'http://localhost:$HTTP_PORT': terminal prompts disabled