Change Username
Generally speaking, login credentials in test environments may not match production logins. This example shows you how to change a production credential (such as a client_id or username) into a test environment value.
Keep in mind that this is typically not necessary if you are using the Speedscale Responders. If the Responder is mocking the connection between the Service Under Test (SUT) and the authentication service, it will provide the same list of valid users as the production system because that's what it recorded in production. However, this example is provided in case you are unable to record the interactions between the SUT and the authentication service.
Objective
Change a credential recorded in production to a test value provided by us. When you have created your transform it should look something like this:

Install Demo
The data necessary for this example can be found in the Speedscale github repository:
git clone https://github.com/speedscale/mock-lab
After you have downloaded the demo, follow the instructions in the languages/go directory (cd mock-lab/languages/go and go run .) to run the app and start capturing traffic. The mock-lab app authenticates through the POST /oauth/token endpoint, which returns an access_token used as a bearer token on subsequent calls. Send a credentialed token request whose body carries the login values you want to transform, for example:
{
"grant_type": "client_credentials",
"client_id": "admin",
"client_secret": "pass"
}
Note: The mock-lab
/oauth/tokenhandler does not require these fields to issue a token, so you can supply whatever credential body fits your own auth flow. The point of this example is to show transforming a credential field (hereclient_id) in the login request body; pick whichever field carries the identity value in your environment.
Find this traffic in the traffic viewer, and then use the Save button to create a snapshot with this traffic.

Configuration
From the snapshot page, select the Traffic tab and you can see your set of Tests requests that will be sent to the server, and Mocks transactions to mock out downstream calls. This is how to create this transform:
- Select the
/oauth/tokentransaction - Click on the
Requesttab to see the request body - Click on the pencil next to
client_idand chooseModify
The screenshots in this section show the same steps on a different login request.

This will open the transform chain on the Prepare tab and you can see it has already selected the JSON Path for your client_id key. Now click the + Add step button and you will see a list of options:

You can see there are many different options available, but for this example select the Constant transform which lets you supply your own value, then click Done. You can visually see exactly how this value will change by looking at Replay uses under the chain. Now click Save and reanalyze to save the chain, and the snapshot will update.

On the Traffic tab, the Changes column of the /oauth/token transaction now shows that there are transforms applied to that specific request. Now you can run this snapshot to see what the results look like. Try it out on your own snapshot!
Join slack.speedscale.com to ask real time questions. Our expert engineers are always happy to help with configuration issues.