- commit
- 5c8d929
- parent
- 57bb60c
- author
- Eric Bower
- date
- 2025-02-21 21:10:34 -0500 EST
chore: test is failing on `--delete` Alright, the test is failing because of the new `--delete` flag. ``` time=2025-02-21T21:10:11.225-05:00 level=ERROR source=/home/erock/go/pkg/mod/github.com/picosh/send@v0.0.0-20250213162645-ec2027b68462/protocols/rsync/rsync.go:157 msg="error running rsync middleware" service=pgs err="runtime error: index out of range [7876097] with length 0" ```
3 files changed,
+26,
-14
M
go.mod
+1,
-0
1@@ -48,6 +48,7 @@ require (
2 github.com/jmoiron/sqlx v1.4.0
3 github.com/lib/pq v1.10.9
4 github.com/microcosm-cc/bluemonday v1.0.27
5+ github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
6 github.com/minio/minio-go/v7 v7.0.80
7 github.com/mmcdole/gofeed v1.3.0
8 github.com/muesli/reflow v0.3.0
M
go.sum
+2,
-0
1@@ -634,6 +634,8 @@ github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKju
2 github.com/miekg/dns v1.1.45/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
3 github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
4 github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
5+github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a h1:eU8j/ClY2Ty3qdHnn0TyW3ivFoPC/0F1gQZz8yTxbbE=
6+github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a/go.mod h1:v8eSC2SMp9/7FTKUncp7fH9IwPfw+ysMObcEz5FWheQ=
7 github.com/minio/madmin-go/v3 v3.0.77 h1:cqp5kVeT5anDyocvoN81puwpy+GN7t+Xdj6xCLpnONE=
8 github.com/minio/madmin-go/v3 v3.0.77/go.mod h1:ku/RUc2xeo4Uui/GHUURMoNEVXk4Ih40xA3KHLyMF1o=
9 github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
+23,
-14
1@@ -3,7 +3,6 @@ package pgs
2 import (
3 "crypto/ed25519"
4 "crypto/rand"
5- "crypto/x509"
6 "encoding/pem"
7 "fmt"
8 "io"
9@@ -15,6 +14,7 @@ import (
10 "testing"
11 "time"
12
13+ "github.com/mikesmitty/edkey"
14 "github.com/picosh/pico/db"
15 pgsdb "github.com/picosh/pico/pgs/db"
16 "github.com/picosh/pico/shared/storage"
17@@ -24,7 +24,13 @@ import (
18 )
19
20 func TestSshServerSftp(t *testing.T) {
21- logger := slog.Default()
22+ opts := &slog.HandlerOptions{
23+ AddSource: true,
24+ Level: slog.LevelInfo,
25+ }
26+ logger := slog.New(
27+ slog.NewTextHandler(os.Stdout, opts),
28+ )
29 dbpool := pgsdb.NewDBMemory(logger)
30 // setup test data
31 dbpool.SetupTestData()
32@@ -63,7 +69,13 @@ func TestSshServerSftp(t *testing.T) {
33 }
34
35 func TestSshServerRsync(t *testing.T) {
36- logger := slog.Default()
37+ opts := &slog.HandlerOptions{
38+ AddSource: true,
39+ Level: slog.LevelInfo,
40+ }
41+ logger := slog.New(
42+ slog.NewTextHandler(os.Stdout, opts),
43+ )
44 dbpool := pgsdb.NewDBMemory(logger)
45 // setup test data
46 dbpool.SetupTestData()
47@@ -107,10 +119,10 @@ func TestSshServerRsync(t *testing.T) {
48 }
49
50 // remove the temporary directory at the end of the program
51- defer os.RemoveAll(name)
52+ // defer os.RemoveAll(name)
53
54 block := &pem.Block{
55- Type: "PRIVATE KEY",
56+ Type: "OPENSSH PRIVATE KEY",
57 Bytes: user.privateKey,
58 }
59 keyFile := filepath.Join(name, "id_ed25519")
60@@ -139,7 +151,7 @@ func TestSshServerRsync(t *testing.T) {
61 )
62
63 eCmd := fmt.Sprintf(
64- `"ssh -p 2222 -o IdentitiesOnly=yes -i %s -o StrictHostKeyChecking=no"`,
65+ "ssh -p 2222 -o IdentitiesOnly=yes -i %s -o StrictHostKeyChecking=no",
66 keyFile,
67 )
68
69@@ -154,13 +166,13 @@ func TestSshServerRsync(t *testing.T) {
70 }
71
72 // check it's there
73- fi, err := client.Lstat("about.html")
74+ fi, err := client.Lstat("/test/about.html")
75 if err != nil {
76 cfg.Logger.Error("could not get stat for file", "err", err)
77 t.Error("about.html not found")
78 return
79 }
80- if fi.Size() != 0 {
81+ if fi.Size() != 46 {
82 cfg.Logger.Error("about.html wrong size", "size", fi.Size())
83 t.Error("about.html wrong size")
84 return
85@@ -171,8 +183,9 @@ func TestSshServerRsync(t *testing.T) {
86
87 // copy files with delete
88 delCmd := exec.Command("rsync", "-rv", "--delete", "-e", eCmd, name+"/", "localhost:/test")
89- err = delCmd.Run()
90+ result, err = delCmd.CombinedOutput()
91 if err != nil {
92+ fmt.Println(string(result), err)
93 t.Error(err)
94 return
95 }
96@@ -284,11 +297,7 @@ func GenerateUser() UserSSH {
97 panic(err)
98 }
99
100- b, err := x509.MarshalPKCS8PrivateKey(userKey)
101- if err != nil {
102- panic(err)
103- }
104-
105+ b := edkey.MarshalED25519PrivateKey(userKey)
106 userSigner, err := ssh.NewSignerFromKey(userKey)
107 if err != nil {
108 panic(err)