Open 255kb opened 1 year ago
Unfortunately, I don't think this can work. At least for the AWS PHP SDK, the Clients, for example the CognitoIdentityProviderClient that would call the example above with ListUserPools
, is always using /
as route. The client distinguishes the different methods by header, not by route.
Example output from mockoon logging of a ListUserPools
call with CognitoIdentityProviderClient
in a PHP application:
{
"level": "info",
"message": "POST / | 200",
"mockName": "mockoon-amazon-cognito-identity-provider",
"timestamp": "2023-05-09T11:49:51.180Z",
"transaction": {
"proxied": false,
"request": {
"body": "{\"MaxResults\":30}",
"headers": [
{
"key": "authorization",
"value": "AWS4-HMAC-SHA256 Credential=XXX/20230509/eu-central-1/cognito-idp/aws4_request, SignedHeaders=host;x-amz-date;x-amz-target;x-amz-user-agent, Signature=XXX"
},
{
"key": "aws-sdk-invocation-id",
"value": "XXX"
},
{
"key": "aws-sdk-retry",
"value": "0/0"
},
{
"key": "content-length",
"value": "17"
},
{
"key": "content-type",
"value": "application/x-amz-json-1.1"
},
{
"key": "host",
"value": "mockoon:3000"
},
{
"key": "user-agent",
"value": "aws-sdk-php/3.268.16 OS/Linux/5.15.90.1-microsoft-standard-WSL2 lang/php/8.2.4 GuzzleHttp/7"
},
{
"key": "x-amz-date",
"value": "20230509T114951Z"
},
{
"key": "x-amz-target",
"value": "AWSCognitoIdentityProviderService.ListUserPools"
},
{
"key": "x-amz-user-agent",
"value": "aws-sdk-php/3.268.16 OS/Linux/5.15.90.1-microsoft-standard-WSL2 lang/php/8.2.4"
}
],
"method": "POST",
"params": [],
"query": "",
"queryParams": {},
"route": "/",
"urlPath": "/"
},
"response": {
"body": "{}",
"headers": [
{
"key": "content-length",
"value": "2"
},
{
"key": "content-type",
"value": "application/json; charset=utf-8"
}
],
"statusCode": 200,
"statusMessage": "OK"
},
"routeResponseUUID": "e162096b-18ba-40b8-99d2-f8f1dc42fc9b",
"routeUUID": "5114dd4f-7643-4acd-b736-303163bc1bd9"
}
}
I changed the Cognito json provided by mockoon to not have #X-Amz-Target=XXX
in it's route which results in 101 Routes for /
and I will always receive the result for the first /
route 🥲
There is no way to add rules to route matching, right? Duplicate routes by path but Route A is called when Header A is sent and Route B matches if Header B is sent.
Edit: temporary solution at least for my case: use one route with many responses + rules.
Sorry, your message slipped my mind for a long time! There is no rules system at the environment level (there is an opened issue though), only at the route level. I guess it would be possible to automatically create a route with multiple header rules. But I guess it would become hard to manage at one point. I think this improvement should be done after a global rules system has been added.
Describe the bug Discussed in https://github.com/mockoon/mockoon/discussions/1028 Some API definition (AWS cognito) are not parsed correctly and show a header in the endpoint. It's also prefixed with a # which makes calling the endpoint impossible
To Reproduce Import the definition and try to call the endpoint.
Expected behavior Endpoint should be
ListUserPools
instead of#X-Amz-Target=AWSCognitoIdentityProviderService.ListUserPools
.