From eae4c38023c8bf337a11d3294d835e01a473dfd2 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 2 Mar 2025 14:15:33 +0100 Subject: [PATCH] internal/test/notary: add testPassRetriever helper Add a basic helper to provide the equivalent of passphrase.ConstantRetriever with a fixed passphrase for testing. Signed-off-by: Sebastiaan van Stijn --- internal/test/notary/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/test/notary/client.go b/internal/test/notary/client.go index 3ee625fd3b..a948ad62cf 100644 --- a/internal/test/notary/client.go +++ b/internal/test/notary/client.go @@ -5,7 +5,6 @@ import ( "github.com/theupdateframework/notary/client" "github.com/theupdateframework/notary/client/changelist" "github.com/theupdateframework/notary/cryptoservice" - "github.com/theupdateframework/notary/passphrase" "github.com/theupdateframework/notary/storage" "github.com/theupdateframework/notary/trustmanager" "github.com/theupdateframework/notary/tuf/data" @@ -494,11 +493,17 @@ func (LoadedNotaryRepository) GetDelegationRoles() ([]data.Role, error) { return loadedDelegationRoles, nil } +const testPass = "password" + +func testPassRetriever(string, string, bool, int) (string, bool, error) { + return testPass, false, nil +} + // GetCryptoService is the getter for the repository's CryptoService func (l LoadedNotaryRepository) GetCryptoService() signed.CryptoService { if l.statefulCryptoService == nil { // give it an in-memory cryptoservice with a root key and targets key - l.statefulCryptoService = cryptoservice.NewCryptoService(trustmanager.NewKeyMemoryStore(passphrase.ConstantRetriever("password"))) + l.statefulCryptoService = cryptoservice.NewCryptoService(trustmanager.NewKeyMemoryStore(testPassRetriever)) l.statefulCryptoService.AddKey(data.CanonicalRootRole, l.GetGUN(), nil) l.statefulCryptoService.AddKey(data.CanonicalTargetsRole, l.GetGUN(), nil) }