Skip to content

Commit b641577

Browse files
Copilotmjcheetham
andcommitted
Inline InitializePasswordStoreWithGpgIdInSubdirectory into its only test
Co-authored-by: mjcheetham <5658207+mjcheetham@users.noreply.github.com>
1 parent 50bae92 commit b641577

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

src/shared/Core.Tests/Interop/Posix/GnuPassCredentialStoreTests.cs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,25 @@ public void GnuPassCredentialStore_ReadWriteDelete_GpgIdInSubdirectory()
9191
{
9292
var fs = new TestFileSystem();
9393
var gpg = new TestGpg(fs);
94-
string storeRoot = InitializePasswordStoreWithGpgIdInSubdirectory(fs, gpg, TestNamespace);
9594

96-
var collection = new GpgPassCredentialStore(fs, gpg, storeRoot, TestNamespace);
95+
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
96+
string storePath = Path.Combine(homePath, ".password-store");
97+
const string userId = "gcm-test@example.com";
9798

98-
// Create a service that is guaranteed to be unique
99-
string uniqueGuid = Guid.NewGuid().ToString("N");
100-
string service = $"https://example.com/{uniqueGuid}";
99+
// Place .gpg-id only in the namespace subdirectory (not the store root),
100+
// simulating a pass store where the root has no .gpg-id but submodules do.
101+
string subDirPath = Path.Combine(storePath, TestNamespace);
102+
string gpgIdPath = Path.Combine(subDirPath, ".gpg-id");
103+
104+
gpg.GenerateKeys(userId);
105+
106+
fs.Directories.Add(storePath);
107+
fs.Directories.Add(subDirPath);
108+
fs.Files[gpgIdPath] = Encoding.UTF8.GetBytes(userId);
109+
110+
var collection = new GpgPassCredentialStore(fs, gpg, storePath, TestNamespace);
111+
112+
string service = $"https://example.com/{Guid.NewGuid():N}";
101113
const string userName = "john.doe";
102114
string password = Guid.NewGuid().ToString("N");
103115

@@ -186,27 +198,5 @@ private static string InitializePasswordStore(TestFileSystem fs, TestGpg gpg)
186198

187199
return storePath;
188200
}
189-
190-
private static string InitializePasswordStoreWithGpgIdInSubdirectory(TestFileSystem fs, TestGpg gpg, string subdirectory)
191-
{
192-
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
193-
string storePath = Path.Combine(homePath, ".password-store");
194-
string userId = "gcm-test@example.com";
195-
196-
// Place .gpg-id only in the namespace subdirectory (not the store root),
197-
// simulating a pass store where the root has no .gpg-id but submodules do.
198-
string subDirPath = Path.Combine(storePath, subdirectory);
199-
string gpgIdPath = Path.Combine(subDirPath, ".gpg-id");
200-
201-
// Ensure we have a GPG key for use with testing
202-
gpg.GenerateKeys(userId);
203-
204-
// Init the password store with .gpg-id only in the subdirectory
205-
fs.Directories.Add(storePath);
206-
fs.Directories.Add(subDirPath);
207-
fs.Files[gpgIdPath] = Encoding.UTF8.GetBytes(userId);
208-
209-
return storePath;
210-
}
211201
}
212202
}

0 commit comments

Comments
 (0)