-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix GPG ID lookup and remove hardcoded test credentials #2274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
29dd825
32654f4
c5128fa
b879c63
6d53ee6
25b7027
29f16b3
50bae92
b641577
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,17 +23,19 @@ public GpgPassCredentialStore(IFileSystem fileSystem, IGpg gpg, string storeRoot | |
|
|
||
| private string GetGpgId() | ||
| { | ||
| string gpgIdPath = Path.Combine(StoreRoot, ".gpg-id"); | ||
| if (!FileSystem.FileExists(gpgIdPath)) | ||
| // Search for a .gpg-id file anywhere under the store root. | ||
| // This handles configurations where .gpg-id is in a subdirectory | ||
| // (e.g., a git submodule) rather than the store root itself. | ||
| foreach (string gpgIdPath in FileSystem.EnumerateFiles(StoreRoot, ".gpg-id")) | ||
|
||
| { | ||
| throw new Exception($"Cannot find GPG ID in '{gpgIdPath}'; password store has not been initialized"); | ||
| using (var stream = FileSystem.OpenFileStream(gpgIdPath, FileMode.Open, FileAccess.Read, FileShare.Read)) | ||
| using (var reader = new StreamReader(stream)) | ||
| { | ||
| return reader.ReadLine(); | ||
| } | ||
| } | ||
|
|
||
| using (var stream = FileSystem.OpenFileStream(gpgIdPath, FileMode.Open, FileAccess.Read, FileShare.Read)) | ||
| using (var reader = new StreamReader(stream)) | ||
| { | ||
| return reader.ReadLine(); | ||
| } | ||
| throw new Exception($"Cannot find GPG ID in password store at '{StoreRoot}'; run `pass init <gpg-id>` to initialize the store."); | ||
| } | ||
|
|
||
| protected override bool TryDeserializeCredential(string path, out FileCredential credential) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is now only used in one test. Can we inline this in the
GnuPassCredentialStore_ReadWriteDelete_GpgIdInSubdirectorytest, so that it matches the other test (GnuPassCredentialStore_WriteCredential_MultipleGpgIds_UsesNearestGpgId) that does all the store/.gpg-id setup in the test method?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b641577. The
InitializePasswordStoreWithGpgIdInSubdirectoryhelper has been removed and its logic inlined directly intoGnuPassCredentialStore_ReadWriteDelete_GpgIdInSubdirectory, matching the style of theMultipleGpgIdstest.