2017-09-26 20:16:18 -04:00
|
|
|
package trust
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2017-10-30 12:21:41 -04:00
|
|
|
"github.com/theupdateframework/notary/client"
|
|
|
|
"github.com/theupdateframework/notary/passphrase"
|
|
|
|
"github.com/theupdateframework/notary/trustpinning"
|
2017-09-26 20:16:18 -04:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
|
|
|
|
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
defer os.RemoveAll(tmpDir)
|
|
|
|
|
|
|
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
|
|
|
|
assert.EqualError(t, err, "client is offline")
|
|
|
|
}
|