Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

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