-
Notifications
You must be signed in to change notification settings - Fork 141
/
http.txtar
164 lines (141 loc) · 6.51 KB
/
http.txtar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# 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 serve
exec soft serve &
# wait for SSH server to start
ensureserverrunning SSH_PORT
# 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.*'
# go-get not found (invalid repo)
curl -XPOST http://localhost:$HTTP_PORT/repo299/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
# 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