public async Task ShouldAddNewIdentityResource() { var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Save(command); _database.IdentityResources.FirstOrDefault(s => s.Name == command.Name).Should().NotBeNull(); }
public async Task ShouldNotAddIdentityResourcesWithoutValidBearer() { _client.SetBearerToken(Guid.NewGuid().ToString()); var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); var response = await _client.PostAsync("/identity-resources", new StringContent(command.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json)); response.IsSuccessStatusCode.Should().BeFalse(); response.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public async Task ShouldAddIdentityResources() { await Login(); _client.SetBearerToken(_token.AccessToken); var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); var response = await _client.PostAsync("/identity-resources", new StringContent(command.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json)); response.EnsureSuccessStatusCode(); response.Headers.Location.PathAndQuery.Should().Contain("/identity-resources"); }
public async Task ShouldRemoveIdentityResource() { var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Save(command); _database.IdentityResources.FirstOrDefault(s => s.Name == command.Name).Should().NotBeNull(); await _identityResource.Remove(new RemoveIdentityResourceViewModel(command.Name)); _notifications.GetNotifications().Select(s => s.Value).ToList().ForEach(_output.WriteLine); _database.IdentityResources.FirstOrDefault(s => s.Name == command.Name).Should().BeNull(); }
public async Task ShouldUpdateIdentityResource() { var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Save(command); var client = _database.IdentityResources.FirstOrDefault(s => s.Name == command.Name); client.Should().NotBeNull(); InMemoryData.DetachAll(); var updateCommand = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Update(command.Name, updateCommand); _database.IdentityResources.FirstOrDefault(f => f.Name == updateCommand.Name).Should().NotBeNull(); }
public async Task Should_Update_IdentityResource() { var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Save(command); var client = _database.IdentityResources.FirstOrDefault(s => s.Name == command.Name); client.Should().NotBeNull(); InMemoryData.DetachAll(); var updateCommand = IdentityResourceFaker.GenerateIdentiyResource().Generate(); await _identityResource.Update(command.Name, updateCommand); var ir = _database.IdentityResources.FirstOrDefault(f => f.Name == updateCommand.Name); ir.Should().NotBeNull(); ir.Name.Should().Be(updateCommand.Name); ir.Properties.Should().HaveCount(updateCommand.Properties.Count); }
public async Task ShouldGetAllIdentityResources() { await Login(); _client.SetBearerToken(_token.AccessToken); var command = IdentityResourceFaker.GenerateIdentiyResource().Generate(); var response = await _client.PostAsync("/identity-resources", new StringContent(command.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json)); response.EnsureSuccessStatusCode(); response.Headers.Location.PathAndQuery.Should().Contain("/identity-resources"); // Get content response = await _client.GetAsync("/identity-resources"); response.EnsureSuccessStatusCode(); var content = await response.Content.ReadAsStringAsync(); var resources = content.FromJson <IEnumerable <IdentityResourceListView> >(); resources.Should().HaveCountGreaterThan(0); }