public void GetTokenUserId() { NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); string userId = null; this.Invoking((a) => { // act client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); userId = client.GetTokenUserId(); }) // assert .ShouldNotThrow(); userId.Should().Be("F7D5AC0B-5C00-4253-8B54-046392260658"); }
public void Authenticate_should_return_True() { // arrange NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); var authorized = false; this.Invoking((a) => { // act authorized = client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); }) // assert .ShouldNotThrow(); authorized.Should().BeTrue(); }
public void GetTokenExpirationDate() { NancyWebAppConfig.IdentityServerEnabled = true; var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup))); var handler = server.CreateHandler(); var client = new BasicClient(handler, "https://server/connect/token", "client", "secret"); DateTimeOffset expirationDate; this.Invoking((a) => { // act client.AuthenticateUserAsync("alfredorevilla", "password", "api1").RunAsSynchronous(); expirationDate = client.GetTokenExpirationDate(); }) // assert .ShouldNotThrow(); expirationDate.Should().BeAfter(DateTimeOffset.UtcNow); expirationDate.Should().BeBefore(DateTimeOffset.MaxValue); }