Skip to content

Commit

Permalink
feat: add ssh lfs-transfer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Dec 11, 2023
1 parent e02c00f commit fc81914
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
2 changes: 0 additions & 2 deletions pkg/git/lfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ func (t *lfsTransfer) StartUpload(oid string, r io.Reader, _ transfer.Args) (io.
return nil, err
}

t.logger.Infof("Object name: %s", obj.Name())

return &uploadObject{
oid: oid,
size: written,
Expand Down
1 change: 0 additions & 1 deletion testscript/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func TestScript(t *testing.T) {
cfg.HTTP.PublicURL = "http://" + httpListen
cfg.Stats.ListenAddr = statsListen
cfg.LFS.Enabled = true
// cfg.LFS.SSHEnabled = true

// Parse os SOFT_SERVE environment variables
if err := cfg.ParseEnv(); err != nil {
Expand Down
76 changes: 76 additions & 0 deletions testscript/testdata/ssh-lfs.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# vi: set ft=conf

[windows] dos2unix err1.txt err2.txt err3.txt errauth.txt

# enable ssh lfs transfer
env SOFT_SERVE_LFS_SSH_ENABLED=true
# start soft serve
exec soft serve &
# wait for server to start
waitforserver

# create a user
soft user create foo --key "$USER1_AUTHORIZED_KEY"

# create a repo
soft repo create repo1
soft repo create repo1p -p
usoft repo create repo2
usoft repo create repo2p -p

# SSH Git LFS Transfer command
! soft git-lfs-transfer
cmp stderr err1.txt
! soft git-lfs-transfer repo1
cmp stderr err2.txt
soft git-lfs-transfer repo1 download
stdout '000eversion=1\n000clocking\n0000'
soft git-lfs-transfer repo1 upload
stdout '000eversion=1\n000clocking\n0000'
usoft git-lfs-transfer repo1 download
stdout '000eversion=1\n000clocking\n0000'
! usoft git-lfs-transfer repo1 upload
cmp stderr errauth.txt

# Unauthorized user
! usoft git-lfs-transfer
cmp stderr err1.txt
! usoft git-lfs-transfer repo1p
cmp stderr err2.txt
! usoft git-lfs-transfer repo1p download
cmp stderr errauth.txt
! usoft git-lfs-transfer repo1p upload
cmp stderr errauth.txt

# push & create repo with some files, commits, tags...
mkdir ./repo1
git -c init.defaultBranch=master -C repo1 init
mkfile ./repo1/README.md '# Project\nfoo'
mkfile ./repo1/foo.png 'foo'
mkfile ./repo1/bar.png 'bar'
git -C repo1 remote add origin ssh://localhost:$SSH_PORT/repo1
git -C repo1 lfs install --local
git -C repo1 lfs track '*.png'
git -C repo1 add -A
git -C repo1 commit -m 'first'
git -C repo1 tag v0.1.0
git -C repo1 push origin HEAD
git -C repo1 push origin HEAD --tags

# clone repo with ssh lfs-transfer
git clone ssh://localhost:$SSH_PORT/repo1 repo1c
exists repo1c/README.md
exists repo1c/foo.png
exists repo1c/bar.png

# stop the server
[windows] stopserver

-- err1.txt --
Error: accepts 2 arg(s), received 0
-- err2.txt --
Error: accepts 2 arg(s), received 1
-- err3.txt --
Error: invalid request
-- errauth.txt --
Error: you are not authorized to do this

0 comments on commit fc81914

Please sign in to comment.