public async Task CanGetTokenFromContext() { var props = new AuthenticationProperties(); var tokens = new List <AuthenticationToken>(); var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; tokens.Add(tok1); tokens.Add(tok2); tokens.Add(tok3); props.StoreTokens(tokens); var context = new DefaultHttpContext(); var handler = new TestAuthHandler(props); context.Features.Set <IHttpAuthenticationFeature>(new HttpAuthenticationFeature() { Handler = handler }); Assert.Equal("1", await context.Authentication.GetTokenAsync("One")); Assert.Equal("2", await context.Authentication.GetTokenAsync("Two")); Assert.Equal("3", await context.Authentication.GetTokenAsync("Three")); }
public async Task CanGetTokenFromContext() { var props = new AuthenticationProperties(); var tokens = new List<AuthenticationToken>(); var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; tokens.Add(tok1); tokens.Add(tok2); tokens.Add(tok3); props.StoreTokens(tokens); var context = new DefaultHttpContext(); var handler = new TestAuthHandler(props); context.Features.Set<IHttpAuthenticationFeature>(new HttpAuthenticationFeature() { Handler = handler }); Assert.Equal("1", await context.Authentication.GetTokenAsync("One")); Assert.Equal("2", await context.Authentication.GetTokenAsync("Two")); Assert.Equal("3", await context.Authentication.GetTokenAsync("Three")); }