Skip to main content

Action

The following Post Login action imports a custom module to fetch the user’s roles from an external service and sets them as a custom claim on the access token, denying access if the module call fails.
test-an-action-module.js
my-module.js

Unit Test

The unit tests load the action alongside the custom module and mock fetch to verify roles are set on success, and that access is denied when the external service returns an error status or the request fails with a network error.
test-an-action-module.spec.js
package.json
test-an-action-module.spec.js
package.json
.mocharc.json
test-an-action-module.spec.js
package.json