コード例 #1
0
        public void Expand(string permission, string expectedPermissions)
        {
            var expected = expectedPermissions.Split(new[] { ',' });
            var af       = new RequiresAuth(permission);

            var actual = af.Expand();

            Assert.Equal(expected, actual);
        }
コード例 #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.PostRequiresAuthAsync(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 async Task Can_Authenticate_with_ApiKey()
        {
            AppHost.LastApiKey             = null;
            RequiresAuthService.LastApiKey = null;

            var client = GetClient(c => c.BearerToken = liveKey.Id);

            var request = new RequiresAuth {
                Name = "foo"
            };
            var response = await client.PostRequiresAuthAsync(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 = GetClient(c => c.BearerToken = testKey.Id);
            var testResponse = await client.PostSecuredAsync(new Secured { Name = "test" });

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

            Assert.That(AppHost.LastApiKey.Id, Is.EqualTo(testKey.Id));
        }
コード例 #4
0
 public object Any(RequiresAuth request)
 {
     return(request);
 }
コード例 #5
0
 public object Any(RequiresAuth request)
 {
     return(new RequiresAuthResponse {
         Result = $"Hello, {request.Name}!"
     });
 }
コード例 #6
0
 public object Any(RequiresAuth request)
 {
     return("<h1>HAS AUTH!</h1>");
 }