Ejemplo n.º 1
0
        public async Task Obtain_one_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.GetById(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .GetAsync();

            await response.ShouldBe(StatusCodes.Status200OK);

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

            searched.Should().BeEquivalentTo(created);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public async Task Fail_to_obtain_one_user_because_is_not_authorized()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.GetById(Guid.NewGuid()))
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status401Unauthorized);
        }
Ejemplo n.º 4
0
        public async Task Fail_to_obtain_one_user_when_does_not_exist()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.GetById(Guid.NewGuid()))
                           .WithIdentity(Identities.Administrator)
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status404NotFound);
        }
Ejemplo n.º 5
0
        public async Task Fail_to_obtain_one_user_because_is_not_admin()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.GetById(Guid.NewGuid()))
                           .WithIdentity(Identities.OneUser)
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status403Forbidden);
        }