Hello,
In order to make end 2 end tests with the management API, we found that mocking this api is as other api if we know that the “domain” parameter can be expressed with https://domain and not only domain.
In that case, for example, to mock the request token, with something like :
when (
HttpRequest.request()
.withMethod(POST.name())
.withPath("/oauth/token")
.apply {
withHeaders(
mapOf(
"grant_type" to "client_credentials",
"client_id" to "XXXXXXX",
"client_secret" to "XXXXXXX",
"audience" to "https://xxxx.auth0.com/api/v2/"
)
)
},
Times.once()
).respond(
HttpResponse.response()
.withBody("""{
"access_token": "xxx",
"scope": "read:users update:users delete:users create:users read:users_app_metadata update:users_app_metadata delete:users_app_metadata create:users_app_metadata create:user_tickets read:connections read:organization_connections",
"expires_in": 86400,
"token_type": "Bearer"
}""", UTF_8)
)
Have fun!