---
schema_version: "1"
id: 86c61a2ae54103ddfaf2b232db655ff6b711c9b8818866b86ba33e0f32ab4e4d
title: HttpCalloutMockUtil Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Auth_HttpCalloutMockUtil.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_HttpCalloutMockUtil.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b2d783f7efbbc7f6284a3c1b577335b4623191aa6f0b682967b58da349dff5e7
description: Contains a method to send fake HTTP callouts for classes in the Auth namespace.Mocks an HTTP callout using an implementation of the System.HttpCalloutMock interface.
---
# HttpCalloutMockUtil Class

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

## Namespace

[Auth](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Auth.htm "The Auth namespace provides an interface and classes for single sign-on into Salesforce and session security management.")

## 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](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm).

- **[HttpCalloutMockUtil Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_HttpCalloutMockUtil.htm#apex_Auth_HttpCalloutMockUtil_methods)**

## HttpCalloutMockUtil Methods

The following are methods for HttpCalloutMockUtil.

- **[setHttpMock(mock)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_HttpCalloutMockUtil.htm#apex_Auth_HttpCalloutMockUtil_setHttpMock)**  
    Mocks an HTTP callout using an implementation of the System.HttpCalloutMock interface.

### 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](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_interface_httpcalloutmock.htm)
    
    A class that implements the [System.HttpCalloutMock](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_interface_httpcalloutmock.htm) 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