Esempio n. 1
0
        public async Task Delete_existing_user_from_app()
        {
            var response = await Given
                           .Server
                           .CreateRequest(AccountEndpoint.Register)
                           .WithJsonBody(new RegisterModel()
            {
                Username = $"{Guid.NewGuid()}@domain.com",
                Password = Guid.NewGuid().ToString(),
            })
                           .PostAsync();

            await response.ShouldBe(StatusCodes.Status200OK);

            var created = await response.ReadJsonResponse <UserViewModel>();

            response = await Given
                       .Server
                       .CreateRequest(UsersEndpoint.Delete(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .DeleteAsync();

            await response.ShouldBe(StatusCodes.Status204NoContent);

            response = await Given
                       .Server
                       .CreateRequest(UsersEndpoint.GetById(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .GetAsync();

            await response.ShouldBe(StatusCodes.Status404NotFound);
        }
Esempio n. 2
0
        public async Task Fail_to_delete_one_user_because_is_not_authorized()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.Delete(Guid.NewGuid()))
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status401Unauthorized);
        }
Esempio n. 3
0
        public async Task Fail_to_delete_one_user_because_is_not_admin()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.Delete(Guid.NewGuid()))
                           .WithIdentity(Identities.OneUser)
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status403Forbidden);
        }