Implemented Core client
This commit is contained in:
44
Cloudflare.Tests/Auth/ApiTokenAuthenticationTest.cs
Normal file
44
Cloudflare.Tests/Auth/ApiTokenAuthenticationTest.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using AMWD.Net.Api.Cloudflare.Auth;
|
||||
|
||||
namespace Cloudflare.Core.Tests.Auth
|
||||
{
|
||||
[TestClass]
|
||||
public class ApiTokenAuthenticationTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void ShouldAddHeader()
|
||||
{
|
||||
// Arrange
|
||||
string apiToken = "some-api-token";
|
||||
|
||||
var auth = new ApiTokenAuthentication(apiToken);
|
||||
using var clt = new HttpClient();
|
||||
|
||||
// Act
|
||||
auth.AddHeader(clt);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(clt.DefaultRequestHeaders.Contains("Authorization"));
|
||||
|
||||
Assert.AreEqual("Bearer", clt.DefaultRequestHeaders.Authorization.Scheme);
|
||||
Assert.AreEqual(apiToken, clt.DefaultRequestHeaders.Authorization.Parameter);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void ShouldArgumentNullExceptionForEmailAddress(string apiToken)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
new ApiTokenAuthentication(apiToken);
|
||||
|
||||
// Assert - ArgumentNullException
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user