2017-09-26 20:16:18 -04:00
|
|
|
package trust
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2018-03-05 18:53:52 -05:00
|
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
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
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
|
|
|
|
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
2018-03-06 14:44:13 -05:00
|
|
|
assert.NilError(t, err)
|
2017-09-26 20:16:18 -04:00
|
|
|
defer os.RemoveAll(tmpDir)
|
|
|
|
|
|
|
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
2018-03-06 14:44:13 -05:00
|
|
|
assert.NilError(t, err)
|
2017-09-26 20:16:18 -04:00
|
|
|
|
|
|
|
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
|
2018-03-06 15:54:24 -05:00
|
|
|
assert.Error(t, err, "client is offline")
|
2017-09-26 20:16:18 -04:00
|
|
|
}
|