1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package x509
20
21 import (
22 "os"
23 "path/filepath"
24 "testing"
25
26 "github.com/sigstore/rekor/pkg/util"
27 )
28
29 func TestX509(t *testing.T) {
30 td := t.TempDir()
31 artifactPath := filepath.Join(td, "artifact")
32 sigPath := filepath.Join(td, "signature")
33 certPath := filepath.Join(td, "cert.pem")
34 pubKeyPath := filepath.Join(td, "key.pem")
35
36 CreatedX509SignedArtifact(t, artifactPath, sigPath)
37
38 if err := os.WriteFile(certPath, []byte(RSACert), 0o644); err != nil {
39 t.Fatal(err)
40 }
41 if err := os.WriteFile(pubKeyPath, []byte(PubKey), 0o644); err != nil {
42 t.Fatal(err)
43 }
44
45
46 out := util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
47 "--public-key", certPath, "--pki-format", "x509")
48 util.OutputContains(t, out, "Created entry at")
49 out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
50 "--public-key", certPath, "--pki-format", "x509")
51 util.OutputContains(t, out, "Entry already exists")
52
53
54 out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
55 "--public-key", pubKeyPath, "--pki-format", "x509")
56 util.OutputContains(t, out, "Created entry at")
57
58
59 CreatedX509SignedArtifact(t, artifactPath, sigPath)
60
61 out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
62 "--public-key", pubKeyPath, "--pki-format", "x509")
63 util.OutputContains(t, out, "Created entry at")
64 out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
65 "--public-key", pubKeyPath, "--pki-format", "x509")
66 util.OutputContains(t, out, "Entry already exists")
67
68 out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath,
69 "--public-key", certPath, "--pki-format", "x509")
70 util.OutputContains(t, out, "Created entry at")
71 uuid := util.GetUUIDFromUploadOutput(t, out)
72
73
74 out = util.RunCli(t, "search", "--email", "test@rekor.dev")
75 util.OutputContains(t, out, uuid)
76 }
77
View as plain text