Activities of "lalitChougule"

  • ABP Framework version: v3.0.4
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Hi,

I was trying to mock IdentityUserManager

Error :

Can not instantiate proxy of class: Volo.Abp.Identity.IdentityUserManager.
Could not find a parameterless constructor.

StackTrace :

   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.CreateProxyUsingCastleProxyGenerator(Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments, IInterceptor[] interceptors, ProxyGenerationOptions proxyGenerationOptions)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Proxies.CastleDynamicProxy.CastleDynamicProxyFactory.GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments, Boolean callBaseByDefault)
   at NSubstitute.Core.SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For(Type[] typesToProxy, Object[] constructorArguments)
   at NSubstitute.Substitute.For[T](Object[] constructorArguments)
   at SCV.Litmus.LitmusIdentity.LitmusUserInfoApplicationTests.AfterAddApplication(IServiceCollection services) in D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\test\SCV.Litmus.Application.Tests\LitmusIdentity\LitmusUserInfoApplicationTests.cs:line 26
   at Volo.Abp.Testing.AbpIntegratedTest`1..ctor()
   at SCV.Litmus.LitmusTestBase`1..ctor()
   at SCV.Litmus.LitmusApplicationTestBase..ctor()
   at SCV.Litmus.LitmusIdentity.LitmusUserInfoApplicationTests..ctor() in D:\Litmus\Projects\ap-ar-dashboard\SCV.Litmus\aspnet-core\modules\litmus-core\test\SCV.Litmus.Application.Tests\LitmusIdentity\LitmusUserInfoApplicationTests.cs:line 19

My Code :

public class LitmusUserInfoApplicationTests : LitmusApplicationTestBase
    {
        private readonly ILitmusUserInfoAppService _litmusUserInfoAppService;

        private IdentityUserManager _identityUserManager;

        public LitmusUserInfoApplicationTests()
        {
            _litmusUserInfoAppService = GetRequiredService<ILitmusUserInfoAppService>();
        }

        protected override void AfterAddApplication(IServiceCollection services)
        {
            _identityUserManager = Substitute.For<IdentityUserManager>();
            services.AddSingleton(_identityUserManager);
        }

        [Fact]
        public async Task GetSellerQuestionnaireForMakerCheckAsync()
        {
            _identityUserManager.FindByIdAsync("39faa1bb-6509-6a7d-b17f-0deee2cf47db")
                .Returns(Task.FromResult(JsonConvert.DeserializeObject<IdentityUser>(@"{
                      'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                      'UserName': 'Seller.Admin',
                      'NormalizedUserName': 'SELLER.ADMIN',
                      'Name': 'Seller',
                      'Surname': 'Admin',
                      'Email': 'seller.admin@ness.com',
                      'NormalizedEmail': 'LALIT.CHOUGULE@NESS.COM',
                      'EmailConfirmed': false,
                      'PasswordHash': 'AQAAAAEAACcQAAAAEOK/7B0qge7madNnCVW5zGiVxa7sgIYc7XIKR/wG+fuDFn2g28hDGmd/i34RV/Rc8Q==',
                      'SecurityStamp': 'CUICLIBP3N5Z7NV52SKWF2MHBRIGDEPZ',
                      'PhoneNumber': null,
                      'PhoneNumberConfirmed': false,
                      'TwoFactorEnabled': true,
                      'LockoutEnd': null,
                      'LockoutEnabled': true,
                      'AccessFailedCount': 0,
                      'Roles': [
                        {
                          'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                          'UserId': '39fd4aa9-8553-35c0-4312-0d7b5f01b810',
                          'RoleId': '39fc43a0-e722-2bc3-7d24-9cc6992ccd3a'
                        }
                      ],
                      'Claims': [],
                      'Logins': [],
                      'Tokens': [],
                      'OrganizationUnits': [],
                      'IsDeleted': false,
                      'DeleterId': null,
                      'DeletionTime': null,
                      'LastModificationTime': '2021-06-23T16:22:02.440744',
                      'LastModifierId': null,
                      'CreationTime': '2021-06-23T16:18:53.936857',
                      'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                      'ExtraProperties': {
                        'PasswordSetDate': '2021-09-21T10:50:14.4543311Z',
                        'HaveOptedMakerChecker': true
                      },
                      'ConcurrencyStamp': '5224e087605a4f498a9684556b5506dc',
                      'Id': '39fd4aa9-8553-35c0-4312-0d7b5f01b810'
                    }")));

            var mock_sellerRequesterUsers = @"[
              {
                'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                'UserName': 'Seller.Requester',
                'NormalizedUserName': 'SELLER.REQUESTER',
                'Name': 'Seller',
                'Surname': 'Requester',
                'Email': 'Kaustubh.Kale@ness.com',
                'NormalizedEmail': 'KAUSTUBH.KALE@NESS.COM',
                'EmailConfirmed': false,
                'PasswordHash': 'AQAAAAEAACcQAAAAEFCPsMT+tOATxKorhUkndGa1/k3SOjnx3+emm2sWafeYlVvcnDFnSeP0k5uXlgYJwA==',
                'SecurityStamp': 'NUUY6ROI2NTZ7UBM2FBDHZBKP5UPXS7B',
                'PhoneNumber': null,
                'PhoneNumberConfirmed': false,
                'TwoFactorEnabled': true,
                'LockoutEnd': null,
                'LockoutEnabled': true,
                'AccessFailedCount': 0,
                'Roles': null,
                'Claims': null,
                'Logins': null,
                'Tokens': null,
                'OrganizationUnits': null,
                'IsDeleted': false,
                'DeleterId': null,
                'DeletionTime': null,
                'LastModificationTime': '2021-06-23T16:30:40.180889',
                'LastModifierId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'CreationTime': '2021-06-23T16:30:29.23093',
                'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'ExtraProperties': {
                  'PasswordSetDate': '2021-09-21T11:00:28.4022237Z',
                  'HaveOptedMakerChecker': false
                },
                'ConcurrencyStamp': '0b7b68128a81401fbc6fa3f91e36b3f3',
                'Id': '39fd4ab4-2271-7518-4964-a131224f8919'
              }
            ]";

            _identityUserManager.GetUsersInRoleAsync("SellerRequester")
                .Returns(Task.FromResult(JsonConvert.DeserializeObject<IList<IdentityUser>>(mock_sellerRequesterUsers)));

            var mock_sellerApproverUsers = @"[
              {
                'TenantId': 'd1be844b-d3a2-031a-f036-39f5d4380239',
                'UserName': 'Seller.Approver',
                'NormalizedUserName': 'SELLER.APPROVER',
                'Name': 'Seller',
                'Surname': 'Approver',
                'Email': 'Yaduraj.Shakti@ness.com',
                'NormalizedEmail': 'YADURAJ.SHAKTI@NESS.COM',
                'EmailConfirmed': false,
                'PasswordHash': 'AQAAAAEAACcQAAAAEJkl+HrzdX1HQPWcLTvhmgtiibs2F4pX4avyk4UxK6iHFSCa5Ca4/VyNxVgyY47xIA==',
                'SecurityStamp': 'TUOGMEIA2RJSFMXCKARFLZO2XSK2QWCA',
                'PhoneNumber': null,
                'PhoneNumberConfirmed': false,
                'TwoFactorEnabled': true,
                'LockoutEnd': null,
                'LockoutEnabled': true,
                'AccessFailedCount': 0,
                'Roles': null,
                'Claims': null,
                'Logins': null,
                'Tokens': null,
                'OrganizationUnits': null,
                'IsDeleted': false,
                'DeleterId': null,
                'DeletionTime': null,
                'LastModificationTime': '2021-06-23T16:29:45.804466',
                'LastModifierId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'CreationTime': '2021-06-23T16:29:33.925747',
                'CreatorId': '1c26f3a7-fa8f-dbaf-406b-39f5d443409f',
                'ExtraProperties': {
                  'PasswordSetDate': '2021-09-21T10:59:32.8141291Z',
                  'HaveOptedMakerChecker': false
                },
                'ConcurrencyStamp': '7d9f64db3fa74b2b827940360d2b5185',
                'Id': '39fd4ab3-494d-9f88-56ac-e9b402130a4d'
              }
            ]";

            _identityUserManager.GetUsersInRoleAsync("SellerApprover")
               .Returns(Task.FromResult(JsonConvert.DeserializeObject<IList<IdentityUser>>(mock_sellerApproverUsers)));

            var result = await _litmusUserInfoAppService.GetSellerQuestionnaireInfoAsync();
        }
    }

How do I mock IdentityUserManager ?

Can we have a session ? May be you can figure it out if you have a look ? It's bit urgent as my app is about to go live in few days.

hi @lalitChougule

How can I reproduce your problem?

I am not sure how its happening in my project. May be we can connect and you can have a look.

hi Please share these info.

  • ABP Framework version: vX.X.X
  • UI type: Angular / MVC / Blazor
  • DB provider: EF Core / MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

ABP Framework version: v3.0.4 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): no / yes Exception message and stack trace: N.A Steps to reproduce the issue: N.A

Hi,

I am not able to see security-logs on UI. And even AuditLogs are not visible even after giving permission for same.

Please guide me !!!

Hi @muhammedaltug,

Thanks to answer my queries. I have few more requirement, and few previously unanswered questions and its related to same topic so posting it here itself.

  1. To hide password and username field from user creation form, Can it be done only by replacing the whole component or there is any other way around ? I don't want to replace whole component just for this small change.
  2. Just like what we do on backend i.e. override only particular method of service , can we do same for user.component ? i.e. in angular component ?
  3. Requirement : Once my user is created I want to redirect the user to my custom page.

Can all the above requirements can be done without replacing user.component ? If yes please guide me.

Thanks in advance !!!

Hi,

Why you can't access IIdentityRoleRepository? Can you explain the structure of your project

I think we are trying to access it in Application.Contracts thatz why its not accessible.

My Project structure

Gateway
	MainProject.HttpApi.Host
Microservices
	ProjectA.HttpApi.Host
	ProjectB.HttpApi.Host
	ProjectC.HttpApi.Host -- IdentityServer
	ProjectD.HttpApi.Host
Module
	ProjectA
		scr
			ProjectA.Application
			ProjectA.Application.Contracts
			ProjectA.Domain
			ProjectA.Domain.Shared
			ProjectA.EntityFrameworkCore
			ProjectA.HttpApi
			ProjectA.HttpApiClient
		test
			ProjectA.Application.Tests
			ProjectA.Domain.Tests
			ProjectA.EntityFrameworkCore.Tests
			ProjectA.HttpApiClient.ConsoleTestApp
			ProjectA.TestBase
	ProjectB
		src
			ProjectB.Application
			ProjectB.Application.Contracts
			ProjectB.Domain
			ProjectB.Domain.Shared
			ProjectB.EntityFrameworkCore
			ProjectB.HttpApi
			ProjectB.HttpApiClient
		test
			ProjectB.Application.Tests
			ProjectB.Domain.Tests
			ProjectB.EntityFrameworkCore.Tests
			ProjectB.HttpApiClient.ConsoleTestApp
			ProjectB.TestBase
	ProjectC
		src
			ProjectC.Application
			ProjectC.Application.Contracts
			ProjectC.Domain
			ProjectC.Domain.Shared
			ProjectC.EntityFrameworkCore
			ProjectC.HttpApi
			ProjectC.HttpApiClient
		test
			ProjectC.Application.Tests
			ProjectC.Domain.Tests
			ProjectC.EntityFrameworkCore.Tests
			ProjectC.HttpApiClient.ConsoleTestApp
			ProjectC.TestBase
	ProjectD
		src
			ProjectD.Application
			ProjectD.Application.Contracts
			ProjectD.Domain
			ProjectD.Domain.Shared
			ProjectD.EntityFrameworkCore
			ProjectD.HttpApi
			ProjectD.HttpApiClient
		test
			ProjectD.Application.Tests
			ProjectD.Domain.Tests
			ProjectD.EntityFrameworkCore.Tests
			ProjectD.HttpApiClient.ConsoleTestApp
			ProjectD.TestBase

The code which I am trying to do is in Module of Gateway project.

HI

It depends on where your dynamic permissions are stored. If your application is a monolithic application, you can consider try to inject the repository.

In short, don't call application services, because this will cause an infinite loop.

Ok I got your point. What are the other ways of access roles ? I dont want to access permissions. I want to access all roles.

I am not able to access IIdentityRoleRepository as well as IdentityRoleManager in the above code block.

hi

The application service will try to get all permissions when you call the its method, it will be an infinite loop.

So do not call application service in the Define method.

You can get dynamic permissions through other ways. Async methods are preferred.

Please provide sample code, What are the other ways and what do u mean by Sync methods are preferred ?

  • ABP Framework version: v3.0.4
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no / yes
  • Exception message and stack trace: Unable to cast object of type 'Microsoft.Data.Sqlite.SqliteConnection' to type 'Npgsql.NpgsqlConnection
  • Steps to reproduce the issue: As details below

Hi,

We have created custom repositories for our entities as per https://docs.abp.io/en/abp/latest/Repositories#custom-repositories. In one of our repository we one method which executes postgreSQL function as below :

public async Task<bool> UpdateInvoiceStatusInBulk(InvoiceStatusUpdateBulkDto updateInvoiceList, CancellationToken cancellationToken = default)
        {
            var result = false;
            var data = JsonConvert.SerializeObject(updateInvoiceList);
            await EnsureConnectionOpenAsync(cancellationToken);

            using (var command = CreateCommand("SELECT \"UpdateInvoiceStatus\"(@data)", CommandType.StoredProcedure, new NpgsqlParameter("@data", data)))
            {
               result = (bool)command.ExecuteScalarAsync(cancellationToken).Result;
            }
            
            return result;
        }

Normally this method works fine. But while unit testing for the method which call UpdateInvoiceStatusInBulk method internally gives error i.e. Unable to cast object of type 'Microsoft.Data.Sqlite.SqliteConnection' to type 'Npgsql.NpgsqlConnection This is just because while unit testing we use sqlite db which is provided by framework. I am not able to do testing of the method which internally calls the above method. How do I resolve this issue ?

Showing 51 to 60 of 124 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 14, 2025, 14:54