|
|
|
@ -32,6 +32,7 @@ namespace Ombi.Schedule.Tests
|
|
|
|
|
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc", NormalizedUserName = "ABC", UserType = UserType.LocalUser},
|
|
|
|
|
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="sys", NormalizedUserName = "SYS", UserType = UserType.SystemUser},
|
|
|
|
|
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="plex", NormalizedUserName = "PLEX", UserType = UserType.PlexUser, ProviderUserId = "PLEX_ID", Email = "dupe"},
|
|
|
|
|
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="Admin", NormalizedUserName = "ADMIN", UserType = UserType.PlexUser, ProviderUserId = "ADMIN_ID", Email = "ADMIN@ADMIN.CO"},
|
|
|
|
|
};
|
|
|
|
|
private AutoMocker _mocker;
|
|
|
|
|
private PlexUserImporter _subject;
|
|
|
|
@ -368,9 +369,9 @@ namespace Ombi.Schedule.Tests
|
|
|
|
|
|
|
|
|
|
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public async Task Import_Cleanup_Missing_Plex_Admin()
|
|
|
|
|
public async Task Import_Cleanup_Missing_Plex_Admin_Dont_Delete()
|
|
|
|
|
{
|
|
|
|
|
_mocker.Setup<ISettingsService<UserManagementSettings>, Task<UserManagementSettings>>(x => x.GetSettingsAsync())
|
|
|
|
|
.ReturnsAsync(new UserManagementSettings
|
|
|
|
@ -387,22 +388,25 @@ namespace Ombi.Schedule.Tests
|
|
|
|
|
{
|
|
|
|
|
user = new User
|
|
|
|
|
{
|
|
|
|
|
email = "diff_email",
|
|
|
|
|
authentication_token = "user_token",
|
|
|
|
|
title = "user_title",
|
|
|
|
|
username = "diff_username",
|
|
|
|
|
id = "diff_user_id",
|
|
|
|
|
email = "ADMIN@ADMIN.CO",
|
|
|
|
|
authentication_token = "Admin",
|
|
|
|
|
title = "Admin",
|
|
|
|
|
username = "Admin",
|
|
|
|
|
id = "ADMIN_ID",
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_mocker.Setup<OmbiUserManager, Task<IdentityResult>>(x => x.CreateAsync(It.Is<OmbiUser>(x => x.UserName == "diff_username" && x.Email == "diff_email" && x.ProviderUserId == "diff_user_id" && x.UserType == UserType.PlexUser)))
|
|
|
|
|
.ReturnsAsync(IdentityResult.Success);
|
|
|
|
|
_mocker.Setup<OmbiUserManager, Task<IdentityResult>>(x => x.AddToRoleAsync(It.Is<OmbiUser>(x => x.UserName == "diff_username"), It.Is<string>(x => x == OmbiRoles.Admin)))
|
|
|
|
|
.ReturnsAsync(IdentityResult.Success);
|
|
|
|
|
|
|
|
|
|
_mocker.Setup<OmbiUserManager, Task<bool>>(x => x.IsInRoleAsync(It.Is<OmbiUser>(x => x.UserName == "Admin"), OmbiRoles.Admin)).ReturnsAsync(true);
|
|
|
|
|
|
|
|
|
|
await _subject.Execute(null);
|
|
|
|
|
|
|
|
|
|
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "PLEX_ID" && x.Email == "dupe" && x.UserName == "plex")), Times.Once);
|
|
|
|
|
_mocker.Verify<IUserDeletionEngine>(x => x.DeleteUser(It.Is<OmbiUser>(x => x.ProviderUserId == "ADMIN_ID" && x.Email == "ADMIN@ADMIN.CO" && x.UserName == "Admin")), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|