Hi all.
I need to access a session variable in a http transform function called 'check_scope()'. But the print statement in my check_scope function
shows that the "${scopeContains}" is not being retrieved from the session
Below is the code and console output. Other things I've tried: injecting session into he outer exec, referencing session in the transform call, doing exec with session
to print the session value inside the check_scope function which doesn't print anything oddly.
Any pointers to try, or ideally a code pattern I can look at are appreciated. Thanks!
**HTTP post that returns 'scope' value to be checked**
.exec(http(OAuthV2TokenReq)
.post("/oauth/token")
.basicAuth(AuthConfig.WEB_CLIENT_ID, AuthConfig.WEB_CLIENT_SECRET)
.headers(HEADERS_LOGIN_OAUTH)
.formParam("grant_type", "authorization_code")
.formParam("code", "${code}")
.formParam("redirect_uri", GlobalVars.getEnv)
.check(status.is(200))
.check(jsonPath("$.id").ofType[String].exists)
.check(jsonPath("$.access_token").ofType[String].exists)
.check(jsonPath("$.id").saveAs("user_id"))
.check(jsonPath("$.access_token").saveAs("jwt_token"))
.check(jsonPath("$.refresh_token").saveAs("refresh_token"))
.check(jsonPath("$.expires_in").ofType[Int].saveAs("expires_in"))
.check(jsonPath("$.expires_in").ofType[Int].transform(convertExpiresInToDate(_)).saveAs("jwtExpiryDate"))
**.check(jsonPath("$.scope").ofType[String].transform(check_scope(_, "${scopeContains}")).saveAs("scope"))**
.check(jsonPath("$").saveAs("auth_response"))
)
**check_scope Function:**
``` private def check_scope(scope: String, scopeContains: String) : String = { ```
``` println("CHECK_SCOPE scope: " + scope + ", scopeContains: '" + scopeContains + "'") ```
``` scope ```
``` } ```
Console output: