function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam SwannSam Swann 

Test class for Single-Sign-On Auto generated JIT handler.

Hi

I am new to this Single-Sign-on configuration.
I have customized the autogenerated Jit handler Apex class to insert/update the user record as per my requirement. 

While writing a test class for this auto-generated Jit handler class, I am running into some errors. 

Here are the methods I am trying to refer from Jit handler:
 

/*Create User */
global User createUser(Id samlSsoProviderId, Id communityId, Id portalId,
		String federationIdentifier, Map<String, String> attributes, String assertion) {
		User u = new User();
		handleJit(true, u, samlSsoProviderId, communityId, portalId,
			federationIdentifier, attributes, assertion);
		return u;
	}

/*Update User */
global void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId,
		String federationIdentifier, Map<String, String> attributes, String assertion) {
		User u = [SELECT FirstName, LastName, Phone, Email FROM User WHERE Id=:userId];
		handleJit(false, u, samlSsoProviderId, communityId, portalId,
			federationIdentifier, attributes, assertion);
	}

/*Jit Handler method */
private void handleJit(boolean create, User u, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
		if(communityId != null) {
			handleUser(create, u, attributes, federationIdentifier, false);
		} else {
			handleUser(create, u, attributes, federationIdentifier, true);
		}
	}

/*HandleUser method*/
// This method has some basic insert and update User fields based on my requirement.

Can someone please help me out writing a test class and methods that call the above methods?

Thanks
Sam SwannSam Swann
// Create User 
global User createUser(Id samlSsoProviderId, Id communityId, Id portalId,
		String federationIdentifier, Map<String, String> attributes, String assertion) {
		User u = new User();
		handleJit(true, u, samlSsoProviderId, communityId, portalId,
			federationIdentifier, attributes, assertion);
		return u;
	}

// Update User 
global void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId,
		String federationIdentifier, Map<String, String> attributes, String assertion) {
		User u = [SELECT FirstName, LastName, Phone, Email FROM User WHERE Id=:userId];
		handleJit(false, u, samlSsoProviderId, communityId, portalId,
			federationIdentifier, attributes, assertion);
	}

// Jit Handler method 
private void handleJit(boolean create, User u, Id samlSsoProviderId, Id communityId, Id portalId, String federationIdentifier, Map<String, String> attributes, String assertion) {
		if(communityId != null) {
			handleUser(create, u, attributes, federationIdentifier, false);
		} else {
			handleUser(create, u, attributes, federationIdentifier, true);
		}
	}

// HandleUser method
// This method has some basic insert and update User fields based on my requirement.


Update: To just to have a good visualization. 

If someone responds before EOD today, that would be great.

Thanks.