Beispiel #1
0
        private void SetupManagementClients(MockContext context)
        {
            LegacyResourceManagementClient = GetLegacyResourceManagementClient();
            LegacySubscriptionClient       = GetLegacySubscriptionClient();
            ResourceManagementClient       = GetResourceManagementClient(context);
            SubscriptionClient             = GetSubscriptionClient(context);
            GalleryClient = GetGalleryClient();
            AuthorizationManagementClient = GetAuthorizationManagementClient();
            GraphClient        = GetGraphClient(context);
            InsightsClient     = GetInsightsClient();
            this.FeatureClient = this.GetFeatureClient(context);
            var testEnvironment = this.csmTestFactory.GetTestEnvironment();
            var credentials     = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[Microsoft.Azure.Test.TokenAudience.Management],
                testEnvironment.SubscriptionId);

            HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(credentials);

            helper.SetupManagementClients(ResourceManagementClient,
                                          LegacyResourceManagementClient,
                                          LegacySubscriptionClient,
                                          SubscriptionClient,
                                          GalleryClient,
                                          AuthorizationManagementClient,
                                          GraphClient,
                                          InsightsClient,
                                          this.FeatureClient);
        }
Beispiel #2
0
        public static T GetServiceClient <T>() where T : class
        {
            var factory         = (TestEnvironmentFactory) new CSMTestEnvironmentFactory();
            var testEnvironment = factory.GetTestEnvironment();

            ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;

            RecoveryServicesNS.RecoveryServicesManagementClient client;
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[TokenAudience.Management],
                testEnvironment.SubscriptionId);

            if (testEnvironment.UsesCustomUri())
            {
                client = new RecoveryServicesNS.RecoveryServicesManagementClient(
                    "Microsoft.RecoveryServices",
                    credentials,
                    testEnvironment.BaseUri);
            }
            else
            {
                client = new RecoveryServicesNS.RecoveryServicesManagementClient(
                    "Microsoft.RecoveryServices",
                    credentials);
            }
            return(GetServiceClient <T>(factory, client));
        }
Beispiel #3
0
        private void SetupManagementClients(MockContext context)
        {
            this.serviceClient = this.ConstructServiceClient(context);

            this.resourceManagementClient = context.GetServiceClient <ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
            this.storageManagementClient  = LegacyTest.TestBase.GetServiceClient <StorageManagementClient>(this.csmTestFactory);
            var subscriptionClient   = LegacyTest.TestBase.GetServiceClient <SubscriptionClient>(this.csmTestFactory);
            var authManagementClient = LegacyTest.TestBase.GetServiceClient <AuthorizationManagementClient>(this.csmTestFactory);
            var gallleryClient       = LegacyTest.TestBase.GetServiceClient <GalleryClient>(this.csmTestFactory);

            var testEnvironment = this.csmTestFactory.GetTestEnvironment();

            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[Microsoft.Azure.Test.TokenAudience.Management],
                testEnvironment.SubscriptionId);

            HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(credentials);

            helper.SetupManagementClients(
                this.resourceManagementClient,
                subscriptionClient,
                this.serviceClient,
                authManagementClient,
                gallleryClient,
                this.storageManagementClient);
        }
Beispiel #4
0
        private RecoveryServicesBackupManagementClient GetRsBackupClient()
        {
            var factory = (TestEnvironmentFactory)new CSMTestEnvironmentFactory();

            var testEnvironment = factory.GetTestEnvironment();

            ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;

            RecoveryServicesBackupManagementClient client;
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[TokenAudience.Management],
                testEnvironment.SubscriptionId);

            if (testEnvironment.UsesCustomUri())
            {
                client = new RecoveryServicesBackupManagementClient(
                    credentials,
                    testEnvironment.BaseUri);
            }

            else
            {
                client = new RecoveryServicesBackupManagementClient(
                    credentials);
            }

            client.ResourceNamespace = this.ResourceNamespace;

            return GetServiceClient<RecoveryServicesBackupManagementClient>(factory, client);
        }
Beispiel #5
0
        public T GetServiceClient <T>() where T : class
        {
            var factory         = (TestEnvironmentFactory) new CSMTestEnvironmentFactory();
            var testEnvironment = factory.GetTestEnvironment();

            ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[TokenAudience.Management],
                testEnvironment.SubscriptionId);

            if (typeof(T) == typeof(SiteRecoveryVaultManagementClient))
            {
                SiteRecoveryVaultManagementClient client;

                if (testEnvironment.UsesCustomUri())
                {
                    client = new SiteRecoveryVaultManagementClient(
                        "Microsoft.SiteRecoveryBVTD2",
                        "SiteRecoveryVault",
                        credentials,
                        testEnvironment.BaseUri);
                }
                else
                {
                    client = new SiteRecoveryVaultManagementClient(
                        "Microsoft.SiteRecovery",
                        "SiteRecoveryVault",
                        credentials);
                }
                return(GetRSMServiceClient <T>(factory, client));
            }
            else
            {
                SiteRecoveryManagementClient client;

                if (testEnvironment.UsesCustomUri())
                {
                    client = new SiteRecoveryManagementClient(
                        asrVaultCreds.ResourceName,
                        asrVaultCreds.ResourceGroupName,
                        "Microsoft.SiteRecoveryBVTD2",
                        "SiteRecoveryVault",
                        credentials,
                        testEnvironment.BaseUri);
                }

                else
                {
                    client = new SiteRecoveryManagementClient(
                        asrVaultCreds.ResourceName,
                        asrVaultCreds.ResourceGroupName,
                        "Microsoft.SiteRecovery",
                        "vaults",
                        credentials);
                }

                return(GetSRMServiceClient <T>(factory, client));
            }
        }
Beispiel #6
0
        public static T GetServiceClient <T>() where T : class
        {
            var factory = (TestEnvironmentFactory) new RDFETestEnvironmentFactory();

            var testEnvironment = factory.GetTestEnvironment();

            ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;

            StorSimpleManagementClient client;
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[TokenAudience.Management],
                testEnvironment.SubscriptionId);

            if (testEnvironment.UsesCustomUri())
            {
                client = new StorSimpleManagementClient(
                    ConfigurationManager.AppSettings["CloudServiceName"],
                    ConfigurationManager.AppSettings["ResourceName"],
                    ConfigurationManager.AppSettings["ResourceId"],
                    ConfigurationManager.AppSettings["ResourceNamespace"],
                    credentials,
                    testEnvironment.BaseUri);
            }

            else
            {
                client = new StorSimpleManagementClient(
                    ConfigurationManager.AppSettings["CloudServiceName"],
                    ConfigurationManager.AppSettings["ResourceName"],
                    ConfigurationManager.AppSettings["ResourceId"],
                    ConfigurationManager.AppSettings["ResourceNamespace"],
                    credentials);
            }

            return(GetServiceClient <T>(factory, client));
        }
        private void SetupManagementClients(MockContext context)
        {
            this.ResourceManagementClient = 
                    LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
            this.WebServicesManagementClient = 
                    context.GetServiceClient<AzureMLWebServicesManagementClient>(
                                                            TestEnvironmentFactory.GetTestEnvironment());
            this.StorageManagementClient = LegacyTest.TestBase.GetServiceClient<StorageManagementClient>(this.csmTestFactory);

            var subscriptionClient = LegacyTest.TestBase.GetServiceClient<SubscriptionClient>(this.csmTestFactory);
            var authManagementClient = LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
            var gallleryClient = LegacyTest.TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);

            var testEnvironment = this.csmTestFactory.GetTestEnvironment();
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[Microsoft.Azure.Test.TokenAudience.Management],
                testEnvironment.SubscriptionId);
            HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(
                    credentials);
            helper.SetupManagementClients(this.ResourceManagementClient, 
                subscriptionClient, 
                this.WebServicesManagementClient, 
                authManagementClient, 
                gallleryClient,
                this.StorageManagementClient);
        }
        public T GetServiceClient <T>(String scenario) where T : class
        {
            var factory         = (TestEnvironmentFactory) new CSMTestEnvironmentFactory();
            var testEnvironment = factory.GetTestEnvironment();

            ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler;
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[TokenAudience.Management],
                testEnvironment.SubscriptionId);
            var resourceNamespace = "";
            var resourceType      = "";
            var resourceName      = "";
            var resourceGroupName = "";

            switch (scenario)
            {
            case Constants.NewModel:
                resourceNamespace = "Microsoft.SiteRecovery";
                resourceType      = "SiteRecoveryVault";
                resourceName      = "ReleaseVault";
                resourceGroupName = "ReleaseResourceGroup";
                break;

            default:
                resourceNamespace = "Microsoft.SiteRecoveryBVTD2";
                resourceType      = "SiteRecoveryVault";
                resourceName      = asrVaultCreds.ResourceName;
                resourceGroupName = asrVaultCreds.ResourceGroupName;
                break;
            }
            ;

            if (typeof(T) == typeof(SiteRecoveryVaultManagementClient))
            {
                SiteRecoveryVaultManagementClient client;

                if (testEnvironment.UsesCustomUri())
                {
                    client = new SiteRecoveryVaultManagementClient(
                        resourceNamespace,
                        resourceType,
                        credentials,
                        testEnvironment.BaseUri);
                }
                else
                {
                    client = new SiteRecoveryVaultManagementClient(
                        resourceNamespace,
                        resourceType,
                        credentials);
                }
                return(GetRSMServiceClient <T>(factory, client));
            }
            else
            {
                SiteRecoveryManagementClient client;

                if (testEnvironment.UsesCustomUri())
                {
                    client = new SiteRecoveryManagementClient(
                        resourceName,
                        resourceGroupName,
                        resourceNamespace,
                        resourceType,
                        credentials,
                        testEnvironment.BaseUri);
                }

                else
                {
                    client = new SiteRecoveryManagementClient(
                        resourceName,
                        resourceGroupName,
                        resourceNamespace,
                        resourceType,
                        credentials);
                }

                return(GetSRMServiceClient <T>(factory, client));
            }
        }
        private void SetupManagementClients(MockContext context)
        {
            LegacyResourceManagementClient = GetLegacyResourceManagementClient();
            LegacySubscriptionClient = GetLegacySubscriptionClient();
            ResourceManagementClient = GetResourceManagementClient(context);
            SubscriptionClient = GetSubscriptionClient(context);
            GalleryClient = GetGalleryClient();
            AuthorizationManagementClient = GetAuthorizationManagementClient();
            GraphClient = GetGraphClient(context);
            InsightsClient = GetInsightsClient();
            this.FeatureClient = this.GetFeatureClient(context);
            var testEnvironment = this.csmTestFactory.GetTestEnvironment();
            var credentials = new SubscriptionCredentialsAdapter(
                testEnvironment.AuthorizationContext.TokenCredentials[Microsoft.Azure.Test.TokenAudience.Management],
                testEnvironment.SubscriptionId);
            HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(credentials);

            helper.SetupManagementClients(ResourceManagementClient,
                LegacyResourceManagementClient,
                LegacySubscriptionClient,
                SubscriptionClient,
                GalleryClient,
                AuthorizationManagementClient,
                GraphClient,
                InsightsClient,
                this.FeatureClient);
        }