Beispiel #1
0
        public async Task ShouldDeleteClientClaims()
        {
            await Login();

            var newClient = await AddClient();

            var claim = ClientViewModelFaker.GenerateSaveClaim(newClient.ClientId).Generate();

            // Create one
            var httpResponse = await _client.PostAsync($"/clients/{newClient.ClientId}/claims", new StringContent(claim.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json));

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
            httpResponse.Headers.Location.Should().NotBeNull();
            httpResponse.Headers.Location.PathAndQuery.Should().Contain("/claims");

            httpResponse = await _client.GetAsync($"/clients/{newClient.ClientId}/claims");

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };

            // Deserialize and examine results.
            var stringResponse = await httpResponse.Content.ReadAsStringAsync();

            var claims = stringResponse.FromJson <IEnumerable <ClaimViewModel> >();

            claims.Should().HaveCountGreaterThan(0);

            httpResponse = await _client.DeleteAsync($"/clients/{newClient.ClientId}/claims?type={claims.First().Type.UrlEncode()}&value={claims.First().Value.UrlEncode()}");

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
        }
Beispiel #2
0
        public async Task Should_Not_Add_New_ClientClaim_When_Client_Doesnt_Exist()
        {
            var command  = ClientViewModelFaker.GenerateSaveClient().Generate();
            var property = ClientViewModelFaker.GenerateSaveClaim(command.ClientId).Generate();

            var result = await _clientAppService.SaveClaim(property);

            _database.ClientClaims.Include(i => i.Client).Where(f => f.Client.ClientId == command.ClientId).Should().NotBeNull();
            result.Should().BeFalse(becauseArgs: _notifications.GetNotificationsByKey());
        }
        public async Task ShouldAddNewClientClaim()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            var property = ClientViewModelFaker.GenerateSaveClaim().Generate();

            await _clientAppService.SaveClaim(property);

            _database.Clients.FirstOrDefault(s => s.ClientId == command.ClientId).Should().NotBeNull();
            _database.ClientClaims.Include(i => i.Client).Where(f => f.Client.ClientId == command.ClientId).Should().NotBeNull();
        }
Beispiel #4
0
        public async Task ShouldAddNewClientClaim()
        {
            await Login();

            var newClient = await AddClient();

            var claim = ClientViewModelFaker.GenerateSaveClaim(newClient.ClientId).Generate();

            // Create one
            var httpResponse = await _client.PostAsync($"/clients/{newClient.ClientId}/claims", new StringContent(claim.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json));

            try { httpResponse.EnsureSuccessStatusCode(); } catch { _output.WriteLine(await httpResponse.Content.ReadAsStringAsync()); throw; };
            httpResponse.Headers.Location.Should().NotBeNull();
            httpResponse.Headers.Location.PathAndQuery.Should().Contain("/claims");
        }
Beispiel #5
0
        public async Task Should_Get_ClientClaim()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            var property = ClientViewModelFaker.GenerateSaveClaim(command.ClientId).Generate();

            await _clientAppService.SaveClaim(property);

            _database.Clients.FirstOrDefault(s => s.ClientId == command.ClientId).Should().NotBeNull();
            var clams = await _clientAppService.GetClaims(command.ClientId);

            clams.Should().HaveCountGreaterOrEqualTo(1);
        }
Beispiel #6
0
        public async Task Should_Remove_ClientClaim()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            var property = ClientViewModelFaker.GenerateSaveClaim(command.ClientId).Generate();

            await _clientAppService.SaveClaim(property);

            _database.Clients.FirstOrDefault(s => s.ClientId == command.ClientId).Should().NotBeNull();
            var clams = _database.ClientClaims.Include(i => i.Client).Where(f => f.Client.ClientId == command.ClientId);

            clams.Should().HaveCountGreaterOrEqualTo(1);

            var removeClaim = new RemoveClientClaimViewModel(command.ClientId, property.Type, property.Value);
            await _clientAppService.RemoveClaim(removeClaim);

            var clientDb = await _database.Clients.Include(s => s.Claims).FirstOrDefaultAsync(s => s.ClientId == command.ClientId);

            clientDb.Claims.Should().BeEmpty();
        }