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); }
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)); }
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)); }
public object Any(RequiresAuth request) { return(request); }
public object Any(RequiresAuth request) { return(new RequiresAuthResponse { Result = $"Hello, {request.Name}!" }); }
public object Any(RequiresAuth request) { return("<h1>HAS AUTH!</h1>"); }