testInvokeAuthorizer method
Simulate the execution of an Authorizer in your RestApi with headers, parameters, and an incoming request body.
May throw BadRequestException.
May throw NotFoundException.
May throw TooManyRequestsException.
May throw UnauthorizedException.
Parameter authorizerId :
Specifies a test invoke authorizer request's Authorizer ID.
Parameter restApiId :
The string identifier of the associated RestApi.
Parameter additionalContext :
A key-value map of additional context variables.
Parameter body :
The simulated request body of an incoming invocation request.
Parameter headers :
A key-value map of headers to simulate an incoming invocation request.
This is where the incoming authorization token, or identity source, should
be specified.
Parameter multiValueHeaders :
The headers as a map from string to list of values to simulate an incoming
invocation request. This is where the incoming authorization token, or
identity source, may be specified.
Parameter pathWithQueryString :
The URI path, including query string, of the simulated invocation request.
Use this to specify path parameters and query string parameters.
Parameter stageVariables :
A key-value map of stage variables to simulate an invocation on a deployed
Stage.
Implementation
Future<TestInvokeAuthorizerResponse> testInvokeAuthorizer({
required String authorizerId,
required String restApiId,
Map<String, String>? additionalContext,
String? body,
Map<String, String>? headers,
Map<String, List<String>>? multiValueHeaders,
String? pathWithQueryString,
Map<String, String>? stageVariables,
}) async {
final $payload = <String, dynamic>{
if (additionalContext != null) 'additionalContext': additionalContext,
if (body != null) 'body': body,
if (headers != null) 'headers': headers,
if (multiValueHeaders != null) 'multiValueHeaders': multiValueHeaders,
if (pathWithQueryString != null)
'pathWithQueryString': pathWithQueryString,
if (stageVariables != null) 'stageVariables': stageVariables,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/restapis/${Uri.encodeComponent(restApiId)}/authorizers/${Uri.encodeComponent(authorizerId)}',
exceptionFnMap: _exceptionFns,
);
return TestInvokeAuthorizerResponse.fromJson(response);
}