Skip to content

Replacing Regression Test User Creation with CreateUserPassKyc()

Initially, the regression tests used internal testing APIs to create new users and pass KYC (Know Your Customer). We had decided to replace those methods with the CreateUserPassKyc() method from the KYC regression test contract UserPassKycActions. This change will simplify the maintenance and debugging of all regression tests.

Introduction

By default, the CreateUserPassKyc() method creates user type SsnQrVerifiedAdvisorUser, which submits customer details and passes KYC without further documentation. However, other types of user creation are also available:

  • NoSsnOnlineUser
  • SsnOnlineUser
  • NoSsnQrVerifiedAdvisorUser
  • NoSsnAdvisorAssistedUser
  • SsnAdvisorAssistedUser

Steps to Replace Old User Creation

To replace the user creation in your tests, follow these steps:

  1. Add the KYC Regression Test Contract NuGet Package:

    • Ensure the KYC regression test contract is included in your project.
  2. Introduce the Necessary APIs and Test States:

    • Import the KYC, SalesTool, and User APIs and include the test states in BaseRegressionTest and TestState.
  3. Replace Current User Creation:

    • Replace the existing user creation code with:
      await this.CreateUserPassKyc();
      
  4. Ensure User ID in Tests:

    • Make sure the userId in your tests is retrieved using:
      State.UserId.GetValueOrDefault();
      
  5. Rerun All Tests:

    • Rerun all the tests to ensure they pass as usual.

Reference Implementation

For a reference on how to implement these changes, please refer to this PR in the pspfunding area: PR #15244.

Important Note

Ensure you use the GetInternalTestApiClient<TService>() extension method for services that require authorization using Internal Testing API Keys. Failure to do so will result in an UnauthorizedException with the message "Missing Authorization Header".