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:
NoSsnOnlineUserSsnOnlineUserNoSsnQrVerifiedAdvisorUserNoSsnAdvisorAssistedUserSsnAdvisorAssistedUser
Steps to Replace Old User Creation¶
To replace the user creation in your tests, follow these steps:
-
Add the KYC Regression Test Contract NuGet Package:
- Ensure the KYC regression test contract is included in your project.
-
Introduce the Necessary APIs and Test States:
- Import the
KYC,SalesTool, andUserAPIs and include the test states inBaseRegressionTestandTestState.
- Import the
-
Replace Current User Creation:
- Replace the existing user creation code with:
await this.CreateUserPassKyc();
- Replace the existing user creation code with:
-
Ensure User ID in Tests:
- Make sure the
userIdin your tests is retrieved using:
State.UserId.GetValueOrDefault();
- Make sure the
-
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".