From 85fb37e7a561d0e7696703574d82419fddc19316 Mon Sep 17 00:00:00 2001 From: Firas Ghanmi Date: Fri, 31 Jul 2026 11:14:57 +0200 Subject: [PATCH] replace tuftool with tufcli Signed-off-by: Firas Ghanmi --- pkg/clients/{tuftool.go => tufcli.go} | 8 +-- pkg/strategy/cgw/cgw_test.go | 2 +- test/{tuftool => tufcli}/targets/ctfe.pub | 0 .../targets/fulcio_v1.crt.pem | 0 test/{tuftool => tufcli}/targets/rekor.pub | 0 .../targets/tsa.certchain.pem | 0 .../tufcli_manual_tuf_repo_test.go} | 55 +++++++++---------- .../tufcli_suite_init_test.go} | 2 +- 8 files changed, 33 insertions(+), 34 deletions(-) rename pkg/clients/{tuftool.go => tufcli.go} (54%) rename test/{tuftool => tufcli}/targets/ctfe.pub (100%) rename test/{tuftool => tufcli}/targets/fulcio_v1.crt.pem (100%) rename test/{tuftool => tufcli}/targets/rekor.pub (100%) rename test/{tuftool => tufcli}/targets/tsa.certchain.pem (100%) rename test/{tuftool/tuftool_manual_tuf_repo_test.go => tufcli/tufcli_manual_tuf_repo_test.go} (76%) rename test/{tuftool/tuftool_suite_init_test.go => tufcli/tufcli_suite_init_test.go} (92%) diff --git a/pkg/clients/tuftool.go b/pkg/clients/tufcli.go similarity index 54% rename from pkg/clients/tuftool.go rename to pkg/clients/tufcli.go index d480f4c..2edfbcc 100644 --- a/pkg/clients/tuftool.go +++ b/pkg/clients/tufcli.go @@ -1,13 +1,13 @@ package clients -type Tuftool struct { +type Tufcli struct { *cli } -func NewTuftool() *Tuftool { - return &Tuftool{ +func NewTufcli() *Tufcli { + return &Tufcli{ &cli{ - Name: "tuftool", + Name: "tufcli", setupStrategy: PreferredSetupStrategy(), versionCommand: "--version", }} diff --git a/pkg/strategy/cgw/cgw_test.go b/pkg/strategy/cgw/cgw_test.go index d0347bf..4dbe50a 100644 --- a/pkg/strategy/cgw/cgw_test.go +++ b/pkg/strategy/cgw/cgw_test.go @@ -21,7 +21,7 @@ func TestContentGatewayName(t *testing.T) { {"gitsign", "gitsign_cli"}, {"rekor-cli", "rekor_cli"}, {"ec", "ec"}, - {"tuftool", "tuftool"}, + {"tufcli", "tufcli"}, {"createtree", "createtree"}, {"some-other-tool", "some_other_tool"}, } diff --git a/test/tuftool/targets/ctfe.pub b/test/tufcli/targets/ctfe.pub similarity index 100% rename from test/tuftool/targets/ctfe.pub rename to test/tufcli/targets/ctfe.pub diff --git a/test/tuftool/targets/fulcio_v1.crt.pem b/test/tufcli/targets/fulcio_v1.crt.pem similarity index 100% rename from test/tuftool/targets/fulcio_v1.crt.pem rename to test/tufcli/targets/fulcio_v1.crt.pem diff --git a/test/tuftool/targets/rekor.pub b/test/tufcli/targets/rekor.pub similarity index 100% rename from test/tuftool/targets/rekor.pub rename to test/tufcli/targets/rekor.pub diff --git a/test/tuftool/targets/tsa.certchain.pem b/test/tufcli/targets/tsa.certchain.pem similarity index 100% rename from test/tuftool/targets/tsa.certchain.pem rename to test/tufcli/targets/tsa.certchain.pem diff --git a/test/tuftool/tuftool_manual_tuf_repo_test.go b/test/tufcli/tufcli_manual_tuf_repo_test.go similarity index 76% rename from test/tuftool/tuftool_manual_tuf_repo_test.go rename to test/tufcli/tufcli_manual_tuf_repo_test.go index 0516fb6..4d0bb71 100644 --- a/test/tuftool/tuftool_manual_tuf_repo_test.go +++ b/test/tufcli/tufcli_manual_tuf_repo_test.go @@ -1,4 +1,4 @@ -package tuftool +package tufcli import ( "fmt" @@ -34,20 +34,20 @@ const expirationDays10 string = "in 10 days" var _ = Describe("TUF manual repo test", Ordered, func() { var ( - err error - tuftool *clients.Tuftool + err error + tufcli *clients.Tufcli ) BeforeAll(func() { - tuftool = clients.NewTuftool() + tufcli = clients.NewTufcli() openshiftStrategyActive := api.GetValueFor(api.CliStrategy) == "openshift" if openshiftStrategyActive && (runtime.GOOS != "linux" || runtime.GOARCH != "amd64") { - logrus.Info("Skipping tuftool download test: openshift strategy is only supported on linux/amd64") - Skip("Skipping tuftool download test: openshift strategy is only supported on linux/amd64") + logrus.Info("Skipping tufcli download test: openshift strategy is only supported on linux/amd64") + Skip("Skipping tufcli download test: openshift strategy is only supported on linux/amd64") } - Expect(testsupport.InstallPrerequisites(tuftool)).To(Succeed()) + Expect(testsupport.InstallPrerequisites(tufcli)).To(Succeed()) DeferCleanup(func() { if err := testsupport.DestroyPrerequisites(); err != nil { @@ -61,8 +61,8 @@ var _ = Describe("TUF manual repo test", Ordered, func() { logrus.Infof("Created temporary directory: %s", workdir) }) - It("should setup repository via tuftool", func() { - setupManualTufRepo(tuftool) + It("should setup repository via tufcli", func() { + setupManualTufRepo(tufcli) }) It("should verify workdir structure", func() { @@ -70,8 +70,7 @@ var _ = Describe("TUF manual repo test", Ordered, func() { }) }) -func setupManualTufRepo(tuftool *clients.Tuftool) { - // "Tuf repo directory" +func setupManualTufRepo(tufcli *clients.Tufcli) { root = filepath.Join(workdir, "root", "root.json") rootDir = filepath.Join(workdir, "root") input = filepath.Join(workdir, "input") @@ -87,22 +86,22 @@ func setupManualTufRepo(tuftool *clients.Tuftool) { err = os.MkdirAll(tufRepo, os.ModePerm) Expect(err).ToNot(HaveOccurred()) - Expect(tuftool.Command(testsupport.TestContext, "root", "init", root).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "expire", root, expirationWeeks52).Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "init", "--path", root).Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "expire", "--path", root, "--time", expirationWeeks52).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "set-threshold", root, "root", "1").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "set-threshold", root, "snapshot", "1").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "set-threshold", root, "targets", "1").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "set-threshold", root, "timestamp", "1").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "set-threshold", "--path", root, "--role", "root", "--threshold", "1").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "set-threshold", "--path", root, "--role", "snapshot", "--threshold", "1").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "set-threshold", "--path", root, "--role", "targets", "--threshold", "1").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "set-threshold", "--path", root, "--role", "timestamp", "--threshold", "1").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "gen-rsa-key", root, keyDir+"/root.pem", "--role", "root").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "gen-rsa-key", root, keyDir+"/snapshot.pem", "--role", "snapshot").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "gen-rsa-key", root, keyDir+"/targets.pem", "--role", "targets").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "gen-rsa-key", root, keyDir+"/timestamp.pem", "--role", "timestamp").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "gen-rsa-key", "--path", root, "--output", keyDir+"/root.pem", "--role", "root").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "gen-rsa-key", "--path", root, "--output", keyDir+"/snapshot.pem", "--role", "snapshot").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "gen-rsa-key", "--path", root, "--output", keyDir+"/targets.pem", "--role", "targets").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "gen-rsa-key", "--path", root, "--output", keyDir+"/timestamp.pem", "--role", "timestamp").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "root", "sign", root, "-k", keyDir+"/root.pem").Run()).To(Succeed()) + Expect(tufcli.Command(testsupport.TestContext, "root", "sign", "--path", root, "--key", keyDir+"/root.pem").Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "create", + Expect(tufcli.Command(testsupport.TestContext, "create", "--root", root, "--key", keyDir+"/root.pem", "--key", keyDir+"/snapshot.pem", @@ -117,7 +116,7 @@ func setupManualTufRepo(tuftool *clients.Tuftool) { "--timestamp-version", "1", "--outdir", tufRepo).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "rhtas", + Expect(tufcli.Command(testsupport.TestContext, "rhtas", "--root", root, "--key", keyDir+"/root.pem", "--key", keyDir+"/snapshot.pem", @@ -135,7 +134,7 @@ func setupManualTufRepo(tuftool *clients.Tuftool) { "--outdir", tufRepo, "--metadata-url", "file://"+tufRepo).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "rhtas", + Expect(tufcli.Command(testsupport.TestContext, "rhtas", "--root", root, "--key", keyDir+"/root.pem", "--key", keyDir+"/snapshot.pem", @@ -153,7 +152,7 @@ func setupManualTufRepo(tuftool *clients.Tuftool) { "--outdir", tufRepo, "--metadata-url", "file://"+tufRepo).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "rhtas", + Expect(tufcli.Command(testsupport.TestContext, "rhtas", "--root", root, "--key", keyDir+"/root.pem", "--key", keyDir+"/snapshot.pem", @@ -171,7 +170,7 @@ func setupManualTufRepo(tuftool *clients.Tuftool) { "--outdir", tufRepo, "--metadata-url", "file://"+tufRepo).Run()).To(Succeed()) - Expect(tuftool.Command(testsupport.TestContext, "rhtas", + Expect(tufcli.Command(testsupport.TestContext, "rhtas", "--root", root, "--key", keyDir+"/root.pem", "--key", keyDir+"/snapshot.pem", @@ -223,7 +222,7 @@ func verifyWorkdirStructure(rootPath string) { foundSuffixesCount := make(map[string]int) for _, suffix := range targetSuffixes { - foundSuffixesCount[suffix] = 0 // Initialize count for each suffix + foundSuffixesCount[suffix] = 0 } err := filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error { diff --git a/test/tuftool/tuftool_suite_init_test.go b/test/tufcli/tufcli_suite_init_test.go similarity index 92% rename from test/tuftool/tuftool_suite_init_test.go rename to test/tufcli/tufcli_suite_init_test.go index d0520d0..d124590 100644 --- a/test/tuftool/tuftool_suite_init_test.go +++ b/test/tufcli/tufcli_suite_init_test.go @@ -1,4 +1,4 @@ -package tuftool +package tufcli import ( "testing"