# 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 # create user soft user create user1 --key "$USER1_AUTHORIZED_KEY" # create access token soft token create --expires-in '1h' 'repo2' stdout 'ss_*' cp stdout tokenfile envfile TOKEN=tokenfile soft token create --expires-in '1ns' 'repo2' stdout 'ss_*' cp stdout etokenfile envfile ETOKEN=etokenfile usoft token create 'repo2' stdout 'ss_*' cp stdout utokenfile envfile UTOKEN=utokenfile # push & create repo with some files, commits, tags... mkdir ./repo2 git -c init.defaultBranch=master -C repo2 init mkfile ./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/repo2 git -C repo2 lfs install --local git -C repo2 lfs track '*.png' git -C repo2 add -A git -C repo2 commit -m 'first' git -C repo2 tag v0.1.0 git -C repo2 push origin HEAD git -C repo2 push origin HEAD --tags # dumb http git curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refs stdout '[0-9a-z]{40} refs/heads/master\n[0-9a-z]{40} refs/tags/v0.1.0' # http errors curl -XGET http://localhost:$HTTP_PORT/repo2111foobar.git/foo/bar stdout '404.*' curl -XGET http://localhost:$HTTP_PORT/repo2111/foobar.git/foo/bar stdout '404.*' curl -XGET http://localhost:$HTTP_PORT/repo2.git/foo/bar stdout '404.*' curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/foo stdout '404.*' curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch stdout '.*Method Not Allowed.*' curl -XPOST http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch stdout '.*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/batch stdout '.*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/batch stdout '.*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/batch stdout '.*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/batch stdout '.*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/batch cmp stdout http1.txt curl -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/batch stdout '.*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/batch cmp stdout http1.txt # go-get allow (public repo) curl http://localhost:$HTTP_PORT/repo2.git?go-get=1 cmpenv stdout goget.txt curl http://localhost:$HTTP_PORT/repo2.git/subpackage?go-get=1 cmpenv stdout goget.txt curl http://localhost:$HTTP_PORT/repo2/subpackage?go-get=1 cmpenv stdout goget.txt # go-get not found (invalid method) curl -XPOST http://localhost:$HTTP_PORT/repo2/subpackage?go-get=1 stdout '404.*' # set private soft repo private repo2 true # allow access private 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/batch cmp stdout http2.txt curl -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/batch cmp stdout http3.txt # deny access private curl http://localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch stdout '.*credentials needed.*' curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch stdout '.*credentials needed.*' curl http://0$UTOKEN@localhost:$HTTP_PORT/repo2.git/info/lfs/objects/batch cmp stdout http3.txt # deny dumb http git curl -XGET http://localhost:$HTTP_PORT/repo2.git/info/refs stdout '404.*' # 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_clone cmpenv stderr gitclone.txt ! git clone http://someuser:somepassword@localhost:$HTTP_PORT/repo2 repo2_clone stderr '.*403.*' # go-get not found (private repo) curl http://localhost:$HTTP_PORT/repo2.git?go-get=1 stdout '404.*' # go-get forbidden (private repo & expired token) curl http://$ETOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1 stdout '403.*' # go-get not found (private repo & different user) curl http://$UTOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1 stdout '404.*' # go-get with creds curl http://$TOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1 cmpenv stdout goget.txt -- 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 -- Redirecting to docs at godoc.org/localhost:$HTTP_PORT/repo2... -- gitclone.txt -- Cloning into 'repo2_clone'... fatal: could not read Username for 'http://localhost:$HTTP_PORT': terminal prompts disabled