Skip to content

Commit fc81914

Browse files
committed
feat: add ssh lfs-transfer tests
1 parent e02c00f commit fc81914

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

pkg/git/lfs.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ func (t *lfsTransfer) StartUpload(oid string, r io.Reader, _ transfer.Args) (io.
159159
return nil, err
160160
}
161161

162-
t.logger.Infof("Object name: %s", obj.Name())
163-
164162
return &uploadObject{
165163
oid: oid,
166164
size: written,

testscript/script_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func TestScript(t *testing.T) {
148148
cfg.HTTP.PublicURL = "http://" + httpListen
149149
cfg.Stats.ListenAddr = statsListen
150150
cfg.LFS.Enabled = true
151-
// cfg.LFS.SSHEnabled = true
152151

153152
// Parse os SOFT_SERVE environment variables
154153
if err := cfg.ParseEnv(); err != nil {

testscript/testdata/ssh-lfs.txtar

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# vi: set ft=conf
2+
3+
[windows] dos2unix err1.txt err2.txt err3.txt errauth.txt
4+
5+
# enable ssh lfs transfer
6+
env SOFT_SERVE_LFS_SSH_ENABLED=true
7+
# start soft serve
8+
exec soft serve &
9+
# wait for server to start
10+
waitforserver
11+
12+
# create a user
13+
soft user create foo --key "$USER1_AUTHORIZED_KEY"
14+
15+
# create a repo
16+
soft repo create repo1
17+
soft repo create repo1p -p
18+
usoft repo create repo2
19+
usoft repo create repo2p -p
20+
21+
# SSH Git LFS Transfer command
22+
! soft git-lfs-transfer
23+
cmp stderr err1.txt
24+
! soft git-lfs-transfer repo1
25+
cmp stderr err2.txt
26+
soft git-lfs-transfer repo1 download
27+
stdout '000eversion=1\n000clocking\n0000'
28+
soft git-lfs-transfer repo1 upload
29+
stdout '000eversion=1\n000clocking\n0000'
30+
usoft git-lfs-transfer repo1 download
31+
stdout '000eversion=1\n000clocking\n0000'
32+
! usoft git-lfs-transfer repo1 upload
33+
cmp stderr errauth.txt
34+
35+
# Unauthorized user
36+
! usoft git-lfs-transfer
37+
cmp stderr err1.txt
38+
! usoft git-lfs-transfer repo1p
39+
cmp stderr err2.txt
40+
! usoft git-lfs-transfer repo1p download
41+
cmp stderr errauth.txt
42+
! usoft git-lfs-transfer repo1p upload
43+
cmp stderr errauth.txt
44+
45+
# push & create repo with some files, commits, tags...
46+
mkdir ./repo1
47+
git -c init.defaultBranch=master -C repo1 init
48+
mkfile ./repo1/README.md '# Project\nfoo'
49+
mkfile ./repo1/foo.png 'foo'
50+
mkfile ./repo1/bar.png 'bar'
51+
git -C repo1 remote add origin ssh://localhost:$SSH_PORT/repo1
52+
git -C repo1 lfs install --local
53+
git -C repo1 lfs track '*.png'
54+
git -C repo1 add -A
55+
git -C repo1 commit -m 'first'
56+
git -C repo1 tag v0.1.0
57+
git -C repo1 push origin HEAD
58+
git -C repo1 push origin HEAD --tags
59+
60+
# clone repo with ssh lfs-transfer
61+
git clone ssh://localhost:$SSH_PORT/repo1 repo1c
62+
exists repo1c/README.md
63+
exists repo1c/foo.png
64+
exists repo1c/bar.png
65+
66+
# stop the server
67+
[windows] stopserver
68+
69+
-- err1.txt --
70+
Error: accepts 2 arg(s), received 0
71+
-- err2.txt --
72+
Error: accepts 2 arg(s), received 1
73+
-- err3.txt --
74+
Error: invalid request
75+
-- errauth.txt --
76+
Error: you are not authorized to do this

0 commit comments

Comments
 (0)