RawEndpointConfiguration(string endpointName, Func <MessageContext, IDispatchMessages, Task> onMessage, string poisonMessageQueue) { this.onMessage = onMessage; ValidateEndpointName(endpointName); var sendOnly = onMessage == null; Settings.Set("Endpoint.SendOnly", sendOnly); Settings.Set("TypesToScan", new Type[0]); Settings.Set("NServiceBus.Routing.EndpointName", endpointName); Settings.Set <Conventions>(new Conventions()); //Hack for ASB Settings.Set <StartupDiagnosticEntries>(new StartupDiagnosticEntries()); queueBindings = new QueueBindings(); Settings.Set <QueueBindings>(queueBindings); Settings.SetDefault("Transactions.IsolationLevel", IsolationLevel.ReadCommitted); Settings.SetDefault("Transactions.DefaultTimeout", TransactionManager.DefaultTimeout); if (!sendOnly) { queueBindings.BindSending(poisonMessageQueue); Settings.Set("NServiceBus.Raw.PoisonMessageQueue", poisonMessageQueue); Settings.Set("errorQueue", poisonMessageQueue); //Hack for MSMQ Settings.SetDefault <IErrorHandlingPolicy>(new DefaultErrorHandlingPolicy(poisonMessageQueue, 5)); } }
public async Task Should_not_update_properties_of_an_existing_system_queue() { var queuePath = "errorQ"; var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); await namespaceManager.DeleteQueue(queuePath).ConfigureAwait(false); if (!await namespaceManager.QueueExists(queuePath).ConfigureAwait(false)) { await namespaceManager.CreateQueue(new QueueDescription(queuePath)).ConfigureAwait(false); } var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); settings.Set(WellKnownConfigurationKeys.Core.RecoverabilityNumberOfImmediateRetries, 2); var queueBindings = new QueueBindings(); queueBindings.BindSending(queuePath); settings.Set <QueueBindings>(queueBindings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.Queues().LockDuration(TimeSpan.FromMinutes(4)); var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings); await creator.Create(queuePath, namespaceManager); var real = await namespaceManager.GetQueue(queuePath); Assert.That(real.LockDuration, Is.EqualTo(TimeSpan.FromSeconds(60))); //cleanup await namespaceManager.DeleteQueue(queuePath); }
protected TransportSeam(TransportDefinition transportDefinition, HostSettings hostSettings, QueueBindings queueBindings) { TransportDefinition = transportDefinition; QueueBindings = queueBindings; this.hostSettings = hostSettings; }
RawEndpointConfiguration(string endpointName, Func <MessageContext, IDispatchMessages, Task> onMessage, string poisonMessageQueue) { this.onMessage = onMessage; ValidateEndpointName(endpointName); var sendOnly = onMessage == null; Settings.Set("Endpoint.SendOnly", sendOnly); Settings.Set("TypesToScan", new Type[0]); Settings.Set("NServiceBus.Routing.EndpointName", endpointName); Settings.SetDefault("Transactions.IsolationLevel", IsolationLevel.ReadCommitted); Settings.SetDefault("Transactions.DefaultTimeout", TransactionManager.DefaultTimeout); Settings.PrepareConnectionString(); queueBindings = Settings.Get <QueueBindings>(); if (!sendOnly) { queueBindings.BindSending(poisonMessageQueue); Settings.Set("NServiceBus.Raw.PoisonMessageQueue", poisonMessageQueue); Settings.SetDefault <IErrorHandlingPolicy>(new DefaultErrorHandlingPolicy(poisonMessageQueue, 5)); } SetTransportSpecificFlags(Settings, poisonMessageQueue); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (string address in queueBindings.ReceivingAddresses) { await CreateQueue(address); } }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { settings.Get <FakeTransport.StartUpSequence>().Add($"{nameof(ICreateQueues)}.{nameof(CreateQueueIfNecessary)}"); onQueueCreation?.Invoke(queueBindings); return(Task.FromResult(0)); }
public void Should_setup_permissions() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueNameForReceiving); // use the network service account since that one won't be in the local admin group creator.CreateQueueIfNecessary(bindings, NetworkServiceAccountName); var createdQueue = GetQueue(testQueueNameForReceiving); MessageQueueAccessRights?accountAccessRights; AccessControlEntryType? accessControlEntryType; Assert.True(createdQueue.TryGetPermissions(NetworkServiceAccountName, out accountAccessRights, out accessControlEntryType)); Assert.True(accountAccessRights.HasValue); Assert.True(accessControlEntryType == AccessControlEntryType.Allow, "User should have access"); Assert.True(accountAccessRights?.HasFlag(MessageQueueAccessRights.WriteMessage), $"{NetworkServiceAccountName} should have write access"); Assert.True(accountAccessRights?.HasFlag(MessageQueueAccessRights.ReceiveMessage), $"{NetworkServiceAccountName} should have receive messages access"); MessageQueueAccessRights?localAdminAccessRights; AccessControlEntryType? accessControlEntryTypeForLocalAdmin; Assert.True(createdQueue.TryGetPermissions(LocalAdministratorsGroupName, out localAdminAccessRights, out accessControlEntryTypeForLocalAdmin)); Assert.True(localAdminAccessRights.HasValue); Assert.True(localAdminAccessRights?.HasFlag(MessageQueueAccessRights.FullControl), $"{LocalAdministratorsGroupName} should have full control"); Assert.IsTrue(accessControlEntryTypeForLocalAdmin == AccessControlEntryType.Allow, $"{LocalAdministratorsGroupName} should have access"); }
protected async Task StartPump(Func <MessageContext, Task> onMessage, Func <ErrorContext, Task <ErrorHandleResult> > onError, TransportTransactionMode transactionMode, Action <string, Exception> onCriticalError = null) { InputQueueName = GetTestName() + transactionMode; ErrorQueueName = $"{InputQueueName}.error"; transportSettings.Set("NServiceBus.Routing.EndpointName", InputQueueName); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(InputQueueName); queueBindings.BindSending(ErrorQueueName); transportSettings.Set(ErrorQueueSettings.SettingsKey, ErrorQueueName); transportSettings.Set <QueueBindings>(queueBindings); transportSettings.Set <EndpointInstances>(new EndpointInstances()); Configurer = CreateConfigurer(); var configuration = Configurer.Configure(transportSettings, transactionMode); TransportInfrastructure = configuration.TransportInfrastructure; IgnoreUnsupportedTransactionModes(transactionMode); IgnoreUnsupportedDeliveryConstraints(); ReceiveInfrastructure = TransportInfrastructure.ConfigureReceiveInfrastructure(); SendInfrastructure = TransportInfrastructure.ConfigureSendInfrastructure(); lazyDispatcher = new Lazy <IDispatchMessages>(() => SendInfrastructure.DispatcherFactory()); MessagePump = ReceiveInfrastructure.MessagePumpFactory(); var queueCreator = ReceiveInfrastructure.QueueCreatorFactory(); await queueCreator.CreateQueueIfNecessary(queueBindings, WindowsIdentity.GetCurrent().Name); var pushSettings = new PushSettings(InputQueueName, ErrorQueueName, configuration.PurgeInputQueueOnStartup, transactionMode); await MessagePump.Init( context => { if (context.Headers.ContainsKey(TestIdHeaderName) && context.Headers[TestIdHeaderName] == testId) { return(onMessage(context)); } return(Task.FromResult(0)); }, context => { if (context.Message.Headers.ContainsKey(TestIdHeaderName) && context.Message.Headers[TestIdHeaderName] == testId) { return(onError(context)); } return(Task.FromResult(ErrorHandleResult.Handled)); }, new FakeCriticalError(onCriticalError), pushSettings); MessagePump.Start(configuration.PushRuntimeSettings); }
public void Should_setup_permissions() { var testQueueName = "MsmqQueueCreatorTests.permissions"; var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); DeleteQueueIfPresent(testQueueName); bindings.BindReceiving(testQueueName); // use the network service account since that one won't be in the local admin group creator.CreateQueueIfNecessary(bindings, NetworkServiceAccountName); var createdQueue = GetQueue(testQueueName); MessageQueueAccessRights? accountAccessRights; Assert.True(createdQueue.TryGetPermissions(NetworkServiceAccountName, out accountAccessRights)); Assert.True(accountAccessRights.HasValue, "User should have access rights"); Assert.AreEqual(MessageQueueAccessRights.WriteMessage | MessageQueueAccessRights.ReceiveMessage, accountAccessRights, "User should have write/read access"); MessageQueueAccessRights? localAdminAccessRights; Assert.True(createdQueue.TryGetPermissions(LocalAdministratorsGroupName, out localAdminAccessRights)); Assert.True(localAdminAccessRights.HasValue, "User should have access rights"); Assert.AreEqual(MessageQueueAccessRights.FullControl, localAdminAccessRights, "LocalAdmins should have full control"); }
public void Should_not_add_everyone_and_anonymous_to_already_existing_queues() { var path = MsmqAddress.Parse(testQueueNameForReceiving).PathWithoutPrefix; using (var queue = MessageQueue.Create(path)) { queue.SetPermissions(LocalEveryoneGroupName, MessageQueueAccessRights.GenericWrite, AccessControlEntryType.Revoke); queue.SetPermissions(LocalAnonymousLogonName, MessageQueueAccessRights.WriteMessage, AccessControlEntryType.Revoke); } var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueNameForReceiving); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); var existingQueue = GetQueue(testQueueNameForReceiving); MessageQueueAccessRights?nullBecauseRevoked; AccessControlEntryType? accessControlEntryType; Assert.False(existingQueue.TryGetPermissions(LocalEveryoneGroupName, out nullBecauseRevoked, out accessControlEntryType)); Assert.False(existingQueue.TryGetPermissions(LocalAnonymousLogonName, out nullBecauseRevoked, out accessControlEntryType)); Assert.IsNull(accessControlEntryType); }
public Configuration(TransportInfrastructure transportInfrastructure, QueueBindings queueBindings, bool receivingEnabled) { this.transportInfrastructure = transportInfrastructure; QueueBindings = queueBindings; ReceivingEnabled = receivingEnabled; TransportType = transportInfrastructure.GetType(); }
public void Should_setup_permissions() { var testQueueName = "MsmqQueueCreatorTests.permissions"; var creator = new QueueCreator(true); var bindings = new QueueBindings(); DeleteQueueIfPresent(testQueueName); bindings.BindReceiving(testQueueName); // use the network service account since that one won't be in the local admin group creator.CreateQueueIfNecessary(bindings, NetworkServiceAccountName); var createdQueue = GetQueue(testQueueName); MessageQueueAccessRights?accountAccessRights; Assert.True(createdQueue.TryGetPermissions(NetworkServiceAccountName, out accountAccessRights)); Assert.True(accountAccessRights.HasValue, "User should have access rights"); Assert.AreEqual(MessageQueueAccessRights.WriteMessage | MessageQueueAccessRights.ReceiveMessage, accountAccessRights, "User should have write/read access"); MessageQueueAccessRights?localAdminAccessRights; Assert.True(createdQueue.TryGetPermissions(LocalAdministratorsGroupName, out localAdminAccessRights)); Assert.True(localAdminAccessRights.HasValue, "User should have access rights"); Assert.AreEqual(MessageQueueAccessRights.FullControl, localAdminAccessRights, "LocalAdmins should have full control"); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (string address in queueBindings.ReceivingAddresses) { await CreateQueue(address); } }
public async Task Should_not_update_properties_of_an_existing_system_queue() { var queuePath = "errorQ"; var namespaceManager = new NamespaceManagerAdapter(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value)); await namespaceManager.DeleteQueue(queuePath).ConfigureAwait(false); if (!await namespaceManager.QueueExists(queuePath).ConfigureAwait(false)) { await namespaceManager.CreateQueue(new QueueDescription(queuePath)).ConfigureAwait(false); } var settings = new DefaultConfigurationValues().Apply(new SettingsHolder()); settings.Set(WellKnownConfigurationKeys.Core.RecoverabilityNumberOfImmediateRetries, 2); var queueBindings = new QueueBindings(); queueBindings.BindSending(queuePath); settings.Set <QueueBindings>(queueBindings); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.Queues().MaxDeliveryCount(2); var creator = new AzureServiceBusQueueCreator(settings); await creator.Create(queuePath, namespaceManager); var real = await namespaceManager.GetQueue(queuePath); Assert.That(real.MaxDeliveryCount, Is.EqualTo(10)); //cleanup await namespaceManager.DeleteQueue(queuePath); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (var address in queueBindings.ReceivingAddresses) { await CreateQueue(address) .ConfigureAwait(false); } }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (var address in queueBindings.ReceivingAddresses) { await CreateQueue(address) .ConfigureAwait(false); } }
public void Should_blow_up_if_name_is_null() { var creator = new QueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(null); Assert.Throws <ArgumentNullException>(() => creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name)); }
static Task CreateQueueIfNotExists(QueueAddressTranslator addressTranslator, SqlConnectionFactory sqlConnectionFactory) { var queueCreator = new QueueCreator(sqlConnectionFactory, addressTranslator, new CanonicalQueueAddress("Delayed", "dbo", "nservicebus")); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(QueueTableName); return(queueCreator.CreateQueueIfNecessary(queueBindings, "")); }
static Task CreateQueueIfNotExists(QueueAddressTranslator addressTranslator) { var queueCreator = new QueueCreator(sqlConnectionFactory, addressTranslator); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(QueueTableName); return(queueCreator.CreateQueueIfNecessary(queueBindings, "")); }
static Task CreateOutputQueueIfNecessary(QueueAddressParser addressParser) { var queueCreator = new QueueCreator(sqlConnectionFactory, addressParser); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(validAddress); return(queueCreator.CreateQueueIfNecessary(queueBindings, "")); }
static Task CreateOutputQueueIfNecessary(QueueAddressTranslator addressParser, SqlConnectionFactory sqlConnectionFactory) { var queueCreator = new QueueCreator(sqlConnectionFactory, addressParser, new CanonicalQueueAddress("Delayed", "dbo", "nservicebus")); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(validAddress); return(queueCreator.CreateQueueIfNecessary(queueBindings, "")); }
static void PurgeQueues(DbConnectionStringBuilder connectionStringBuilder, QueueBindings queueBindings) { if (connectionStringBuilder == null) { return; } var connectionFactory = new ConnectionFactory { AutomaticRecoveryEnabled = true, UseBackgroundThreadsForIO = true }; if (connectionStringBuilder.TryGetValue("username", out var value)) { connectionFactory.UserName = value.ToString(); } if (connectionStringBuilder.TryGetValue("password", out value)) { connectionFactory.Password = value.ToString(); } if (connectionStringBuilder.TryGetValue("virtualhost", out value)) { connectionFactory.VirtualHost = value.ToString(); } if (connectionStringBuilder.TryGetValue("host", out value)) { connectionFactory.HostName = value.ToString(); } else { throw new Exception("The connection string doesn't contain a value for 'host'."); } var queues = queueBindings.ReceivingAddresses.Concat(queueBindings.SendingAddresses); using (var connection = connectionFactory.CreateConnection("Test Queue Purger")) using (var channel = connection.CreateModel()) { foreach (var queue in queues) { try { channel.QueuePurge(queue); } catch (Exception ex) { Console.WriteLine("Unable to clear queue {0}: {1}", queue, ex); } } } }
public void Should_blow_up_for_invalid_accounts() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueNameForReceiving); var ex = Assert.Throws <InvalidOperationException>(() => creator.CreateQueueIfNecessary(bindings, "invalidaccount")); StringAssert.Contains("invalidaccount", ex.Message); }
public Task CreateQueuesIfNecessary(QueueBindings queueBindings, string username) { if (IsSendOnly || UseManualPump) { return(TaskEx.CompletedTask); } var queueCreator = receiveInfrastructure.QueueCreatorFactory(); return(queueCreator.CreateQueueIfNecessary(queueBindings, username)); }
public void Should_not_create_remote_queues() { var creator = new QueueCreator(true); var bindings = new QueueBindings(); var remoteQueueName = "MsmqQueueCreatorTests.remote"; bindings.BindSending($"{remoteQueueName}@some-machine"); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); Assert.False(QueueExists(remoteQueueName)); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { await queueCreator.CreateQueueIfNecessary(queueBindings, identity).ConfigureAwait(false); using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) using (var transaction = connection.BeginTransaction()) { await CreateDelayedMessageQueue(delayedMessageTable, connection, transaction, createMessageBodyComputedColumn).ConfigureAwait(false); transaction.Commit(); } }
public void Should_not_create_remote_queues() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); var remoteQueueName = "MsmqQueueCreatorTests.remote"; bindings.BindSending($"{remoteQueueName}@some-machine"); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); Assert.False(QueueExists(remoteQueueName)); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { using (var connection = connectionConfig.CreateConnection("CreateSubscription")) { await connection.ConnectAsync(); foreach (var queueBinding in queueBindings.ReceivingAddresses) { await EnsureSubscriptionExists(queueBinding, connection).ConfigureAwait(false); } } }
public void Should_not_create_queue_when_a_remote_queue_is_provided() { var remoteQueueName = $"{testQueueNameForReceiving}@some-machine"; var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindSending(remoteQueueName); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); Assert.False(QueueExists(testQueueNameForReceiving)); }
public void Should_make_queues_non_transactional_if_requested() { var creator = new MsmqQueueCreator(false); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueNameForReceiving); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); var queue = GetQueue(testQueueNameForReceiving); Assert.False(queue.Transactional); }
public void Should_create_all_queues() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueNameForReceiving); bindings.BindSending(testQueueNameForSending); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); Assert.True(QueueExists(testQueueNameForSending)); Assert.True(QueueExists(testQueueNameForReceiving)); }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (string address in queueBindings.SendingAddresses) { CreateQueueFolder(address); } foreach (string address in queueBindings.ReceivingAddresses) { CreateQueueFolder(address); } return TaskEx.CompletedTask; }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (var address in queueBindings.SendingAddresses) { Console.WriteLine($"Would create sending address [${address}"); } foreach (var address in queueBindings.ReceivingAddresses) { Console.WriteLine($"Would create receiving address [${address}"); } return(Task.CompletedTask); }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (var receivingAddress in queueBindings.ReceivingAddresses) { CreateQueueIfNecessary(receivingAddress, identity); } foreach (var sendingAddress in queueBindings.SendingAddresses) { CreateQueueIfNecessary(sendingAddress, identity); } return TaskEx.CompletedTask; }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { var tasks = new List <Task>(); foreach (var address in queueBindings.SendingAddresses) { tasks.Add(CreateQueueIfNecessary(address, false)); } foreach (var address in queueBindings.ReceivingAddresses) { tasks.Add(CreateQueueIfNecessary(address, configuration.IsDelayedDeliveryEnabled)); } return(Task.WhenAll(tasks)); }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { foreach (var address in queueBindings.SendingAddresses) { CreateQueueDirectory(address); } foreach (var address in queueBindings.ReceivingAddresses) { CreateQueueDirectory(address); } return(TaskEx.CompletedTask); }
public void Should_make_queues_transactional_if_requested() { var testQueueName = "MsmqQueueCreatorTests.txreceiver"; DeleteQueueIfPresent(testQueueName); var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueName); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); var queue = GetQueue(testQueueName); Assert.True(queue.Transactional); }
public void Should_create_all_queues() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); DeleteQueueIfPresent("MsmqQueueCreatorTests.receiver"); DeleteQueueIfPresent("MsmqQueueCreatorTests.endpoint1"); DeleteQueueIfPresent("MsmqQueueCreatorTests.endpoint2"); bindings.BindReceiving("MsmqQueueCreatorTests.receiver"); bindings.BindSending("MsmqQueueCreatorTests.target1"); bindings.BindSending("MsmqQueueCreatorTests.target2"); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); Assert.True(QueueExists("MsmqQueueCreatorTests.receiver")); Assert.True(QueueExists("MsmqQueueCreatorTests.target1")); Assert.True(QueueExists("MsmqQueueCreatorTests.target2")); }
public async Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { await Task.WhenAll(queueBindings.SendingAddresses.Select(CreateQueue)); }
public void Should_not_add_everyone_and_anonymous_to_already_existing_queues() { var testQueueName = "MsmqQueueCreatorTests.NoChangesToExisting"; DeleteQueueIfPresent(testQueueName); var path = MsmqAddress.Parse(testQueueName).PathWithoutPrefix; using (var existingQueue = MessageQueue.Create(path)) { existingQueue.SetPermissions(LocalEveryoneGroupName, MessageQueueAccessRights.GenericWrite, AccessControlEntryType.Revoke); existingQueue.SetPermissions(LocalAnonymousLogonName, MessageQueueAccessRights.WriteMessage, AccessControlEntryType.Revoke); } var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueName); creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name); var queue = GetQueue(testQueueName); MessageQueueAccessRights? nullBecauseRevoked; Assert.False(queue.TryGetPermissions(LocalEveryoneGroupName, out nullBecauseRevoked)); Assert.False(queue.TryGetPermissions(LocalAnonymousLogonName, out nullBecauseRevoked)); }
public void Should_allow_queue_names_above_the_limit_for_set_permission() { var testQueueName = $"MsmqQueueCreatorTests.tolong.{Guid.NewGuid().ToString().Replace("-", "")}"; var maxQueueNameForSetPermissionToWork = 102 - Environment.MachineName.Length; testQueueName = $"{testQueueName}{new string('a', maxQueueNameForSetPermissionToWork - testQueueName.Length + 1)}"; DeleteQueueIfPresent(testQueueName); var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueName); Assert.DoesNotThrow(() => creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name)); }
public void Should_blow_up_for_invalid_accounts() { var testQueueName = "MsmqQueueCreatorTests.badidentity"; DeleteQueueIfPresent(testQueueName); var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(testQueueName); var ex = Assert.Throws<InvalidOperationException>(() => creator.CreateQueueIfNecessary(bindings, "invalidaccount")); StringAssert.Contains("invalidaccount", ex.Message); }
public void Should_blow_up_if_name_is_null() { var creator = new MsmqQueueCreator(true); var bindings = new QueueBindings(); bindings.BindReceiving(null); Assert.Throws<ArgumentNullException>(() => creator.CreateQueueIfNecessary(bindings, WindowsIdentity.GetCurrent().Name)); }
public Task CreateQueueIfNecessary(QueueBindings queueBindings, string identity) { return Task.FromResult(0); }