DockerCLI/cli/command/trust/helpers_test.go

25 lines
682 B
Go
Raw Normal View History

package trust
import (
"io/ioutil"
"os"
"testing"
"github.com/theupdateframework/notary/client"
"github.com/theupdateframework/notary/passphrase"
"github.com/theupdateframework/notary/trustpinning"
"gotest.tools/v3/assert"
)
func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.NilError(t, err)
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
assert.Error(t, err, "client is offline")
}