testInvokeAuthorizer method
Simulate the execution of an Authorizer in your RestApi with headers, parameters, and an incoming request body.
May throw BadRequestException. May throw UnauthorizedException. May throw NotFoundException. May throw TooManyRequestsException.
Parameter authorizerId :
Required Specifies a test invoke authorizer request's Authorizer
ID.
Parameter restApiId :
Required The string identifier of the associated RestApi.
Parameter additionalContext :
Optional A key-value map of additional context variables.
Parameter body :
Optional The simulated request body of an incoming invocation request.
Parameter headers :
Required 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 :
Optional 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 :
Optional 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 {
ArgumentError.checkNotNull(authorizerId, 'authorizerId');
ArgumentError.checkNotNull(restApiId, 'restApiId');
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);
}