Jmeter performance testing with different grant types offered by WSO2 APIM — Part 3(Implicit grant Type)
By: Chamindu Udakara
Tags: Grant Types, Jmeter, Implicit Grant, Wso2 Api Manager, Performance Testing

5. Create Request to authorize endpoint.

To achieve this task, the following steps need to be completed.

Create an HTTP request using Jmeter GUI (Authorization_Code >Add > Sampler> HTTP Request) and rename it as “Send a request to authorize endpoint” In the HTTP Request window under the “Basic” configurations window following configs need to be provided.

Protocol: https Server Name or IP: localhost (Or Whatever the hostname of Gateway node) Port Number: 8243 (Or authorized port number of the server) HTTP Request Method : GET Path : /oauth2/authorize

3. Then Using GUI add the following parameters and their respective values.

client_id: [Extracted consumer key from Devportal GUI] redirect_uri : [ Callback URL which provided when generating keys with Dev portal GUI ] response_type: token scope : openId nonce: [ Any Random Number ]

After the above configs, the GUI of Jmeter should looks similar to the following image.

4. Add a response assertion to Above created “Send a request to authorize endpoint” HTTP request (HTTP Request > Add > Assertion> Response Assertion) and provide details as follows.

Apply to: Main samples only Field to Test: Response Headers Patterns to Test: HTTP/1.1 200

5. Add an XPath extractor to Above created “Send a request to authorize endpoint” HTTP request (HTTP Request > Add > Post Processor> XPath Extractor) and provide details as follows.

6. Create Request to Common Auth Login HTTP Request.

Create an HTTP request using Jmeter GUI (Authorization_Code >Add > Sampler> HTTP Request) and rename it as “Common Auth Login HTTP Request” In the HTTP Request window under the “Basic” configurations window following configs need to be provided.

Protocol: https Server Name or IP: localhost (Or Whatever the hostname of Gateway node) Port Number: 8243 (Or authorized port number of the server) HTTP Request Method : POST Path : /commonauth

3. Then Using GUI add the following parameters and their respective values.

username: [Admin username of that particlar tenant] password: [ Admin password of that particlar tenant ] sessionDataKey: ${sessionDataKey} ** (The value for this field is automatically extracted by previously added XPath extractor of previous request)

After the above configs, the GUI of Jmeter should looks similar to the following image.

4. Add a response assertion to Above created “Common Auth Login HTTP Request” HTTP request (HTTP Request > Add > Assertion> Response Assertion) and provide details as follows.

Apply to: Main samples only Field to Test: Response Headers Patterns to Test: HTTP/1.1 200

5. Add an XPath extractor to Above created “Send a request to authorize endpoint” HTTP request (HTTP Request > Add > Post Processor> XPath Extractor) and provide details as follows. Rename that Xpath extractor as follows for clarification when running these tests.

**The values extracted here will be a required body parameter for the next request to be made.

7. Create Request to Get Authorization Code.

To perform this task following steps need to be completed.

Create an HTTP request using Jmeter GUI (Authorization_Code >Add > Sampler> HTTP Request) and rename it as “ Get Authorization Code” In the HTTP Request window under the “Basic” configurations window following configs need to be provided.

Protocol: https Server Name or IP: localhost (Or Whatever the hostname of Gateway node) Port Number: 8243 (Or authorized port number of the server) HTTP Request Method : POST Path : /oauth2/authorize

3. Then Using GUI add the following parameters and their respective values.

consent: approve sessionDataKeyConsent: ${sessionDataKeyConsent}** (The value for this field is automatically extracted by previously added XPath extractor of previous request)

After the above configs, the GUI of Jmeter should looks similar to the following image.

4. Add a response assertion to Above created “Get Authorization Code” HTTP request (HTTP Request > Add > Assertion> Response Assertion) and provide details as follows.

Apply to: Main samples only Field to Test: Response Headers Patterns to Test: HTTP/1.1 302

5. Add a Regular Expression Extractor to Above created “Get Authorization Code” HTTP request (HTTP Request > Add > Post Processor> Regular Expression Extractor) and provide details as follows. Rename that extractor as follows for clarification when running these tests.

Regular expression to use: access_token=([a-zA-Z0–9-._]+)\&?

**The values extracted here will be a required body parameter for the next request to be made.

8. Using this extracted token now the user can create a request to invoke APIs in order to perform Jmeter performance testings.

References

https://jmeter.apache.org/download_jmeter.cgi. (Follow the https://medium.com/@cudakara/how-to-install-jmeter-in-ubuntu-20-04-7e4d30c42551