Пример #1
0
        public async Task Can_Authenticate_with_ApiKey()
        {
            AppHost.LastApiKey             = null;
            RequiresAuthService.LastApiKey = null;

            var client = GetClient();

            client.BearerToken = liveKey.Id;

            var request = new RequiresAuth {
                Name = "foo"
            };
            var response = await client.SendAsync(request);

            Assert.That(response.Name, Is.EqualTo(request.Name));

            Assert.That(AppHost.LastApiKey.Id, Is.EqualTo(liveKey.Id));
            Assert.That(RequiresAuthService.LastApiKey.Id, Is.EqualTo(liveKey.Id));

            client.BearerToken = testKey.Id;
            var testResponse = await client.SendAsync(new Secured { Name = "test" });

            Assert.That(testResponse.Result, Is.EqualTo("Hello, test"));

            Assert.That(AppHost.LastApiKey.Id, Is.EqualTo(testKey.Id));
        }
Пример #2
0
        public async Task Does_allow_ApiKey_in_IHasBearerToken_RequestDto()
        {
            AppHost.LastApiKey             = null;
            RequiresAuthService.LastApiKey = null;

            var client = GetClient();

            var request = new RequiresAuth {
                BearerToken = liveKey.Id, Name = "foo"
            };
            var response = await client.SendAsync(request);

            Assert.That(response.Name, Is.EqualTo(request.Name));

            Assert.That(AppHost.LastApiKey.Id, Is.EqualTo(liveKey.Id));
            Assert.That(RequiresAuthService.LastApiKey.Id, Is.EqualTo(liveKey.Id));
        }
Пример #3
0
 public object Any(RequiresAuth request)
 {
     LastApiKey = base.Request.GetApiKey();
     return(request);
 }