2024-02-10 10:41:47 +00:00
|
|
|
|
2020-05-02 12:04:26 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using SpotifyAPI.Web.Http;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Tests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2020-05-13 22:49:54 +01:00
|
|
|
public class TokenAuthenticatorTest
|
2020-05-02 12:04:26 +01:00
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void Apply_AddsCorrectHeader()
|
|
|
|
{
|
2020-05-13 22:49:54 +01:00
|
|
|
var authenticator = new TokenAuthenticator("MyToken", "Bearer");
|
2020-05-02 12:04:26 +01:00
|
|
|
var request = new Mock<IRequest>();
|
2020-05-13 22:49:54 +01:00
|
|
|
var apiConnector = new Mock<IAPIConnector>();
|
|
|
|
|
2020-05-02 12:04:26 +01:00
|
|
|
request.SetupGet(r => r.Headers).Returns(new Dictionary<string, string>());
|
|
|
|
|
2020-05-13 22:49:54 +01:00
|
|
|
authenticator.Apply(request.Object, apiConnector.Object);
|
2024-02-10 10:41:47 +00:00
|
|
|
Assert.That(request.Object.Headers["Authorization"], Is.EqualTo("Bearer MyToken"));
|
2020-05-02 12:04:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|