HttpCalloutMockUtil Class

Contains a method to send fake HTTP callouts for classes in the Auth namespace.

Namespace

Auth

Usage

Use the setHttpMock method in this class to test HTTP callouts when implementing the Auth.JWTBearerTokenExchange and Auth.JWTUtil classes.

For the Auth.JWTBearerTokenExchange class, mock callouts to the OAuth token endpoint when using the JWTBearerTokenExchange method.

For the Auth.JWTUtil class, mock callouts to the identity provider’s JSON Web Key Set (JWKS) endpoint when using the validateJWTWithKeysEndpoint method.

For more information on mocking HTTP callouts, see Testing HTTP Callouts by Implementing the HttpCalloutMock Interface.

HttpCalloutMockUtil Methods

The following are methods for HttpCalloutMockUtil.

setHttpMock(mock)

Mocks an HTTP callout using an implementation of the System.HttpCalloutMock interface.

Signature

public static void setHttpMock(System.HttpCalloutMock mock)

Parameters

mock
Type: System.HttpCalloutMock
A class that implements the System.HttpCalloutMock interface to return a fake HTTP response for a given request to the OAuth token endpoint or a JWKS endpoint on an external identity provider, depending on your use case.

Return Value

Type: void