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?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    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>();
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 23, 2026, 09:57
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.