public void Resolves_ClientId() { var context = new NancyContext { CurrentUser = new TestPrincipal(new Claim(JwtClaimTypes.ClientId, "fabric-authorization")) }; var contextWrapper = new NancyContextWrapper(context); var eventContextResolver = new EventContextResolverService(contextWrapper); Assert.Equal("fabric-authorization", eventContextResolver.ClientId); }
public void Resolves_Subject() { var context = new NancyContext { CurrentUser = new TestPrincipal(new Claim(JwtClaimTypes.Subject, "12345")) }; var contextWrapper = new NancyContextWrapper(context); var eventContextResolver = new EventContextResolverService(contextWrapper); Assert.Equal("12345", eventContextResolver.Subject); }
public void Resolves_Username() { var context = new NancyContext { CurrentUser = new TestPrincipal(new Claim(JwtClaimTypes.Name, "bob")) }; var contextWrapper = new NancyContextWrapper(context); var eventContextResolver = new EventContextResolverService(contextWrapper); Assert.Equal("bob", eventContextResolver.Username); }
public async Task <bool> HealthCheck() { var eventContextResolverService = new EventContextResolverService(new NancyContextWrapper(new NancyContext())); var clientStore = _appConfig.UseInMemoryStores ? (IClientStore) new InMemoryClientStore() : new CouchDbClientStore(new CouchDbAccessService(_appConfig.CouchDbSettings, _logger), _logger, eventContextResolverService); var result = await clientStore.GetAll(); return(result.Any()); }
// TODO: make this DB-agnostic public async Task <bool> HealthCheck() { var eventContextResolverService = new EventContextResolverService(new NancyContextWrapper(new NancyContext())); var clientStore = _appConfig.StorageProvider.Equals(StorageProviders.InMemory, StringComparison.OrdinalIgnoreCase) ? (IClientStore) new InMemoryClientStore() : new CouchDbClientStore(new CouchDbAccessService(_appConfig.CouchDbSettings, _logger), _logger, eventContextResolverService); var result = await clientStore.GetAll(); return(result.Any()); }
public void Resolves_IpAddress() { var request = new Request("POST", "http://test/test", null, null, "192.168.0.1"); var context = new NancyContext { Request = request }; var contextWrapper = new NancyContextWrapper(context); var eventContextResolver = new EventContextResolverService(contextWrapper); Assert.Equal("192.168.0.1", eventContextResolver.RemoteIpAddress); }
public void ResolvesAllToNull_IfNotSpecified() { var context = new NancyContext { CurrentUser = new TestPrincipal() }; var contextWrapper = new NancyContextWrapper(context); var eventContextResolver = new EventContextResolverService(contextWrapper); Assert.Null(eventContextResolver.Username); Assert.Null(eventContextResolver.Subject); Assert.Null(eventContextResolver.ClientId); Assert.Null(eventContextResolver.RemoteIpAddress); }