Files
octokit.net/Octokit.Tests/Authentication/BasicAuthenticatorTests.cs
Haacked 997e955f38 Rename to Octokit to be consistent with other API libs
GitHub is naming all of the libraries Octokit for their respective
platforms
2013-01-29 14:00:27 -08:00

41 lines
1.3 KiB
C#

using System;
using FluentAssertions;
using Octokit.Authentication;
using Octokit.Http;
using Xunit;
namespace Octokit.Tests
{
public class BasicAuthenticatorTests
{
public class TheConstructor
{
}
public class TheAuthenticateMethod
{
[Fact]
public void SetsRequestHeaderForToken()
{
var authenticator = new BasicAuthenticator();
var request = new Request();
authenticator.Authenticate(request, new Credentials("that-creepy-dude", "Fahrvergnügen"));
request.Headers.Should().ContainKey("Authorization");
request.Headers["Authorization"].Should().Be("Basic dGhhdC1jcmVlcHktZHVkZTpGYWhydmVyZ27DvGdlbg==");
}
[Fact]
public void EnsuresArgumentsNotNull()
{
var authenticator = new BasicAuthenticator();
Assert.Throws<ArgumentNullException>(() => authenticator.Authenticate(new Request(), null));
Assert.Throws<ArgumentNullException>(() => authenticator.Authenticate(null, new Credentials("x", "y")));
Assert.Throws<ArgumentNullException>(() => authenticator.Authenticate(null, new Credentials("token")));
}
}
}
}