Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Security/BackOfficeUserStoreTests.cs
Bjarke Berg 029a261476 Improve functionality for external member logins (#11855)
* Bugfix - Take ufprt from form data if the request has form content type, otherwise fallback to use the query

* External linking for members

* Changed migration to reuse old table

* removed unnecessary web.config files

* Cleanup

* Extracted class to own file

* Clean up

* Rollback changes to Umbraco.Web.UI.csproj

* Fixed migration for SqlCE

* Change notification handler to be on deleted

* Update src/Umbraco.Infrastructure/Security/MemberUserStore.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Fixed issue with errors not shown on member linking

* fixed issue with errors

* clean up

* Fix issue where external logins could not be used to upgrade Umbraco, because the externalLogin table was expected to look different. (Like after the migration)

* Fixed issue in Ignore legacy column now using result column.

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
2022-01-19 09:21:50 +01:00

67 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Security
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class BackOfficeUserStoreTests : UmbracoIntegrationTest
{
private IUserService UserService => GetRequiredService<IUserService>();
private IEntityService EntityService => GetRequiredService<IEntityService>();
private IExternalLoginWithKeyService ExternalLoginService => GetRequiredService<IExternalLoginWithKeyService>();
private IUmbracoMapper UmbracoMapper => GetRequiredService<IUmbracoMapper>();
private ILocalizedTextService TextService => GetRequiredService<ILocalizedTextService>();
private BackOfficeUserStore GetUserStore()
=> new BackOfficeUserStore(
ScopeProvider,
UserService,
EntityService,
ExternalLoginService,
Options.Create(GlobalSettings),
UmbracoMapper,
new BackOfficeErrorDescriber(TextService),
AppCaches);
[Test]
public async Task Can_Persist_Is_Approved()
{
var userStore = GetUserStore();
var user = new BackOfficeIdentityUser(GlobalSettings, 1, new List<IReadOnlyUserGroup>())
{
Name = "Test",
Email = "test@test.com",
UserName = "test@test.com"
};
IdentityResult createResult = await userStore.CreateAsync(user);
Assert.IsTrue(createResult.Succeeded);
Assert.IsFalse(user.IsApproved);
// update
user.IsApproved = true;
var saveResult = await userStore.UpdateAsync(user);
Assert.IsTrue(saveResult.Succeeded);
Assert.IsTrue(user.IsApproved);
// get get
user = await userStore.FindByIdAsync(user.Id);
Assert.IsTrue(user.IsApproved);
}
}
}