Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 7c448a4

Browse files
authored
Merge pull request #111 from github-for-unity/fixes/keychain-adapter-update-clear
Fixes to Update/Clear in KeychainAdapter
2 parents 53662ce + 8ab8208 commit 7c448a4

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/GitHub.Api/Authentication/KeychainAdapter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ public void Set(ICredential credential)
1717
public void UpdateToken(string token)
1818
{
1919
Credential.UpdateToken(token);
20+
OctokitCredentials = new Credentials(OctokitCredentials.Login, token);
2021
}
2122

2223
public void Clear()
2324
{
2425
OctokitCredentials = Credentials.Anonymous;
26+
Credential = null;
2527
}
2628

2729
/// <summary>

src/tests/UnitTests/Authentication/KeychainTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public void ShouldConnectSetCredentialsTokenAndSave()
392392
keychainAdapter.Credential.Token.Should().Be(token);
393393
keychainAdapter.OctokitCredentials.AuthenticationType.Should().Be(AuthenticationType.Basic);
394394
keychainAdapter.OctokitCredentials.Login.Should().Be(username);
395-
keychainAdapter.OctokitCredentials.Password.Should().Be(password);
395+
keychainAdapter.OctokitCredentials.Password.Should().Be(token);
396396

397397
keychain.Save(hostUri).Wait();
398398

@@ -472,10 +472,7 @@ public void ShouldConnectSetCredentialsAndClear()
472472

473473
keychain.Clear(hostUri, false).Wait();
474474

475-
keychainAdapter.Credential.Should().NotBeNull();
476-
keychainAdapter.Credential.Host.Should().Be(hostUri);
477-
keychainAdapter.Credential.Username.Should().Be(username);
478-
keychainAdapter.Credential.Token.Should().Be(password);
475+
keychainAdapter.Credential.Should().BeNull();
479476
keychainAdapter.OctokitCredentials.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
480477
keychainAdapter.OctokitCredentials.Login.Should().BeNull();
481478
keychainAdapter.OctokitCredentials.Password.Should().BeNull();

0 commit comments

Comments
 (0)