Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Git-Credential-Manager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AzureRepos", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AzureRepos.Tests", "src\shared\Microsoft.AzureRepos.Tests\Microsoft.AzureRepos.Tests.csproj", "{97DC6241-1240-4A85-8035-F8404A983A82}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ManagedApps", "src\shared\Microsoft.ManagedApps\Microsoft.ManagedApps.csproj", "{AD948E97-7A7D-4364-AF28-3E4341D72026}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ManagedApps.Tests", "src\shared\Microsoft.ManagedApps.Tests\Microsoft.ManagedApps.Tests.csproj", "{9EE65F46-3FFA-4886-ACED-998C1597271E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windows", "windows", "{66722747-1B61-40E4-A89B-1AC8E6D62EA9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestInfrastructure", "src\shared\TestInfrastructure\TestInfrastructure.csproj", "{5A7D9E8B-C1D2-4C5C-BE98-648C41D1F8BD}"
Expand Down Expand Up @@ -135,6 +139,38 @@ Global
{97DC6241-1240-4A85-8035-F8404A983A82}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{97DC6241-1240-4A85-8035-F8404A983A82}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{97DC6241-1240-4A85-8035-F8404A983A82}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.MacRelease|Any CPU.Build.0 = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.Release|Any CPU.Build.0 = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{AD948E97-7A7D-4364-AF28-3E4341D72026}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.MacRelease|Any CPU.Build.0 = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.Release|Any CPU.Build.0 = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{9EE65F46-3FFA-4886-ACED-998C1597271E}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{5A7D9E8B-C1D2-4C5C-BE98-648C41D1F8BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A7D9E8B-C1D2-4C5C-BE98-648C41D1F8BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A7D9E8B-C1D2-4C5C-BE98-648C41D1F8BD}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -287,6 +323,8 @@ Global
{AD41FA1E-51F5-4E4F-B7DA-32F921491313} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{714AF9EB-44E6-4058-BD3E-9039F29F4D7A} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{97DC6241-1240-4A85-8035-F8404A983A82} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{AD948E97-7A7D-4364-AF28-3E4341D72026} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{9EE65F46-3FFA-4886-ACED-998C1597271E} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{66722747-1B61-40E4-A89B-1AC8E6D62EA9} = {A7FC1234-95E3-4496-B5F7-4306F41E6A0E}
{5A7D9E8B-C1D2-4C5C-BE98-648C41D1F8BD} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{3C840B06-A595-4FD9-9A76-56CD45B14780} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ProjectReference Include="..\GitHub\GitHub.csproj" />
<ProjectReference Include="..\GitLab\GitLab.csproj" />
<ProjectReference Include="..\Microsoft.AzureRepos\Microsoft.AzureRepos.csproj" />
<ProjectReference Include="..\Microsoft.ManagedApps\Microsoft.ManagedApps.csproj" />
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/shared/Git-Credential-Manager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using GitHub;
using GitLab;
using Microsoft.AzureRepos;
using Microsoft.ManagedApps;
using GitCredentialManager.Authentication;
using GitCredentialManager.UI;

Expand Down Expand Up @@ -61,6 +62,7 @@ private static void AppMain(object o)
app.RegisterProvider(new BitbucketHostProvider(context), HostProviderPriority.Normal);
app.RegisterProvider(new GitHubHostProvider(context), HostProviderPriority.Normal);
app.RegisterProvider(new GitLabHostProvider(context), HostProviderPriority.Normal);
app.RegisterProvider(new ManagedAppsHostProvider(context), HostProviderPriority.Normal);
app.RegisterProvider(new GenericHostProvider(context), HostProviderPriority.Low);

_exitCode = app.RunAsync(args)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using GitCredentialManager.Tests.Objects;
using Xunit;

namespace Microsoft.ManagedApps.Tests
{
public class ManagedAppsBindingManagerTests
{
private const string Host = "https://4899945d6e51f1f0326cda880ec7a7.09.environment.api.powerplatform.com";

[Fact]
public void ManagedAppsBindingManager_GetAccount_NoBinding_ReturnsNull()
{
var manager = new ManagedAppsBindingManager(new NullTrace(), new TestGit());

string account = manager.GetAccount(Host);

Assert.Null(account);
}

[Fact]
public void ManagedAppsBindingManager_SignIn_ThenGetAccount_ReturnsBoundAccount()
{
var git = new TestGit();
var manager = new ManagedAppsBindingManager(new NullTrace(), git);

manager.SignIn(Host, "user@example.com");

Assert.Equal("user@example.com", manager.GetAccount(Host));
}

[Fact]
public void ManagedAppsBindingManager_SignIn_NullAccount_DoesNotThrowAndDoesNotBind()
{
var manager = new ManagedAppsBindingManager(new NullTrace(), new TestGit());

manager.SignIn(Host, null);

Assert.Null(manager.GetAccount(Host));
}

[Fact]
public void ManagedAppsBindingManager_SignOut_RemovesBinding()
{
var git = new TestGit();
var manager = new ManagedAppsBindingManager(new NullTrace(), git);
manager.SignIn(Host, "user@example.com");

manager.SignOut(Host);

Assert.Null(manager.GetAccount(Host));
}

[Fact]
public void ManagedAppsBindingManager_SignOut_NoExistingBinding_DoesNotThrow()
{
var manager = new ManagedAppsBindingManager(new NullTrace(), new TestGit());

manager.SignOut(Host);

Assert.Null(manager.GetAccount(Host));
}

[Fact]
public void ManagedAppsBindingManager_Bindings_AreIndependentPerHost()
{
const string otherHost = "https://c0a12cc2ff79f7306d6ef9fc69c2062.1.environment.api.preprod.powerplatform.com";
var git = new TestGit();
var manager = new ManagedAppsBindingManager(new NullTrace(), git);

manager.SignIn(Host, "user1@example.com");
manager.SignIn(otherHost, "user2@example.com");

Assert.Equal("user1@example.com", manager.GetAccount(Host));
Assert.Equal("user2@example.com", manager.GetAccount(otherHost));
}
}
}
Loading