in benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/AuthenticationActions.scala [59:91]
def feeder(): Feeder[String] = Iterator.continually(
Map(
"clientId" -> cp.clientId,
"clientSecret" -> cp.clientSecret
)
)
/**
* Authenticates using client credentials and saves the access token as a session attribute. The
* credentials are defined in the [[AuthenticationActions.feeder]]. This operation performs an
* OAuth2 client credentials flow, requesting full principal roles, and stores the received access
* token in both the Gatling session and the shared AtomicReference.
*
* There is no limit to the maximum number of users that can authenticate concurrently.
*/
val authenticateAndSaveAccessToken: ChainBuilder =
retryOnHttpStatus(maxRetries, retryableHttpCodes, "Authenticate")(
http("Authenticate")
.post("/api/catalog/v1/oauth/tokens")
.header("Content-Type", "application/x-www-form-urlencoded")
.formParam("grant_type", "client_credentials")
.formParam("client_id", "#{clientId}")
.formParam("client_secret", "#{clientSecret}")
.formParam("scope", "PRINCIPAL_ROLE:ALL")
.saveHttpStatusCode()
.check(status.is(200))
.check(jsonPath("$.access_token").saveAs("accessToken"))
)
.exec { session =>
if (session.contains("accessToken"))
accessToken.set(session("accessToken").as[String])
session
}