-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply reCaptcha to Public Forms #477
Open
scottwarren-sfdo
wants to merge
23
commits into
master
Choose a base branch
from
feature/sw-authflow__captcha
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c6fc02d
Working POC reCaptcha implementation
fd21a50
Merge faf049362452d4f5a86305375247f244fb8d29af into feature/sw-authfl…
salesforce-org-metaci[bot] ffaf21e
Adding component
7b17b51
Merge branch 'feature/sw-authflow__captcha' of github.com:SalesforceF…
29d8c71
Update captcha component
75a0549
Updated tests and formatting
894f842
Updated custom setting and formatting
a2f566f
Merge 876a3eccadc1a6702957b98432dc3bc73999ba17 into feature/sw-authfl…
salesforce-org-metaci[bot] aa1713d
Merge ef95b084c39a1621f6b4fc730a85af393bd9449a into feature/sw-authfl…
salesforce-org-metaci[bot] 2c6ca8c
Updated structure, adjusted tests, fixed modal display
a68f6e1
Merge branch 'feature/sw-authflow__captcha' of github.com:SalesforceF…
00f5a05
Updated formatting
6ae848e
Missing class files
722920b
Formatting
342e0fa
Merge 93f3eb9ec459bc2530fec1141909e360ae79ef02 into feature/sw-authfl…
salesforce-org-metaci[bot] 019e161
Merge 0f95a88d5a7452fa1992da9ccf136c174266c48e into feature/sw-authfl…
salesforce-org-metaci[bot] cdd3133
Merge f2b69caa85760a5124794d0c18fa4249f12a2890 into feature/sw-authfl…
salesforce-org-metaci[bot] ff9330f
Merge be11289a8509d325bb578d3583be67651341e65f into feature/sw-authfl…
salesforce-org-metaci[bot] 46b0b63
Merge c564089b82817b72302707b60bcc9350e7fadbbc into feature/sw-authfl…
salesforce-org-metaci[bot] 6859e89
Merge a3b9b7000d0a61fce1b2a24e9528d0b0ff3fefe6 into feature/sw-authfl…
salesforce-org-metaci[bot] 1f88dca
Merge 75eb39a085b715bc7bba819e296a9ed25677aa80 into feature/sw-authfl…
salesforce-org-metaci[bot] fd621d5
Merge dd36f9a1139b84ac31682574a8e1e28ae55a9834 into feature/sw-authfl…
salesforce-org-metaci[bot] 92fb1a8
Merge 117ea91f43f8383477296d08d73812979dc83817 into feature/sw-authfl…
salesforce-org-metaci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@isTest | ||
public class HttpMockFactory implements HttpCalloutMock { | ||
protected Integer code; | ||
protected String status; | ||
protected String body; | ||
protected Map<String, String> responseHeaders; | ||
|
||
public HttpMockFactory(Integer code, String status, String body, Map<String, String> responseHeaders) { | ||
this.code = code; | ||
this.status = status; | ||
this.body = body; | ||
this.responseHeaders = responseHeaders; | ||
} | ||
|
||
public HTTPResponse respond(HTTPRequest req) { | ||
HttpResponse res = new HttpResponse(); | ||
for (String key : this.responseHeaders.keySet()) { | ||
res.setHeader(key, this.responseHeaders.get(key)); | ||
} | ||
res.setBody(this.body); | ||
res.setStatusCode(this.code); | ||
res.setStatus(this.status); | ||
return res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>47.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,51 @@ private with sharing class VOL_CTRL_PersonalSiteContactLookup_TEST { | |
System.assertEquals(defaultClosedStatus, VOL_CTRL_PersonalSiteContactLookup.getClosedTaskStatus(), 'Expected the system to find the default closed task status when ran as a guest user.'); | ||
} | ||
} | ||
|
||
@IsTest | ||
private static void shouldReturnErrorOnCaptchaFailure() { | ||
//enable captcha | ||
UTIL_UnitTest.setupCaptchaSettings(true); | ||
|
||
//point to our VF page | ||
PageReference lookupPage = Page.PersonalSiteContactLookup; | ||
Test.setCurrentPage(lookupPage); | ||
|
||
Test.startTest(); | ||
VOL_CTRL_PersonalSiteContactLookup ctrl = new VOL_CTRL_PersonalSiteContactLookup(); | ||
ctrl.contact.Firstname = 'Test'; | ||
ctrl.contact.Lastname = 'User'; | ||
ctrl.contact.Email = '[email protected]'; | ||
ctrl.LookupContact(); | ||
Test.stopTest(); | ||
|
||
System.assertEquals(System.Label.CaptchaFailure, ctrl.strResult); | ||
} | ||
|
||
@IsTest | ||
private static void shouldReturnSuccessMessageOnCaptchaSuccess() { | ||
//enable captcha | ||
UTIL_UnitTest.setupCaptchaSettings(true); | ||
|
||
HttpMockFactory mock = new HttpMockFactory(200, 'OK', '{"success":true}', new Map<String,String>()); | ||
Test.setMock(HttpCalloutMock.class, mock); | ||
|
||
//point to our VF page | ||
PageReference lookupPage = Page.PersonalSiteContactLookup; | ||
Test.setCurrentPage(lookupPage); | ||
System.currentPageReference().getParameters().put('g-recaptcha-response', '1234567890'); | ||
|
||
Test.startTest(); | ||
VOL_CTRL_PersonalSiteContactLookup ctrl = new VOL_CTRL_PersonalSiteContactLookup(); | ||
ctrl.contact.Firstname = 'Test'; | ||
ctrl.contact.Lastname = 'User'; | ||
ctrl.contact.Email = '[email protected]'; | ||
ctrl.LookupContact(); | ||
Test.stopTest(); | ||
|
||
System.assertEquals(System.Label.labelContactLookupAmbiguous, ctrl.strResult); | ||
} | ||
|
||
@isTest(SeeAllData=true) // SeeAllData so the CSS file is viewable | ||
/******************************************************************************************************* | ||
* @description test the visualforce page controller, running as the Sites Guest User, if such as user | ||
|
@@ -104,6 +148,8 @@ private with sharing class VOL_CTRL_PersonalSiteContactLookup_TEST { | |
} | ||
|
||
private static void TestPersonalSiteContactLookup() { | ||
//disable captcha | ||
UTIL_UnitTest.setupCaptchaSettings(false); | ||
|
||
//point to our VF page | ||
PageReference p = new PageReference('Page.PersonalSiteContactLookup'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is disabled by default, why do we need to disable it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safeguards the test against unexpected changes elsewhere by being explicit here.