Exemplo n.º 1
0
        public void RegisteredServerTriggerRolloverTest()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                IResourceManagementClient    resourcesClient             = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler);
                IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler);

                // Create ResourceGroup
                string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient);

                // Create RegisteredServer Name
                string storageSyncServiceName = TestUtilities.GenerateName("sss-rscert");
                Guid   serverGuid             = TestUtilities.GenerateGuid();

                var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters();
                var registeredServerParameters   = StorageSyncManagementTestUtilities.GetDefaultRegisteredServerParameters(serverGuid);

                StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters);
                Assert.NotNull(storageSyncServiceResource);
                StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true);

                RegisteredServer registeredServerResource = storageSyncManagementClient.RegisteredServers.Create(resourceGroupName, storageSyncServiceResource.Name, serverGuid.ToString(), registeredServerParameters);
                Assert.NotNull(registeredServerResource);
                StorageSyncManagementTestUtilities.VerifyRegisteredServerProperties(registeredServerResource, true);

                registeredServerResource = storageSyncManagementClient.RegisteredServers.Get(resourceGroupName, storageSyncServiceResource.Name, serverGuid.ToString());
                StorageSyncManagementTestUtilities.VerifyRegisteredServerProperties(registeredServerResource, true);

                string serverCertificate = StorageSyncManagementTestUtilities.GetSecondaryCertificate();
                storageSyncManagementClient.RegisteredServers.TriggerRollover(resourceGroupName, storageSyncServiceResource.Name, serverGuid.ToString(), serverCertificate);

                storageSyncManagementClient.RegisteredServers.Delete(resourceGroupName, storageSyncServiceResource.Name, serverGuid.ToString());
                storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name);
                StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName);
            }
        }