fix tests

This commit is contained in:
Jeffrey Paul 2025-06-08 22:13:22 -07:00
parent fbda2d91af
commit d76a4cbf4d
3 changed files with 9 additions and 9 deletions

View File

@ -188,7 +188,7 @@ func NewKeychainUnlocker(fs afero.Fs, directory string, metadata UnlockerMetadat
// GetKeychainItemName returns the keychain item name from metadata // GetKeychainItemName returns the keychain item name from metadata
func (k *KeychainUnlocker) GetKeychainItemName() (string, error) { func (k *KeychainUnlocker) GetKeychainItemName() (string, error) {
// Load the metadata // Load the metadata
metadataPath := filepath.Join(k.Directory, "unlock-metadata.json") metadataPath := filepath.Join(k.Directory, "unlocker-metadata.json")
metadataData, err := afero.ReadFile(k.fs, metadataPath) metadataData, err := afero.ReadFile(k.fs, metadataPath)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to read keychain metadata: %w", err) return "", fmt.Errorf("failed to read keychain metadata: %w", err)
@ -383,7 +383,7 @@ func CreateKeychainUnlocker(fs afero.Fs, stateDir string) (*KeychainUnlocker, er
return nil, fmt.Errorf("failed to marshal unlocker metadata: %w", err) return nil, fmt.Errorf("failed to marshal unlocker metadata: %w", err)
} }
if err := afero.WriteFile(fs, filepath.Join(unlockerDir, "unlock-metadata.json"), metadataBytes, FilePerms); err != nil { if err := afero.WriteFile(fs, filepath.Join(unlockerDir, "unlocker-metadata.json"), metadataBytes, FilePerms); err != nil {
return nil, fmt.Errorf("failed to write unlocker metadata: %w", err) return nil, fmt.Errorf("failed to write unlocker metadata: %w", err)
} }

View File

@ -147,7 +147,7 @@ func NewPGPUnlocker(fs afero.Fs, directory string, metadata UnlockerMetadata) *P
// GetGPGKeyID returns the GPG key ID from metadata // GetGPGKeyID returns the GPG key ID from metadata
func (p *PGPUnlocker) GetGPGKeyID() (string, error) { func (p *PGPUnlocker) GetGPGKeyID() (string, error) {
// Load the metadata // Load the metadata
metadataPath := filepath.Join(p.Directory, "unlock-metadata.json") metadataPath := filepath.Join(p.Directory, "unlocker-metadata.json")
metadataData, err := afero.ReadFile(p.fs, metadataPath) metadataData, err := afero.ReadFile(p.fs, metadataPath)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to read PGP metadata: %w", err) return "", fmt.Errorf("failed to read PGP metadata: %w", err)
@ -313,7 +313,7 @@ func CreatePGPUnlocker(fs afero.Fs, stateDir string, gpgKeyID string) (*PGPUnloc
return nil, fmt.Errorf("failed to marshal unlocker metadata: %w", err) return nil, fmt.Errorf("failed to marshal unlocker metadata: %w", err)
} }
if err := afero.WriteFile(fs, filepath.Join(unlockerDir, "unlock-metadata.json"), metadataBytes, FilePerms); err != nil { if err := afero.WriteFile(fs, filepath.Join(unlockerDir, "unlocker-metadata.json"), metadataBytes, FilePerms); err != nil {
return nil, fmt.Errorf("failed to write unlocker metadata: %w", err) return nil, fmt.Errorf("failed to write unlocker metadata: %w", err)
} }

View File

@ -59,7 +59,7 @@ func (v *Vault) GetCurrentUnlocker() (secret.Unlocker, error) {
) )
// Read unlocker metadata // Read unlocker metadata
metadataPath := filepath.Join(unlockerDir, "unlock-metadata.json") metadataPath := filepath.Join(unlockerDir, "unlocker-metadata.json")
secret.Debug("Reading unlocker metadata", "path", metadataPath) secret.Debug("Reading unlocker metadata", "path", metadataPath)
metadataBytes, err := afero.ReadFile(v.fs, metadataPath) metadataBytes, err := afero.ReadFile(v.fs, metadataPath)
@ -137,7 +137,7 @@ func (v *Vault) ListUnlockers() ([]UnlockerMetadata, error) {
for _, file := range files { for _, file := range files {
if file.IsDir() { if file.IsDir() {
// Read metadata file // Read metadata file
metadataPath := filepath.Join(unlockersDir, file.Name(), "unlock-metadata.json") metadataPath := filepath.Join(unlockersDir, file.Name(), "unlocker-metadata.json")
exists, err := afero.Exists(v.fs, metadataPath) exists, err := afero.Exists(v.fs, metadataPath)
if err != nil { if err != nil {
continue continue
@ -184,7 +184,7 @@ func (v *Vault) RemoveUnlocker(unlockerID string) error {
for _, file := range files { for _, file := range files {
if file.IsDir() { if file.IsDir() {
// Read metadata file // Read metadata file
metadataPath := filepath.Join(unlockersDir, file.Name(), "unlock-metadata.json") metadataPath := filepath.Join(unlockersDir, file.Name(), "unlocker-metadata.json")
exists, err := afero.Exists(v.fs, metadataPath) exists, err := afero.Exists(v.fs, metadataPath)
if err != nil || !exists { if err != nil || !exists {
continue continue
@ -250,7 +250,7 @@ func (v *Vault) SelectUnlocker(unlockerID string) error {
for _, file := range files { for _, file := range files {
if file.IsDir() { if file.IsDir() {
// Read metadata file // Read metadata file
metadataPath := filepath.Join(unlockersDir, file.Name(), "unlock-metadata.json") metadataPath := filepath.Join(unlockersDir, file.Name(), "unlocker-metadata.json")
exists, err := afero.Exists(v.fs, metadataPath) exists, err := afero.Exists(v.fs, metadataPath)
if err != nil || !exists { if err != nil || !exists {
continue continue
@ -345,7 +345,7 @@ func (v *Vault) CreatePassphraseUnlocker(passphrase string) (*secret.PassphraseU
return nil, fmt.Errorf("failed to marshal metadata: %w", err) return nil, fmt.Errorf("failed to marshal metadata: %w", err)
} }
metadataPath := filepath.Join(unlockerDir, "unlock-metadata.json") metadataPath := filepath.Join(unlockerDir, "unlocker-metadata.json")
if err := afero.WriteFile(v.fs, metadataPath, metadataBytes, secret.FilePerms); err != nil { if err := afero.WriteFile(v.fs, metadataPath, metadataBytes, secret.FilePerms); err != nil {
return nil, fmt.Errorf("failed to write unlocker metadata: %w", err) return nil, fmt.Errorf("failed to write unlocker metadata: %w", err)
} }