Exemplo n.º 1
0
 public void SetUp()
 {
     config = new ApiConfig
     {
         BaseUrl = "https://example.com"
     };
     serviceCollection = new ServiceCollection();
     serviceProvider   = serviceCollection.BuildServiceProvider();
     subject           = new DefaultAuthenticationFactory(serviceProvider);
 }
Exemplo n.º 2
0
        public void CanBuildBearerAuthentication()
        {
            var httpAccessor = new Mock <IHttpContextAccessor>();

            serviceCollection.AddSingleton(httpAccessor.Object);
            serviceProvider  = serviceCollection.BuildServiceProvider();
            subject          = new DefaultAuthenticationFactory(serviceProvider);
            config.AuthType  = typeof(UserBearerAuthentication).FullName;
            config.AuthProps = new Dictionary <string, string>
            {
                { "Mode", "Claims" },
                { "TokenKey", "token" }
            };

            var result = subject.BuildAuthentication(config) as UserBearerAuthentication;

            Assert.That(result.Mode, Is.EqualTo(TokenMode.Claims.ToString()));
            Assert.That(result.TokenKey, Is.EqualTo("token"));
        }