예제 #1
0
        public void NamespaceCreateGetUpdateDeleteAuthorizationRules()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                // Create a namespace
                var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);

                var nameAvailable = EventHubManagementClient.Namespaces.CheckNameAvailability(new CheckNameAvailabilityParameter(namespaceName));

                var createNamespaceResponse = EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
                                                                                                 new EHNamespace()
                {
                    Location = location,
                    Sku      = new Sku
                    {
                        Name = SkuName.Standard,
                        Tier = SkuTier.Standard
                    },
                    Tags = new Dictionary <string, string>()
                    {
                        { "tag1", "value1" },
                        { "tag2", "value2" }
                    }
                });

                Assert.NotNull(createNamespaceResponse);
                Assert.Equal(createNamespaceResponse.Name, namespaceName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created namespace
                var getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                if (string.Compare(getNamespaceResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                Assert.NotNull(getNamespaceResponse);
                Assert.Equal("Succeeded", getNamespaceResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                Assert.Equal(location, getNamespaceResponse.Location, StringComparer.CurrentCultureIgnoreCase);

                // Create a namespace AuthorizationRule
                var    authorizationRuleName           = TestUtilities.GenerateName(EventHubManagementHelper.AuthorizationRulesPrefix);
                string createPrimaryKey                = HttpMockServer.GetVariable("CreatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                var    createAutorizationRuleParameter = new AuthorizationRule()
                {
                    Rights = new List <string>()
                    {
                        AccessRights.Listen, AccessRights.Send
                    }
                };

                var jsonStr = EventHubManagementHelper.ConvertObjectToJSon(createAutorizationRuleParameter);

                var createNamespaceAuthorizationRuleResponse = EventHubManagementClient.Namespaces.CreateOrUpdateAuthorizationRule(resourceGroup, namespaceName,
                                                                                                                                   authorizationRuleName, createAutorizationRuleParameter);
                Assert.NotNull(createNamespaceAuthorizationRuleResponse);
                Assert.True(createNamespaceAuthorizationRuleResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                foreach (var right in createAutorizationRuleParameter.Rights)
                {
                    Assert.Contains(createNamespaceAuthorizationRuleResponse.Rights, r => r == right);
                }

                // Get default namespace AuthorizationRules
                var getNamespaceAuthorizationRulesResponse = EventHubManagementClient.Namespaces.GetAuthorizationRule(resourceGroup, namespaceName, EventHubManagementHelper.DefaultNamespaceAuthorizationRule);
                Assert.NotNull(getNamespaceAuthorizationRulesResponse);
                Assert.Equal(getNamespaceAuthorizationRulesResponse.Name, EventHubManagementHelper.DefaultNamespaceAuthorizationRule);
                Assert.Contains(getNamespaceAuthorizationRulesResponse.Rights, r => r == AccessRights.Listen);
                Assert.Contains(getNamespaceAuthorizationRulesResponse.Rights, r => r == AccessRights.Send);
                Assert.Contains(getNamespaceAuthorizationRulesResponse.Rights, r => r == AccessRights.Manage);

                // Get created namespace AuthorizationRules
                getNamespaceAuthorizationRulesResponse = EventHubManagementClient.Namespaces.GetAuthorizationRule(resourceGroup, namespaceName, authorizationRuleName);
                Assert.NotNull(getNamespaceAuthorizationRulesResponse);
                Assert.True(getNamespaceAuthorizationRulesResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                foreach (var right in createAutorizationRuleParameter.Rights)
                {
                    Assert.Contains(getNamespaceAuthorizationRulesResponse.Rights, r => r == right);
                }

                // Get all namespaces AuthorizationRules
                var getAllNamespaceAuthorizationRulesResponse = EventHubManagementClient.Namespaces.ListAuthorizationRules(resourceGroup, namespaceName);
                Assert.NotNull(getAllNamespaceAuthorizationRulesResponse);
                Assert.True(getAllNamespaceAuthorizationRulesResponse.Count() > 1);
                Assert.Contains(getAllNamespaceAuthorizationRulesResponse, ns => ns.Name == authorizationRuleName);
                Assert.Contains(getAllNamespaceAuthorizationRulesResponse, auth => auth.Name == EventHubManagementHelper.DefaultNamespaceAuthorizationRule);

                // Update namespace authorizationRule
                string            updatePrimaryKey = HttpMockServer.GetVariable("UpdatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                AuthorizationRule updateNamespaceAuthorizationRuleParameter = new AuthorizationRule();
                updateNamespaceAuthorizationRuleParameter.Rights = new List <string>()
                {
                    AccessRights.Listen
                };

                var updateNamespaceAuthorizationRuleResponse = EventHubManagementClient.Namespaces.CreateOrUpdateAuthorizationRule(resourceGroup,
                                                                                                                                   namespaceName, authorizationRuleName, updateNamespaceAuthorizationRuleParameter);

                Assert.NotNull(updateNamespaceAuthorizationRuleResponse);
                Assert.Equal(authorizationRuleName, updateNamespaceAuthorizationRuleResponse.Name);
                Assert.True(updateNamespaceAuthorizationRuleResponse.Rights.Count == updateNamespaceAuthorizationRuleParameter.Rights.Count);
                foreach (var right in updateNamespaceAuthorizationRuleParameter.Rights)
                {
                    Assert.Contains(updateNamespaceAuthorizationRuleResponse.Rights, r => r.Equals(right));
                }

                // Get the updated namespace AuthorizationRule
                var getNamespaceAuthorizationRuleResponse = EventHubManagementClient.Namespaces.GetAuthorizationRule(resourceGroup, namespaceName,
                                                                                                                     authorizationRuleName);
                Assert.NotNull(getNamespaceAuthorizationRuleResponse);
                Assert.Equal(authorizationRuleName, getNamespaceAuthorizationRuleResponse.Name);
                Assert.True(getNamespaceAuthorizationRuleResponse.Rights.Count == updateNamespaceAuthorizationRuleParameter.Rights.Count);
                foreach (var right in updateNamespaceAuthorizationRuleParameter.Rights)
                {
                    Assert.Contains(getNamespaceAuthorizationRuleResponse.Rights, r => r.Equals(right));
                }

                // Get the connection string to the namespace for a Authorization rule created
                var listKeysResponse = EventHubManagementClient.Namespaces.ListKeys(resourceGroup, namespaceName, authorizationRuleName);
                Assert.NotNull(listKeysResponse);
                Assert.NotNull(listKeysResponse.PrimaryConnectionString);
                Assert.NotNull(listKeysResponse.SecondaryConnectionString);

                // Regenerate connection string to the namespace for a Authorization rule created
                var NewKeysResponse_primary = EventHubManagementClient.Namespaces.RegenerateKeys(resourceGroup, namespaceName, authorizationRuleName, new RegenerateAccessKeyParameters(KeyType.PrimaryKey));
                Assert.NotNull(NewKeysResponse_primary);
                Assert.NotEqual(NewKeysResponse_primary.PrimaryConnectionString, listKeysResponse.PrimaryConnectionString);
                Assert.Equal(NewKeysResponse_primary.SecondaryConnectionString, listKeysResponse.SecondaryConnectionString);

                // Regenerate connection string to the namespace for a Authorization rule created
                var NewKeysResponse_secondary = EventHubManagementClient.Namespaces.RegenerateKeys(resourceGroup, namespaceName, authorizationRuleName, new RegenerateAccessKeyParameters(KeyType.SecondaryKey));
                Assert.NotNull(NewKeysResponse_secondary);
                Assert.NotEqual(NewKeysResponse_secondary.PrimaryConnectionString, listKeysResponse.PrimaryConnectionString);
                Assert.NotEqual(NewKeysResponse_secondary.SecondaryConnectionString, listKeysResponse.SecondaryConnectionString);

                // Delete namespace authorizationRule
                EventHubManagementClient.Namespaces.DeleteAuthorizationRule(resourceGroup, namespaceName, authorizationRuleName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Delete namespace
                EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);
            }
        }
        public void EventhubCreateGetUpdateDeleteAuthorizationRules_Length()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                InitializeClients(context);

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                // Create a namespace
                var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);

                var createNamespaceResponse = this.EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
                                                                                                      new EHNamespace()
                {
                    Location = location,
                    Sku      = new Sku
                    {
                        Name = SkuName.Standard,
                        Tier = SkuTier.Standard
                    },
                    Tags = new Dictionary <string, string>()
                    {
                        { "tag1", "value1" },
                        { "tag2", "value2" }
                    }
                });

                Assert.NotNull(createNamespaceResponse);
                Assert.Equal(createNamespaceResponse.Name, namespaceName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created namespace
                var getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                if (string.Compare(getNamespaceResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                Assert.NotNull(getNamespaceResponse);
                Assert.Equal("Succeeded", getNamespaceResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                Assert.Equal(location, getNamespaceResponse.Location, StringComparer.CurrentCultureIgnoreCase);

                // Create Eventhub
                var eventhubName           = EventHubManagementHelper.EventHubPrefix + "thisisthenamewithmorethan53charschecktoverifytheremovlaof50charsnamelengthlimit";
                var createEventhubResponse = this.EventHubManagementClient.EventHubs.CreateOrUpdate(resourceGroup, namespaceName, eventhubName,
                                                                                                    new Eventhub()
                {
                    MessageRetentionInDays = 5
                });

                Assert.NotNull(createEventhubResponse);
                Assert.Equal(createEventhubResponse.Name, eventhubName);

                // Get the created EventHub
                var geteventhubResponse = EventHubManagementClient.EventHubs.Get(resourceGroup, namespaceName, eventhubName);
                Assert.NotNull(geteventhubResponse);
                Assert.Equal(EntityStatus.Active, geteventhubResponse.Status);
                Assert.Equal(geteventhubResponse.Name, eventhubName);

                // Create a EventHub AuthorizationRule
                var    authorizationRuleName           = EventHubManagementHelper.AuthorizationRulesPrefix + "thisisthenamewithmorethan53charschecktoverifytheremovlaof50charsnamelengthlimit";
                string createPrimaryKey                = HttpMockServer.GetVariable("CreatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                var    createAutorizationRuleParameter = new AuthorizationRule()
                {
                    Rights = new List <string>()
                    {
                        AccessRights.Listen, AccessRights.Send
                    }
                };

                var jsonStr = EventHubManagementHelper.ConvertObjectToJSon(createAutorizationRuleParameter);

                var createEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.CreateOrUpdateAuthorizationRule(resourceGroup, namespaceName, eventhubName,
                                                                                                                                 authorizationRuleName, createAutorizationRuleParameter);
                Assert.NotNull(createEventhubAuthorizationRuleResponse);
                Assert.True(createEventhubAuthorizationRuleResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                foreach (var right in createAutorizationRuleParameter.Rights)
                {
                    Assert.Contains(createEventhubAuthorizationRuleResponse.Rights, r => r == right);
                }

                // Get created Eventhub AuthorizationRules
                var getEventhubAuthorizationRulesResponse = EventHubManagementClient.EventHubs.GetAuthorizationRule(resourceGroup, namespaceName, eventhubName, authorizationRuleName);
                Assert.NotNull(getEventhubAuthorizationRulesResponse);
                Assert.True(getEventhubAuthorizationRulesResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                foreach (var right in createAutorizationRuleParameter.Rights)
                {
                    Assert.Contains(getEventhubAuthorizationRulesResponse.Rights, r => r == right);
                }

                // Get all Eventhub AuthorizationRules
                var getAllNamespaceAuthorizationRulesResponse = EventHubManagementClient.EventHubs.ListAuthorizationRules(resourceGroup, namespaceName, eventhubName);
                Assert.NotNull(getAllNamespaceAuthorizationRulesResponse);
                Assert.True(getAllNamespaceAuthorizationRulesResponse.Count() == 1);
                Assert.Contains(getAllNamespaceAuthorizationRulesResponse, ns => ns.Name == authorizationRuleName);

                // Update Eventhub authorizationRule
                string            updatePrimaryKey = HttpMockServer.GetVariable("UpdatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                AuthorizationRule updateEventhubAuthorizationRuleParameter = new AuthorizationRule();
                updateEventhubAuthorizationRuleParameter.Rights = new List <string>()
                {
                    AccessRights.Listen
                };

                var updateEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.CreateOrUpdateAuthorizationRule(resourceGroup,
                                                                                                                                 namespaceName, eventhubName, authorizationRuleName, updateEventhubAuthorizationRuleParameter);

                Assert.NotNull(updateEventhubAuthorizationRuleResponse);
                Assert.Equal(authorizationRuleName, updateEventhubAuthorizationRuleResponse.Name);
                Assert.True(updateEventhubAuthorizationRuleResponse.Rights.Count == updateEventhubAuthorizationRuleParameter.Rights.Count);
                foreach (var right in updateEventhubAuthorizationRuleParameter.Rights)
                {
                    Assert.Contains(updateEventhubAuthorizationRuleResponse.Rights, r => r.Equals(right));
                }

                // Get the updated Eventhub AuthorizationRule
                var getEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.GetAuthorizationRule(resourceGroup, namespaceName, eventhubName,
                                                                                                                   authorizationRuleName);
                Assert.NotNull(getEventhubAuthorizationRuleResponse);
                Assert.Equal(authorizationRuleName, getEventhubAuthorizationRuleResponse.Name);
                Assert.True(getEventhubAuthorizationRuleResponse.Rights.Count == updateEventhubAuthorizationRuleParameter.Rights.Count);
                foreach (var right in updateEventhubAuthorizationRuleParameter.Rights)
                {
                    Assert.Contains(getEventhubAuthorizationRuleResponse.Rights, r => r.Equals(right));
                }

                // Get the connectionString to the Eventhub for a Authorization rule created
                var listKeysResponse = EventHubManagementClient.EventHubs.ListKeys(resourceGroup, namespaceName, eventhubName, authorizationRuleName);
                Assert.NotNull(listKeysResponse);
                Assert.NotNull(listKeysResponse.PrimaryConnectionString);
                Assert.NotNull(listKeysResponse.SecondaryConnectionString);

                //New connection string
                var regenerateConnection_primary = EventHubManagementClient.EventHubs.RegenerateKeys(resourceGroup, namespaceName, eventhubName, authorizationRuleName, new RegenerateAccessKeyParameters(KeyType.PrimaryKey));
                Assert.NotNull(regenerateConnection_primary);
                Assert.NotEqual(listKeysResponse.PrimaryConnectionString, regenerateConnection_primary.PrimaryConnectionString);
                Assert.Equal(listKeysResponse.SecondaryConnectionString, regenerateConnection_primary.SecondaryConnectionString);

                var regenerateConnection_Secondary = EventHubManagementClient.EventHubs.RegenerateKeys(resourceGroup, namespaceName, eventhubName, authorizationRuleName, new RegenerateAccessKeyParameters(KeyType.SecondaryKey));
                Assert.NotNull(regenerateConnection_Secondary);
                Assert.NotEqual(listKeysResponse.SecondaryConnectionString, regenerateConnection_Secondary.SecondaryConnectionString);
                Assert.Equal(regenerateConnection_primary.PrimaryConnectionString, regenerateConnection_Secondary.PrimaryConnectionString);

                // Delete Eventhub authorizationRule
                EventHubManagementClient.EventHubs.DeleteAuthorizationRule(resourceGroup, namespaceName, eventhubName, authorizationRuleName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Delete Eventhub and check for the NotFound exception
                EventHubManagementClient.EventHubs.Delete(resourceGroup, namespaceName, eventhubName);

                // Delete namespace and check for the NotFound exception
                EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);
            }
        }
예제 #3
0
        public void EventhubCreateGetUpdateDeleteAuthorizationRules_Length()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                // Create Eventhub
                var eventhubName = EventHubManagementHelper.EventHubPrefix;
                while (eventhubName.Length != 256)
                {
                    eventhubName += TestUtilities.GenerateName();

                    if (eventhubName.Length > 256)
                    {
                        eventhubName = eventhubName.Substring(1, 256);
                    }
                }

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = string.Empty;
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                // Create a namespace
                var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);

                try
                {
                    var createNamespaceResponse = this.EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
                                                                                                          new EHNamespace()
                    {
                        Location = location,
                        Sku      = new Sku
                        {
                            Name = SkuName.Standard,
                            Tier = SkuTier.Standard
                        },
                        Tags = new Dictionary <string, string>()
                        {
                            { "tag1", "value1" },
                            { "tag2", "value2" }
                        }
                    });

                    Assert.NotNull(createNamespaceResponse);
                    Assert.Equal(createNamespaceResponse.Name, namespaceName);

                    TestUtilities.Wait(TimeSpan.FromSeconds(5));

                    // Get the created namespace
                    var getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                    if (string.Compare(getNamespaceResponse.ProvisioningState, "Succeeded", true) != 0)
                    {
                        TestUtilities.Wait(TimeSpan.FromSeconds(5));
                    }

                    getNamespaceResponse = EventHubManagementClient.Namespaces.Get(resourceGroup, namespaceName);
                    Assert.NotNull(getNamespaceResponse);
                    Assert.Equal("Succeeded", getNamespaceResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                    Assert.Equal(location, getNamespaceResponse.Location, StringComparer.CurrentCultureIgnoreCase);


                    var createEventhubResponse = this.EventHubManagementClient.EventHubs.CreateOrUpdate(resourceGroup, namespaceName, eventhubName,
                                                                                                        new Eventhub()
                    {
                        MessageRetentionInDays = 5
                    });

                    Assert.NotNull(createEventhubResponse);
                    Assert.Equal(createEventhubResponse.Name, eventhubName);
                    Assert.Equal <int>(256, createEventhubResponse.Name.Length);

                    // Get the created EventHub
                    var geteventhubResponse = EventHubManagementClient.EventHubs.Get(resourceGroup, namespaceName, eventhubName);
                    Assert.NotNull(geteventhubResponse);
                    Assert.Equal(EntityStatus.Active, geteventhubResponse.Status);
                    Assert.Equal(geteventhubResponse.Name, eventhubName);
                    Assert.Equal <int>(256, geteventhubResponse.Name.Length);

                    // Create a EventHub AuthorizationRule
                    var    authorizationRuleName           = EventHubManagementHelper.AuthorizationRulesPrefix;
                    string createPrimaryKey                = HttpMockServer.GetVariable("CreatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                    var    createAutorizationRuleParameter = new AuthorizationRule()
                    {
                        Rights = new List <string>()
                        {
                            AccessRights.Listen, AccessRights.Send
                        }
                    };

                    var jsonStr = EventHubManagementHelper.ConvertObjectToJSon(createAutorizationRuleParameter);

                    var createEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.CreateOrUpdateAuthorizationRule(resourceGroup, namespaceName, eventhubName,
                                                                                                                                     authorizationRuleName, createAutorizationRuleParameter.Rights);
                    Assert.NotNull(createEventhubAuthorizationRuleResponse);
                    Assert.True(createEventhubAuthorizationRuleResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                    foreach (var right in createAutorizationRuleParameter.Rights)
                    {
                        Assert.Contains(createEventhubAuthorizationRuleResponse.Rights, r => r == right);
                    }

                    // Get created Eventhub AuthorizationRules
                    var getEventhubAuthorizationRulesResponse = EventHubManagementClient.EventHubs.GetAuthorizationRule(resourceGroup, namespaceName, eventhubName, authorizationRuleName);
                    Assert.NotNull(getEventhubAuthorizationRulesResponse);
                    Assert.True(getEventhubAuthorizationRulesResponse.Rights.Count == createAutorizationRuleParameter.Rights.Count);
                    foreach (var right in createAutorizationRuleParameter.Rights)
                    {
                        Assert.Contains(getEventhubAuthorizationRulesResponse.Rights, r => r == right);
                    }

                    // Get all Eventhub AuthorizationRules
                    var getAllNamespaceAuthorizationRulesResponse = EventHubManagementClient.EventHubs.ListAuthorizationRules(resourceGroup, namespaceName, eventhubName);
                    Assert.NotNull(getAllNamespaceAuthorizationRulesResponse);
                    Assert.True(getAllNamespaceAuthorizationRulesResponse.Count() == 1);
                    Assert.Contains(getAllNamespaceAuthorizationRulesResponse, ns => ns.Name == authorizationRuleName);

                    // Update Eventhub authorizationRule
                    string            updatePrimaryKey = HttpMockServer.GetVariable("UpdatePrimaryKey", EventHubManagementHelper.GenerateRandomKey());
                    AuthorizationRule updateEventhubAuthorizationRuleParameter = new AuthorizationRule();
                    updateEventhubAuthorizationRuleParameter.Rights = new List <string>()
                    {
                        AccessRights.Listen
                    };

                    var updateEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.CreateOrUpdateAuthorizationRule(resourceGroup,
                                                                                                                                     namespaceName, eventhubName, authorizationRuleName, updateEventhubAuthorizationRuleParameter.Rights);

                    Assert.NotNull(updateEventhubAuthorizationRuleResponse);
                    Assert.Equal(authorizationRuleName, updateEventhubAuthorizationRuleResponse.Name);
                    Assert.True(updateEventhubAuthorizationRuleResponse.Rights.Count == updateEventhubAuthorizationRuleParameter.Rights.Count);
                    foreach (var right in updateEventhubAuthorizationRuleParameter.Rights)
                    {
                        Assert.Contains(updateEventhubAuthorizationRuleResponse.Rights, r => r.Equals(right));
                    }

                    // Get the updated Eventhub AuthorizationRule
                    var getEventhubAuthorizationRuleResponse = EventHubManagementClient.EventHubs.GetAuthorizationRule(resourceGroup, namespaceName, eventhubName,
                                                                                                                       authorizationRuleName);
                    Assert.NotNull(getEventhubAuthorizationRuleResponse);
                    Assert.Equal(authorizationRuleName, getEventhubAuthorizationRuleResponse.Name);
                    Assert.True(getEventhubAuthorizationRuleResponse.Rights.Count == updateEventhubAuthorizationRuleParameter.Rights.Count);
                    foreach (var right in updateEventhubAuthorizationRuleParameter.Rights)
                    {
                        Assert.Contains(getEventhubAuthorizationRuleResponse.Rights, r => r.Equals(right));
                    }

                    // Get the connectionString to the Eventhub for a Authorization rule created
                    var listKeysResponse = EventHubManagementClient.EventHubs.ListKeys(resourceGroup, namespaceName, eventhubName, authorizationRuleName);
                    Assert.NotNull(listKeysResponse);
                    Assert.NotNull(listKeysResponse.PrimaryConnectionString);
                    Assert.NotNull(listKeysResponse.SecondaryConnectionString);

                    //New connection string
                    var regenerateConnection_primary = EventHubManagementClient.EventHubs.RegenerateKeys(resourceGroup, namespaceName, eventhubName, authorizationRuleName, KeyType.PrimaryKey);
                    Assert.NotNull(regenerateConnection_primary);
                    Assert.NotEqual(listKeysResponse.PrimaryConnectionString, regenerateConnection_primary.PrimaryConnectionString);
                    Assert.Equal(listKeysResponse.SecondaryConnectionString, regenerateConnection_primary.SecondaryConnectionString);

                    // Delete Eventhub authorizationRule
                    EventHubManagementClient.EventHubs.DeleteAuthorizationRule(resourceGroup, namespaceName, eventhubName, authorizationRuleName);

                    TestUtilities.Wait(TimeSpan.FromSeconds(5));

                    // Delete Eventhub and check for the NotFound exception
                    EventHubManagementClient.EventHubs.Delete(resourceGroup, namespaceName, eventhubName);

                    // Delete namespace and check for the NotFound exception
                    EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);
                }
                finally
                {
                    //Delete Resource Group
                    // this.ResourceManagementClient.ResourceGroups.DeleteWithHttpMessagesAsync(resourceGroup, null, default(CancellationToken)).ConfigureAwait(false);
                    Console.WriteLine("End of EH2018 Namespace CRUD IPFilter Rules test");
                }
            }
        }