Skip to content

Commit 4c3e1ca

Browse files
committed
Test freedesktop secretservice implementation on linux
See https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/credstores.md#freedesktoporg-secret-service-api Document in code how to run this test locally, since it requires interactively unlocking the gnome keyring.
1 parent 75c2a36 commit 4c3e1ca

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
path: bin
7474

7575
- name: 🧪 test
76-
run: dotnet test -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER" --nologo -bl --logger:"console;verbosity=normal" -p:VSTestVerbosity=detailed
76+
run: dotnet test -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER" --nologo -bl -l:"console;verbosity=normal"
7777

7878
- name: 🐛 logs
7979
uses: actions/upload-artifact@v3

src/Tests/Attributes.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ public class LinuxTheoryAttribute() : OSTheoryAttribute(OSPlatform.Linux);
5555
public class macOSTheoryAttribute() : OSTheoryAttribute(OSPlatform.OSX);
5656

5757
public class UnixTheoryAttribute() : OSTheoryAttribute(OSPlatform.Linux, OSPlatform.OSX);
58+
59+
public class LocalFactAttribute : OSFactAttribute
60+
{
61+
public LocalFactAttribute(params string[] onPlatforms) : base(onPlatforms)
62+
{
63+
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")))
64+
Skip = "Local-only test";
65+
}
66+
}

src/Tests/EndToEnd.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ public void GitCacheStore()
3838
Run();
3939
}
4040

41+
[LocalFact(nameof(OSPlatform.Linux))]
42+
public void LinuxSecretService()
43+
{
44+
// To test this locally, you need:
45+
// sudo apt-get update
46+
// sudo apt install libsecret-1-0 libsecret-1-dev
47+
// sudo apt install gnome-keyring
48+
// dbus-launch --sh-syntax
49+
// export $(dbus-launch)
50+
// gnome-keyring-daemon -r -d
51+
52+
// Then run the tests: dotnet test
53+
// This will require keyring unlocking interactively before tests proceed.
54+
55+
Environment.SetEnvironmentVariable("GCM_CREDENTIAL_STORE", "secretservice");
56+
Run();
57+
}
58+
4159
void Run()
4260
{
4361
var store = CredentialManager.Create(Guid.NewGuid().ToString("N"));

0 commit comments

Comments
 (0)