Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/clients/tuftool.go → pkg/clients/tufcli.go
Original file line number Diff line number Diff line change
@@ -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",
}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/cgw/cgw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tuftool
package tufcli

import (
"fmt"
Expand Down Expand Up @@ -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 {
Expand All @@ -61,17 +61,16 @@ 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() {
verifyWorkdirStructure(workdir)
})
})

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")
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tuftool
package tufcli

import (
"testing"
Expand Down
Loading