How to test endpoints and microservices with python

This sample script authenticates with the LMS and then uses the identity returned to interact with a microservice. This is similar to how a real user would interact with a microservice through an MFE. You can copy it, pull out the PIE service, and put in your own calls.

The useful things this does that you will want to steal for your own test script:

  • gets CSRF tokens so you can actually POST to various endpoints

  • hands the JWT identity cookies over to the microservice call

  • sets the magic header without which those identity cookies will not be picked up by the microservice

  • sets a few other headers needed by the endpoints

Services calling each other do not use this login method, so you will need to rebuild the script using a client ID and secret, similar to this OAuth Client script in postman.