Add gun to CryptoServiceTester

The gun field is not necessary yet, but will be useful in a future
commit. But including it immediately allows us to simplify by using
an ordinary method for cryptoServiceFactory instead of closures.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2015-12-02 14:44:23 +01:00
parent 2bfadacf34
commit d3c3d70d6d
1 changed files with 10 additions and 10 deletions

View File

@ -23,9 +23,13 @@ var algoToSigType = map[string]data.SigAlgorithm{
var passphraseRetriever = func(string, string, bool, int) (string, bool, error) { return "", false, nil }
type CryptoServiceTester struct {
cryptoServiceFactory func() *CryptoService
role string
keyAlgo string
role string
keyAlgo string
gun string
}
func (c CryptoServiceTester) cryptoServiceFactory() *CryptoService {
return NewCryptoService(c.gun, trustmanager.NewKeyMemoryStore(passphraseRetriever))
}
// asserts that created key exists
@ -251,10 +255,6 @@ func (c CryptoServiceTester) errorMsg(message string, args ...interface{}) strin
}
func testCryptoService(t *testing.T, gun string) {
getTestingCryptoService := func() *CryptoService {
return NewCryptoService(
gun, trustmanager.NewKeyMemoryStore(passphraseRetriever))
}
roles := []string{
data.CanonicalRootRole,
data.CanonicalTargetsRole,
@ -265,9 +265,9 @@ func testCryptoService(t *testing.T, gun string) {
for _, role := range roles {
for algo := range algoToSigType {
cst := CryptoServiceTester{
cryptoServiceFactory: getTestingCryptoService,
role: role,
keyAlgo: algo,
role: role,
keyAlgo: algo,
gun: gun,
}
cst.TestCreateAndGetKey(t)
cst.TestCreateAndGetWhenMultipleKeystores(t)