2021-05-14 14:14:46.482 +05:30 [ERR] One or more errors occurred. (ValueFactory attempted to access the Value property of this instance.)
System.AggregateException: One or more errors occurred. (ValueFactory attempted to access the Value property of this instance.)
---> System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.get_PermissionDefinitions()
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.GetOrNull(String name)
at Volo.Abp.Authorization.AbpAuthorizationPolicyProvider.GetPolicyAsync(String policyName)
at Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable`1 authorizeData)
at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context)
at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at SCV.Litmus.Permissions.AccessPermissionDefinitionProvider.GetRoles() in D:\Litmus\Projects\core-platform\SCV.Litmus\aspnet-core\modules\litmus-core\src\SCV.Litmus.Application.Contracts\Permissions\AccessPermissionDefinitionProvider.cs:line 35
at SCV.Litmus.Permissions.AccessPermissionDefinitionProvider.Define(IPermissionDefinitionContext context) in D:\Litmus\Projects\core-platform\SCV.Litmus\aspnet-core\modules\litmus-core\src\SCV.Litmus.Application.Contracts\Permissions\AccessPermissionDefinitionProvider.cs:line 25
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.CreatePermissionGroupDefinitions()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.CreatePermissionDefinitions()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.get_PermissionDefinitions()
at Volo.Abp.Authorization.Permissions.PermissionDefinitionManager.GetPermissions()
at Volo.Abp.Authorization.AbpAuthorizationPolicyProvider.GetPoliciesNamesAsync()
at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAuthConfigAsync()
at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAsync()
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync()
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
I was trying to get dynamic value in PermissionDefinitionProvider below is the source code :
public class AccessPermissionDefinitionProvider : PermissionDefinitionProvider
{
private readonly ISomeAppService _someAppService;
public AccessPermissionDefinitionProvider(ISomeAppService someAppService)
{
_someAppService = someAppService;
}
public override void Define(IPermissionDefinitionContext context)
{
var myGroup = context.AddGroup("XYZAccessControl", L("Permission:XYZAccessControl"));
var somePermission = myGroup.AddPermission("XYZBased", L("Permission:XYZ"));
var fetchedData = GetData();
foreach (var item in fetchedData)
{
somePermission.AddChild(item);
}
}
private string[] GetData()
{
var data = _someAppService.GetSomeData().Result; //Just because await throws error here.
return data.select(x=> x.someValue).Distinct().ToArray();
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<XYZResource>(name);
}
}
I cannot run the project as the above error is shown.
REQUIREMENT :
GetData()
with hardcode value it work's as per my expectation but the count is not increased/decreased once I select the permission from the permission tree. Not able to find how it works.Please provide correct approach to achieve this, If I am doing it in a wrong way. I need to achieve this as this is the mandatory requirement for my project.
Hi,
I have a requirement where my user should be prompted or redirected to change password screen after every 90 days. How can this be achieved ?
There should be
FakeCurrentPrincipalAccessor.cs
file in yourTestBase
project, we use it to mock user.Also for data seeding, please check this documentation: https://docs.abp.io/en/abp/latest/Testing#the-seed-data
I got it GetPrincipal() method, but it has main admin. How do I use it in my case. I need to create more than 3-4 Unit test where each method have different login user with different case.
[Fact]
public async CheckForUser_1()
{
using(user_1 logged in)
{
//my code
}
}
[Fact]
public async CheckForUser_2()
{
using(user_2 logged in)
{
//my code
}
}
[Fact]
public async CheckForUser_3()
{
using(user_3 logged in)
{
//my code
}
}
[Fact]
public async CheckForUser_4()
{
using(user_4 logged in)
{
//my code
}
}
So where I have used using(user_1 logged in )
how can I use the method you mentioned ?
Hi @cotur,
I will try that. Please provide me solution for my second point as well.
User cases :
I have 2 users (user_1 and user_2), when I log with user_1 and create another user I check if my user is created by user_1 then I have some different action/code to be executed, and if my user_2 login I have to perform different action/code.This is just an example, but I hope u got my point.
Basic Requirement in Unit Test
I need to know how to I write test case where my user_1 is logged in and where my user_2 is logged in. And how do I seed IdentityUser i.e. AbpUsers table in test env with user_1 and user_2 details because as what I have learned there are more than one tables are involved as below:
etc etc How to I seed the above tables with my data.
Thanks
Hi @alper,
Thanks for the response.
I implemented your second approach, I customized code for the mentioned methods. It was just a POC for now, but in near future I have to develop full functionality. For now it's kinda configured via appsetting.json approach like if RoleA log's in he ill be able to see user's only under RoleA or which ever role the user is associated with. I want to make it more dynamic.
appsetting.json
"UserAccessControl": {
"FetchUsersByClaims": [
"SupplierAdmin"
],
"UserCreationWithClaims": [
"SupplierAdmin"
],
"FetchUsersByRoles": {
"admin": "AnchorAdmin",
"AnchorAdmin": "SellerAdmin",
"SupplierAdmin": "Supplier",
"SellerAdmin": "Seller"
},
"CannotEditUserWithRoles": {
"AnchorAdmin": "AnchorAdmin"
},
"CannotDeleteUserWithRoles": {
"AnchorAdmin": "AnchorAdmin,SupplierAdmin"
}
}
Here as u see my config file in UserAccessControl a section called FetchUsersByRoles, here I have mentioned which If my logged in use if of role admin
he can only get users of role AnchorAdmin
.Likewise other sections.
This is where my config file have control, I want to give this control to my Admin user. I want to generate a screen and allow Admin himself to have a control over this.And in future we add new roles to our system, we can have control over them as well.
If you can simply proved any better approach to manage this requirement will be very helpfull.
Hi,
I have do some code change in IdentityUserAppService, IdentityRoleAppService and ProfileAppService by overridding few methods. Now I want to do Unit Testing of the overridden methods, How do I do it ? Difficulty facing while writing Unit Testing :
_userAppService = GetRequiredService<IIdentityUserAppService>();
this means I am refering to IIdentityUserAppService
Methods not my overridden methods right ?In short In my code block I have to fake my login with a particular user as my method have this kind code : For example as below :
public virtual async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{
var user = new IdentityUser(
GuidGenerator.Create(),
input.UserName,
input.Email,
CurrentTenant.Id
);
if (logged in with user : xyz@abc.com) //then only I have to map extra properties other wise I dont have to map it
{
input.MapExtraPropertiesTo(user);
}
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
await UpdateUserByInput(user, input);
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
So in order to test this kind of code I have to create a session where my xyz@abc.com
user is logged in, then and then only I can check my code block right ?
Please help !!!
There are few other new requirements including the above requirements as below :
If these are not in abp features please let me know how to achieve this. Please try to answer all the above points and if possible please provide some details or sample code.
Thanks
REQUIREMENT #1 I want don't want to show options like Claims, Set Password for my logged user in User tab, similarly for Roles. I have control over Edit and Delete from permission options itself, but I want for other options as well. Please refer to the screenshot for more understanding
REQUIREMENT #2 I dont want to show Organization Units from Create/Edit User as shown below :
How do I do it ?
REQUIREMENT
I refered to this link https://docs.abp.io/en/abp/3.1/Modules/Organization-Units But not sure how to use it in this specific requirement. Even if there is any other feature of abp which will help me to achieve this functionality can help. Please provide few detail points or examples or docs where I can get complete understanding related to my requirement.
Thanks!!!
Hi @lalitChougule,
Please see the component replacement document. If you have any questions after reading the doc, please ask in detail.
Hi @Mehmet ,
I just want to change the css of the buttons and few colors here and there, for that too I need to replace whole component ?