Example #1
0
 static AzureSession()
 {
     ClientFactory = new AzurePowerShellClientFactory();
     AuthenticationFactory = new AuthenticationFactory();
     CurrentContext = new AzureContext();
     CurrentContext.Environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
 }
 static AzureSession()
 {
     SubscriptionTokenCache = new Dictionary<Tuple<Guid, string>, IAccessToken>();
     ClientFactory = new AzurePowerShellClientFactory();
     AuthenticationFactory = new AuthenticationFactory();
     CurrentContext = new AzureContext();
     CurrentContext.Environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
 }
        public void VerifySubscriptionTokenCacheRemove()
        {
            var authFactory = new AuthenticationFactory
            {
                TokenProvider = new MockAccessTokenProvider("testtoken", "testuser")
            };

            var subscriptionId = Guid.NewGuid();

            var credential = authFactory.GetSubscriptionCloudCredentials(new Models.AzureContext
            {
                Environment = AzureEnvironment.PublicEnvironments["AzureCloud"],
                Account = new AzureAccount
                {
                    Id = "testuser",
                    Type = AzureAccount.AccountType.User,
                    Properties = new Dictionary<AzureAccount.Property, string>
                    {
                        { AzureAccount.Property.Tenants, "123" }
                    }
                },
                Subscription = new AzureSubscription
                {
                    Id = subscriptionId,
                    Properties = new Dictionary<AzureSubscription.Property, string>
                    {
                        { AzureSubscription.Property.Tenants, "123"}
                    }
                }
                
            });

            Assert.True(credential is AccessTokenCredential);
            Assert.Equal(subscriptionId, new Guid(((AccessTokenCredential)credential).SubscriptionId));

        }