コード例 #1
0
 static AzureSession()
 {
     ClientFactory = new ClientFactory();
     AuthenticationFactory = new AuthenticationFactory();
     CurrentContext = new AzureContext();
     CurrentContext.Environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
     AzureSession.OldProfileFile = "WindowsAzureProfile.xml";
     AzureSession.OldProfileFileBackup = "WindowsAzureProfile.xml.bak";
     AzureSession.ProfileDirectory = Path.Combine(
         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
         Resources.AzureDirectoryName); ;
     AzureSession.ProfileFile = "AzureProfile.json";
     AzureSession.TokenCacheFile = "TokenCache.dat";
 }
コード例 #2
0
        public void VerifySubscriptionTokenCacheRemove()
        {
            var authFactory = new AuthenticationFactory
            {
                TokenProvider = new MockAccessTokenProvider("testtoken", "testuser")
            };

            var subscriptionId = Guid.NewGuid();

            var credential = authFactory.GetSubscriptionCloudCredentials(new 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));

        }