Ejemplo n.º 1
0
        public async Task Should_Link_User_To_Different_Tenant_User()
        {
            //Arrange
            LoginAsHostAdmin();
            var testTenantId = await CreateTestTenantAndTestUser();

            //Act
            LoginAsDefaultTenantAdmin();
            await _userLinkAppService.LinkToUser(new LinkToUserInput
            {
                TenancyName            = "Test",
                UsernameOrEmailAddress = "test",
                Password = "******"
            });

            //Assert
            var defaultTenantAdmin = await UsingDbContextAsync(context => context.Users.FirstOrDefaultAsync(u => u.TenantId == AbpSession.TenantId && u.Id == AbpSession.UserId));

            var defaultTenantAccount = await _userLinkManager.GetUserAccountAsync(defaultTenantAdmin.ToUserIdentifier());

            var testUser = await UsingDbContextAsync(testTenantId, context => context.Users.FirstOrDefaultAsync(u => u.UserName == "test"));

            var testUserAccount = await _userLinkManager.GetUserAccountAsync(testUser.ToUserIdentifier());

            defaultTenantAccount.UserLinkId.ShouldBe(testUserAccount.UserLinkId);
            defaultTenantAccount.UserLinkId.ShouldBe(defaultTenantAccount.Id);
        }
Ejemplo n.º 2
0
        public async Task Should_Link_User_To_Different_Tenant_User()
        {
            //Arrange
            LoginAsDefaultTenantAdmin();
            await CreateTestTenantAndTestUser();

            //Act
            await _userLinkAppService.LinkToUser(new LinkToUserInput
            {
                TenancyName            = "Test",
                UsernameOrEmailAddress = "test",
                Password = "******"
            });

            //Assert
            await UsingDbContextAsync(async context =>
            {
                var linkedUser  = await context.Users.FirstOrDefaultAsync(u => u.UserName == "test");
                var currentUser = await context.Users.FirstOrDefaultAsync(u => u.Id == AbpSession.UserId);

                currentUser.UserLinkId.HasValue.ShouldBe(true);
                currentUser.UserLinkId.Value.ShouldBe(currentUser.Id);

                linkedUser.UserLinkId.HasValue.ShouldBe(true);
                linkedUser.UserLinkId.Value.ShouldBe(currentUser.Id);
            });
        }
Ejemplo n.º 3
0
        public async Task LinkToUser()
        {
            CreateTestUsers();

            var user = await GetUserByUserNameAsync("jnash");

            AbpSession.UserId = user.Id;

            await _userLinkAppService.LinkToUser(
                new LinkToUserInput
            {
                Password               = "******",
                TenancyName            = "Default",
                UsernameOrEmailAddress = "*****@*****.**"
            }
                );

            var linkedUsers = await _userLinkAppService.GetLinkedUsers(
                new GetLinkedUsersInput
            {
                MaxResultCount = 10,
                SkipCount      = 0
            }
                );

            linkedUsers.Items.Count.ShouldBe(1);
        }