Open Closed

Ignoring auth server in integration test #6374


User avatar
0
Teknosol created
  • ABP Framework version: v7.1.1
  • UI Type: Angular
  • Database System: EF Core PostgreSQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hello, I want to run the integration test by ignoring the authorize feature. I have [Autorize] feature in every method in Application service for authorize operation.

HttpApiHostModule ConfigureServices also works when I add context.Services.AddAlwaysAllowAuthorization(); method depending on the integration test environment, but I use typeof(AbpAspNetCoreMvcClientModule) in DepensOns, I get the permissions from the administration service. Here I get the error in the screenshot and the method returns 500.

How can I disable the AbpAspNetCoreMvcClientModule property in the integration test?


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can replace the IRemoteServiceHttpClientAuthenticator in integration test.

    For example:

    public class IntegrationTestRemoteServiceHttpClientAuthenticator : IRemoteServiceHttpClientAuthenticator
    {
        public virtual Task Authenticate(RemoteServiceHttpClientAuthenticateContext context)
        {
            return Task.CompleteTask;
        }
    }
    
    if(isTest)
    {
        ....
        context.Services.RemoveAll(x => x.ServiceType == typeof(IRemoteServiceHttpClientAuthenticator));
        context.Services.AddTransient<IRemoteServiceHttpClientAuthenticator, IntegrationTestRemoteServiceHttpClientAuthenticator>();
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11