...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package ssh
19
20 import (
21 "github.com/sigstore/rekor/pkg/util"
22 "io/ioutil"
23 "path/filepath"
24 "strings"
25 "testing"
26 )
27
28 func TestSSH(t *testing.T) {
29 td := t.TempDir()
30
31 keyPath := filepath.Join(td, "id_rsa")
32 pubPath := filepath.Join(td, "id_rsa.pub")
33
34 if err := ioutil.WriteFile(pubPath, []byte(publicKey), 0600); err != nil {
35 t.Fatal(err)
36 }
37 if err := ioutil.WriteFile(keyPath, []byte(privateKey), 0600); err != nil {
38 t.Fatal(err)
39 }
40
41
42 artifactPath := filepath.Join(td, "artifact")
43 sigPath := filepath.Join(td, "signature.sig")
44 artifact := util.CreateArtifact(t, artifactPath)
45
46 sig := SSHSign(t, strings.NewReader(artifact))
47 if err := ioutil.WriteFile(sigPath, []byte(sig), 0600); err != nil {
48 t.Fatal(err)
49 }
50
51
52 out := util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
53 "--public-key", pubPath, "--pki-format", "ssh")
54 util.OutputContains(t, out, "Created entry at")
55
56 uuid := util.GetUUIDFromUploadOutput(t, out)
57
58 out = util.RunCli(t, "verify", "--artifact", artifactPath, "--signature", sigPath,
59 "--public-key", pubPath, "--pki-format", "ssh")
60 util.OutputContains(t, out, "Inclusion Proof")
61
62 out = util.RunCli(t, "search", "--public-key", pubPath, "--pki-format", "ssh")
63 util.OutputContains(t, out, uuid)
64 }
65
View as plain text