예제 #1
0
        public void CanRevoke_should_throw_execption_if_client_id_is_null()
        {
            var command = new RevokeClient();

            ValidationAssert.Throws(() => GuardAppClients.CanRevoke(clients_0, command),
                                    new ValidationError("Client id is required.", "Id"));
        }
예제 #2
0
        public void CanAttach_should_throw_execption_if_client_id_is_null()
        {
            var command = new AttachClient();

            ValidationAssert.Throws(() => GuardAppClients.CanAttach(command, App(clients_0)),
                                    new ValidationError("Client ID is required.", "Id"));
        }
예제 #3
0
        public void CanRevoke_should_throw_exception_if_client_is_not_found()
        {
            var command = new RevokeClient {
                Id = "ios"
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppClients.CanRevoke(clients_0, command));
        }
예제 #4
0
        public void UpdateClient_should_throw_exception_if_client_is_not_found()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "iOS"
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppClients.CanUpdate(clients_0, command, Roles.Empty));
        }
예제 #5
0
        public void CanUpdate_should_throw_execption_if_client_id_is_null()
        {
            var command = new UpdateClient {
                Name = "iOS"
            };

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_0, command, Roles.Empty),
                                    new ValidationError("Client id is required.", "Id"));
        }
예제 #6
0
        public void CanAttach_should_not_throw_exception_if_client_is_free()
        {
            var command = new AttachClient {
                Id = "ios"
            };

            var clients_1 = clients_0.Add("android", "secret");

            GuardAppClients.CanAttach(clients_1, command);
        }
예제 #7
0
        public void CanRevoke_should_not_throw_exception_if_client_is_found()
        {
            var command = new RevokeClient {
                Id = "ios"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanRevoke(clients_1, command);
        }
예제 #8
0
        public void UpdateClient_should_throw_exception_if_client_has_same_permission()
        {
            var command = new UpdateClient {
                Id = "ios", Permission = AppClientPermission.Editor
            };

            var clients_1 = clients_0.Add("ios", "secret");

            Assert.Throws <ValidationException>(() => GuardAppClients.CanUpdate(clients_1, command));
        }
예제 #9
0
        public void UpdateClient_should_not_throw_exception_if_command_is_valid()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "iOS", Role = Role.Reader
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanUpdate(clients_1, command, roles);
        }
예제 #10
0
        public void CanAttach_should_throw_exception_if_client_already_exists()
        {
            var command = new AttachClient {
                Id = "android"
            };

            var clients_1 = clients_0.Add("android", "secret");

            Assert.Throws <ValidationException>(() => GuardAppClients.CanAttach(clients_1, command));
        }
예제 #11
0
        public void UpdateClient_not_should_throw_exception_if_client_has_same_role()
        {
            var command = new UpdateClient {
                Id = "ios", Role = Role.Editor
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanUpdate(clients_1, command, roles);
        }
예제 #12
0
        public void UpdateClient_should_not_throw_exception_if_client_has_same_name()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "ios"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanUpdate(command, App(clients_1));
        }
예제 #13
0
        public void UpdateClient_should_throw_exception_if_client_has_invalid_permission()
        {
            var command = new UpdateClient {
                Id = "ios", Permission = (AppClientPermission)10
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command),
                                    new ValidationError("Permission is not valid.", "Permission"));
        }
예제 #14
0
        public void UpdateClient_should_throw_exception_if_client_has_same_permission()
        {
            var command = new UpdateClient {
                Id = "ios", Permission = AppClientPermission.Editor
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command),
                                    new ValidationError("Client has already this permission.", "Permission"));
        }
예제 #15
0
        public void CanAttach_should_throw_exception_if_client_already_exists()
        {
            var command = new AttachClient {
                Id = "android"
            };

            var clients_1 = clients_0.Add("android", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanAttach(clients_1, command),
                                    new ValidationError("A client with the same id already exists."));
        }
예제 #16
0
        public void UpdateClient_should_throw_exception_if_client_has_invalid_role()
        {
            var command = new UpdateClient {
                Id = "ios", Role = "Invalid"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command, roles),
                                    new ValidationError("Role is not a valid value.", "Role"));
        }
예제 #17
0
        public void UpdateClient_should_throw_exception_if_client_has_no_name_and_role()
        {
            var command = new UpdateClient {
                Id = "ios"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command, roles),
                                    new ValidationError("Either name or role must be defined.", "Name", "Role"));
        }
예제 #18
0
        public void UpdateClient_should_throw_exception_if_client_has_same_name()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "ios"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command),
                                    new ValidationError("Client has already this name.", "Name"));
        }
예제 #19
0
        public void UpdateClient_should_throw_exception_if_api_traffic_limit_is_less_than_zero()
        {
            var command = new UpdateClient {
                Id = "ios", ApiTrafficLimit = -10
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(command, App(clients_1)),
                                    new ValidationError("ApiTrafficLimit must be greater or equal to 0.", "ApiTrafficLimit"));
        }
예제 #20
0
        public void UpdateClient_should_throw_exception_if_client_has_same_role()
        {
            var command = new UpdateClient {
                Id = "ios", Role = Role.Editor
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command, roles),
                                    new ValidationError("Client has already this role.", "Role"));
        }
예제 #21
0
        public void CanUpdate_should_throw_execption_if_client_id_is_null()
        {
            var command = new UpdateClient();

            Assert.Throws <ValidationException>(() => GuardAppClients.CanUpdate(clients_0, command));
        }