Ejemplo n.º 1
0
        public void Should_warn_if_queue_doesnt_exist()
        {
            QueuePermissions.CheckQueue("NServiceBus.NonexistingQueueName");

            Assert.That(logOutput.ToString(), Does.Contain("does not exist"));
            Assert.That(logOutput.ToString(), Does.Contain("WARN"));
        }
Ejemplo n.º 2
0
        public void Should_log_if_queue_exists()
        {
            MessageQueue.Create(@".\private$\" + testQueueName, false);

            QueuePermissions.CheckQueue(testQueueName);

            Assert.That(logOutput.ToString(), Does.Contain("Verified that the queue"));
        }
Ejemplo n.º 3
0
        public void Should_log_when_queue_is_remote()
        {
            var remoteQueue = $"{testQueueName}@remotemachine";

            QueuePermissions.CheckQueue(remoteQueue);

            Assert.That(logOutput.ToString(), Does.Contain($"{remoteQueue} is remote, the queue could not be verified."));
        }
Ejemplo n.º 4
0
        public void Should_warn_if_queue_has_public_access(MessageQueueAccessRights rights, WellKnownSidType sidType)
        {
            var groupName = new SecurityIdentifier(sidType, null).Translate(typeof(NTAccount)).ToString();

            using (var queue = MessageQueue.Create(@".\private$\" + testQueueName, false))
            {
                queue.SetPermissions(groupName, rights);
            }

            QueuePermissions.CheckQueue(testQueueName);
            Assert.That(logOutput.ToString(), Does.Contain("Consider setting appropriate permissions"));
        }
Ejemplo n.º 5
0
        public void Should_not_warn_if_queue_has_public_access_set_to_deny(MessageQueueAccessRights accessRights)
        {
            // Set up a queue with the specified access for everyone/anonymous explicitly set to DENY.
            var everyoneGroupName  = new SecurityIdentifier(WellKnownSidType.WorldSid, null).Translate(typeof(NTAccount)).ToString();
            var anonymousGroupName = new SecurityIdentifier(WellKnownSidType.AnonymousSid, null).Translate(typeof(NTAccount)).ToString();

            using (var queue = MessageQueue.Create(@".\private$\" + testQueueName, false))
            {
                queue.SetPermissions(everyoneGroupName, accessRights, AccessControlEntryType.Deny);
                queue.SetPermissions(anonymousGroupName, accessRights, AccessControlEntryType.Deny);
            }

            QueuePermissions.CheckQueue(testQueueName);
            Assert.IsFalse(logOutput.ToString().Contains("Consider setting appropriate permissions"));

            // Resetting the queue permission to delete the queue to enable the cleanup of the unit test
            var path = @".\private$\" + testQueueName;

            using (var queueToModify = new MessageQueue(path))
            {
                queueToModify.SetPermissions(everyoneGroupName, MessageQueueAccessRights.DeleteQueue, AccessControlEntryType.Allow);
            }
        }