Skip to content

Commit

Permalink
Resolved #381: Upgrade to Abp v2.1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jun 8, 2017
1 parent 1ad0c64 commit be84830
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 41 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageIconUrl>http://www.aspnetboilerplate.com/images/abp_nupkg.png</PackageIconUrl>
<PackageProjectUrl>http://www.aspnetboilerplate.com/</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Abp.Zero.Common/Abp.Zero.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp" Version="2.1.0" />
<PackageReference Include="Abp" Version="2.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abp.EntityFramework" Version="2.1.0" />
<PackageReference Include="Abp.EntityFramework" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.EntityFrameworkCore" Version="2.1.0" />
<PackageReference Include="Abp.EntityFrameworkCore" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
Expand Down
4 changes: 2 additions & 2 deletions src/Abp.Zero.NHibernate/Abp.Zero.NHibernate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.NHibernate" Version="2.1.0" />
<PackageReference Include="Abp.FluentMigrator" Version="2.1.0" />
<PackageReference Include="Abp.NHibernate" Version="2.1.1" />
<PackageReference Include="Abp.FluentMigrator" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.EntityFrameworkCore" Version="2.1.0" />
<PackageReference Include="Abp.EntityFrameworkCore" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="1.0.1" />
<PackageReference Include="Abp.AutoMapper" Version="2.1.0" />
<PackageReference Include="Abp.AutoMapper" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
Expand Down
6 changes: 3 additions & 3 deletions src/Abp.ZeroCore/Authorization/Roles/AbpRoleStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public virtual async Task<IList<Claim>> GetClaimsAsync([NotNull] TRole role, Can

Check.NotNull(role, nameof(role));

await _roleRepository.EnsureLoadedAsync(role, u => u.Claims, cancellationToken);
await _roleRepository.EnsureCollectionLoadedAsync(role, u => u.Claims, cancellationToken);

return role.Claims.Select(c => new Claim(c.ClaimType, c.ClaimValue)).ToList();
}
Expand All @@ -299,7 +299,7 @@ public async Task AddClaimAsync([NotNull] TRole role, [NotNull] Claim claim, Can
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));

await _roleRepository.EnsureLoadedAsync(role, u => u.Claims, cancellationToken);
await _roleRepository.EnsureCollectionLoadedAsync(role, u => u.Claims, cancellationToken);

role.Claims.Add(new RoleClaim(role, claim));
}
Expand All @@ -316,7 +316,7 @@ public async Task RemoveClaimAsync([NotNull] TRole role, [NotNull] Claim claim,
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));

await _roleRepository.EnsureLoadedAsync(role, u => u.Claims, cancellationToken);
await _roleRepository.EnsureCollectionLoadedAsync(role, u => u.Claims, cancellationToken);

role.Claims.RemoveAll(c => c.ClaimValue == claim.Value && c.ClaimType == claim.Type);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Abp.ZeroCore/Authorization/Users/AbpUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public virtual async Task<IdentityResult> CheckDuplicateUsernameOrEmailAddressAs

public virtual async Task<IdentityResult> SetRoles(TUser user, string[] roleNames)
{
await AbpStore.UserRepository.EnsureLoadedAsync(user, u => u.Roles);
await AbpStore.UserRepository.EnsureCollectionLoadedAsync(user, u => u.Roles);

//Remove from removed roles
foreach (var userRole in user.Roles.ToList())
Expand Down
22 changes: 11 additions & 11 deletions src/Abp.ZeroCore/Authorization/Users/AbpUserStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public virtual async Task<bool> IsInRoleAsync([NotNull] TUser user, [NotNull] st
return false;
}

await UserRepository.EnsureLoadedAsync(user, u => u.Roles, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);

return user.Roles.Any(r => r.RoleId == role.Id);
}
Expand All @@ -479,7 +479,7 @@ public virtual async Task<IList<Claim>> GetClaimsAsync([NotNull] TUser user, Can

Check.NotNull(user, nameof(user));

await UserRepository.EnsureLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);

return user.Claims.Select(c => new Claim(c.ClaimType, c.ClaimValue)).ToList();
}
Expand All @@ -498,7 +498,7 @@ public virtual async Task AddClaimsAsync([NotNull] TUser user, [NotNull] IEnumer
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));

await UserRepository.EnsureLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);

foreach (var claim in claims)
{
Expand All @@ -522,7 +522,7 @@ public virtual async Task ReplaceClaimAsync([NotNull] TUser user, [NotNull] Clai
Check.NotNull(claim, nameof(claim));
Check.NotNull(newClaim, nameof(newClaim));

await UserRepository.EnsureLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);

var userClaims = user.Claims.Where(uc => uc.ClaimValue == claim.Value && uc.ClaimType == claim.Type);
foreach (var userClaim in userClaims)
Expand All @@ -546,7 +546,7 @@ public virtual async Task RemoveClaimsAsync([NotNull] TUser user, [NotNull] IEnu
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));

await UserRepository.EnsureLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);

foreach (var claim in claims)
{
Expand All @@ -568,7 +568,7 @@ public virtual async Task AddLoginAsync([NotNull] TUser user, [NotNull] UserLogi
Check.NotNull(user, nameof(user));
Check.NotNull(login, nameof(login));

await UserRepository.EnsureLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);

user.Logins.Add(new UserLogin(user.TenantId, user.Id, login.LoginProvider, login.ProviderKey));
}
Expand All @@ -589,7 +589,7 @@ public virtual async Task RemoveLoginAsync([NotNull] TUser user, [NotNull] strin
Check.NotNull(loginProvider, nameof(loginProvider));
Check.NotNull(providerKey, nameof(providerKey));

await UserRepository.EnsureLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);

user.Logins.RemoveAll(userLogin => userLogin.LoginProvider == loginProvider && userLogin.ProviderKey == providerKey);
}
Expand All @@ -608,7 +608,7 @@ public virtual async Task<IList<UserLoginInfo>> GetLoginsAsync([NotNull] TUser u

Check.NotNull(user, nameof(user));

await UserRepository.EnsureLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);

return user.Logins.Select(l => new UserLoginInfo(l.LoginProvider, l.ProviderKey, l.LoginProvider)).ToList();
}
Expand Down Expand Up @@ -1100,7 +1100,7 @@ public virtual async Task SetTokenAsync([NotNull] TUser user, string loginProvid

Check.NotNull(user, nameof(user));

await UserRepository.EnsureLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);

var token = user.Tokens.FirstOrDefault(t => t.LoginProvider == loginProvider && t.Name == name);
if (token == null)
Expand All @@ -1127,7 +1127,7 @@ public async Task RemoveTokenAsync(TUser user, string loginProvider, string name

Check.NotNull(user, nameof(user));

await UserRepository.EnsureLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);

user.Tokens.RemoveAll(t => t.LoginProvider == loginProvider && t.Name == name);
}
Expand All @@ -1146,7 +1146,7 @@ public async Task<string> GetTokenAsync(TUser user, string loginProvider, string

Check.NotNull(user, nameof(user));

await UserRepository.EnsureLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);

return user.Tokens.FirstOrDefault(t => t.LoginProvider == loginProvider && t.Name == name)?.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abp.Castle.Log4Net" Version="2.1.0" />
<PackageReference Include="Abp.Castle.Log4Net" Version="2.1.1" />
<PackageReference Include="Castle.LoggingFacility.MsLogging" Version="2.0.0" />
<PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="2.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abp.TestBase" Version="2.1.0" />
<PackageReference Include="Abp.TestBase" Version="2.1.1" />
<PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.TestBase" Version="2.1.0" />
<PackageReference Include="Abp.TestBase" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.TestBase" Version="2.1.0" />
<PackageReference Include="Abp.TestBase" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.TestBase" Version="2.1.0" />
<PackageReference Include="Abp.TestBase" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="2.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
Expand Down
2 changes: 1 addition & 1 deletion test/Abp.ZeroCore.SampleApp/Abp.ZeroCore.SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abp.AutoMapper" Version="2.1.0" />
<PackageReference Include="Abp.AutoMapper" Version="2.1.1" />
<PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
Expand Down
5 changes: 3 additions & 2 deletions test/Abp.ZeroCore.Tests/Abp.ZeroCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.2" />
<PackageReference Include="Abp.TestBase" Version="2.1.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.2" />
<PackageReference Include="Abp.TestBase" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
Expand Down
1 change: 1 addition & 0 deletions test/Abp.ZeroCore.Tests/Zero/AbpZeroTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Abp.Events.Bus.Entities;
using Abp.Runtime.Session;
using Abp.TestBase;
using Abp.Zero.TestData;
using Abp.ZeroCore.SampleApp.Core;
using Abp.ZeroCore.SampleApp.EntityFramework;
using Microsoft.EntityFrameworkCore;
Expand Down
34 changes: 34 additions & 0 deletions test/Abp.ZeroCore.Tests/Zero/Roles/RoleStore_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Threading.Tasks;
using Abp.Domain.Uow;
using Abp.ZeroCore.SampleApp.Core;
using Shouldly;
using Xunit;

namespace Abp.Zero.Roles
{
public class RoleStore_Tests : AbpZeroTestBase
{
private readonly RoleStore _roleStore;

public RoleStore_Tests()
{
_roleStore = Resolve<RoleStore>();
}

[Fact]
public async Task Should_Get_Role_Claims()
{
using (var uow = Resolve<IUnitOfWorkManager>().Begin())
{
var role = await _roleStore.FindByNameAsync("ADMIN");
role.ShouldNotBeNull();

var claims = await _roleStore.GetClaimsAsync(role);

claims.ShouldNotBeNull();

await uow.CompleteAsync();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Abp.ZeroCore.SampleApp.EntityFramework;

namespace Abp.Zero
namespace Abp.Zero.TestData
{
public class TestDataBuilder
{
Expand All @@ -15,6 +15,7 @@ public TestDataBuilder(SampleAppDbContext context, int tenantId)

public void Create()
{
new TestRolesBuilder(_context, _tenantId).Create();
new TestOrganizationUnitsBuilder(_context, _tenantId).Create();

_context.SaveChanges();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Abp.Organizations;
using Abp.ZeroCore.SampleApp.EntityFramework;

namespace Abp.Zero
namespace Abp.Zero.TestData
{
/* Creates OU tree for default tenant as shown below:
*
Expand Down
35 changes: 35 additions & 0 deletions test/Abp.ZeroCore.Tests/Zero/TestData/TestRolesBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Security.Claims;
using Abp.Authorization.Roles;
using Abp.ZeroCore.SampleApp.Core;
using Abp.ZeroCore.SampleApp.EntityFramework;

namespace Abp.Zero.TestData
{
public class TestRolesBuilder
{
private readonly SampleAppDbContext _context;
private readonly int _tenantId;

public TestRolesBuilder(SampleAppDbContext context, int tenantId)
{
_context = context;
_tenantId = tenantId;
}

public void Create()
{
var role = new Role(_tenantId, "ADMIN", "ADMIN")
{
Claims = new List<RoleClaim>()
};

role.Claims.Add(new RoleClaim(role, new Claim("MyClaim1", "MyClaim1Value")));
role.Claims.Add(new RoleClaim(role, new Claim("MyClaim2", "MyClaim2Value")));

_context.Roles.Add(role);

_context.SaveChanges();
}
}
}
Loading

0 comments on commit be84830

Please sign in to comment.