mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-01 18:35:35 +00:00
Fallback to anon with invalid auth data
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using Xunit.Extensions;
|
||||
|
||||
namespace Burr.Tests
|
||||
{
|
||||
@@ -35,6 +36,39 @@ namespace Burr.Tests
|
||||
|
||||
client.AuthenticationType.Should().Be(AuthenticationType.Oauth);
|
||||
}
|
||||
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
[Theory]
|
||||
public void InvalidTokenFallsBackToAnon(string t)
|
||||
{
|
||||
var client = new GitHubClient { Token = t };
|
||||
|
||||
client.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
|
||||
}
|
||||
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
[Theory]
|
||||
public void InvalidUserNameFallsBackToAnon(string t)
|
||||
{
|
||||
var client = new GitHubClient { Username = t };
|
||||
|
||||
client.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
|
||||
}
|
||||
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
[Theory]
|
||||
public void InvalidPasswordFallsBackToAnon(string t)
|
||||
{
|
||||
var client = new GitHubClient { Password = t };
|
||||
|
||||
client.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -17,7 +17,7 @@ namespace Burr
|
||||
{
|
||||
public GitHubClient()
|
||||
{
|
||||
AuthenticationType = Burr.AuthenticationType.Anonymous;
|
||||
AuthenticationType = AuthenticationType.Anonymous;
|
||||
}
|
||||
|
||||
public AuthenticationType AuthenticationType { get; private set; }
|
||||
@@ -26,13 +26,17 @@ namespace Burr
|
||||
public string Username
|
||||
{
|
||||
get { return username; }
|
||||
set {
|
||||
set
|
||||
{
|
||||
if (value == username) return;
|
||||
|
||||
Token = null;
|
||||
AuthenticationType = Burr.AuthenticationType.Basic;
|
||||
|
||||
username = value;
|
||||
if (username.IsNotBlank())
|
||||
{
|
||||
AuthenticationType = AuthenticationType.Basic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +49,12 @@ namespace Burr
|
||||
if (value == password) return;
|
||||
|
||||
Token = null;
|
||||
AuthenticationType = Burr.AuthenticationType.Basic;
|
||||
|
||||
password = value;
|
||||
if (password.IsNotBlank())
|
||||
{
|
||||
AuthenticationType = AuthenticationType.Basic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +68,12 @@ namespace Burr
|
||||
|
||||
Username = null;
|
||||
Password = null;
|
||||
AuthenticationType = Burr.AuthenticationType.Oauth;
|
||||
|
||||
token = value;
|
||||
if (token.IsNotBlank())
|
||||
{
|
||||
AuthenticationType = AuthenticationType.Oauth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user