Inheritance: IAccessToken
 public MockTokenAuthenticationFactory(string userId, string accessToken)
 {
     Token = new MockAccessToken
     {
         UserId      = userId,
         LoginType   = LoginType.OrgId,
         AccessToken = accessToken
     };
 }
 public MockTokenAuthenticationFactory(string userId, string accessToken)
 {
     Token = new MockAccessToken
     {
         UserId = userId,
         LoginType = LoginType.OrgId,
         AccessToken = accessToken
     };
 }
コード例 #3
0
        public MockTokenAuthenticationFactory(string userId, string accessToken)
        {
            Token = new MockAccessToken
            {
                UserId = userId,
                LoginType = LoginType.OrgId,
                AccessToken = accessToken,
            };

            TokenProvider = ((account, environment, tenant) => Token);
        }
コード例 #4
0
        public MockTokenAuthenticationFactory(string userId, string accessToken)
        {
            Token = new MockAccessToken
            {
                UserId      = userId,
                LoginType   = LoginType.OrgId,
                AccessToken = accessToken,
            };

            TokenProvider = ((account, environment, tenant) => Token);
        }
コード例 #5
0
        public MockTokenAuthenticationFactory()
        {
            Token = new MockAccessToken
            {
                UserId = "Test",
                LoginType = LoginType.OrgId,
                AccessToken = "abc"
            };

            TokenProvider = (account, environment, tenant) => Token = new MockAccessToken
            {
                UserId = account.Id,
                LoginType = LoginType.OrgId,
                AccessToken = Token.AccessToken
            };
        }
コード例 #6
0
        public MockTokenAuthenticationFactory()
        {
            Token = new MockAccessToken
            {
                UserId      = "Test",
                LoginType   = LoginType.OrgId,
                AccessToken = "abc"
            };

            TokenProvider = (account, environment, tenant) => Token = new MockAccessToken
            {
                UserId      = account.Id,
                LoginType   = LoginType.OrgId,
                AccessToken = Token.AccessToken
            };
        }
コード例 #7
0
        public IAccessToken Authenticate(AzureAccount account, AzureEnvironment environment, string tenant, SecureString password, ShowDialog promptBehavior)
        {
            if (account.Id == null)
            {
                account.Id = "test";
            }

            var token = new MockAccessToken
            {
                UserId = account.Id,
                LoginType = LoginType.OrgId,
                AccessToken = "123"
            };

            return token;
        }
コード例 #8
0
        public IAccessToken Authenticate(AzureAccount account, AzureEnvironment environment, string tenant, SecureString password, ShowDialog promptBehavior)
        {
            if (account.Id == null)
            {
                account.Id = "test";
            }

            var token = new MockAccessToken
            {
                UserId      = account.Id,
                LoginType   = LoginType.OrgId,
                AccessToken = "123"
            };

            return(token);
        }
コード例 #9
0
        public IAccessToken Authenticate(AzureAccount account, AzureEnvironment environment, string tenant, SecureString password, ShowDialog promptBehavior,
                                         AzureEnvironment.Endpoint resourceId = AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId)
        {
            if (account.Id == null)
            {
                account.Id = "test";
            }

            var token = new MockAccessToken
            {
                UserId      = account.Id,
                LoginType   = LoginType.OrgId,
                AccessToken = "123"
            };

            return(token);
        }
        public IAccessToken Authenticate(AzureAccount account, AzureEnvironment environment, string tenant, SecureString password, ShowDialog promptBehavior,
            AzureEnvironment.Endpoint resourceId = AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId)
        {
            if (account.Id == null)
            {
                account.Id = "test";
            }

            var token = new MockAccessToken
            {
                UserId = account.Id,
                LoginType = LoginType.OrgId,
                AccessToken = "123"
            };

            return token;
        }
コード例 #11
0
        public void AddAzureAccountIsCaseInsensitive()
        {
            SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(),
                     new List<Microsoft.Azure.Subscriptions.Models.Subscription>(),
                     new[] { commonTenant, guestTenant }.ToList(),
                     (userAccount, environment, tenant) =>
                     {
                         var token = new MockAccessToken
                         {
                             UserId = tenant == commonTenant.TenantId ? userAccount.Id : "USERA",
                             AccessToken = "def",
                             LoginType = LoginType.OrgId
                         };
                         userAccount.Id = token.UserId;
                         return token;
                     });
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User },
                AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

            var userA = client.GetAccount("UserA");
            var secondUserA = client.GetAccount("USERA");
            Assert.NotNull(userA);
            Assert.NotNull(secondUserA);
            Assert.Equal(userA.Id, secondUserA.Id);
        }
コード例 #12
0
        public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
        {
            SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(),
                     new List<CSMSubscription>(),
                     new[] { commonTenant, guestTenant }.ToList(),
                    (userAccount, environment, tenant) =>
                    {
                        var token = new MockAccessToken
                        {
                            UserId = tenant == commonTenant.TenantId ? userAccount.Id : "UserB",
                            AccessToken = "def",
                            LoginType = LoginType.OrgId
                        };
                        userAccount.Id = token.UserId;
                        return token;
                    });
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User },
                AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

            Assert.Equal("UserA", account.Id);
            Assert.Equal(2, account.GetSubscriptions(client.Profile).Count);
            var subrdfe1 = account.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId));
            var userA = client.GetAccount("UserA");
            var userB = client.GetAccount("UserB");
            var subGuest = userB.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(guestRdfeSubscription.SubscriptionId));
            Assert.NotNull(userA);
            Assert.NotNull(userB);
            Assert.Contains<string>(rdfeSubscription1.SubscriptionId, userA.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase);
            Assert.Contains<string>(guestRdfeSubscription.SubscriptionId, userB.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase);
            Assert.NotNull(subrdfe1);
            Assert.NotNull(subGuest);
            Assert.Equal("UserA", subrdfe1.Account);
            Assert.Equal("UserB", subGuest.Account);
        }