-
Notifications
You must be signed in to change notification settings - Fork 39
Increase SFDCAccessController coverage and assertions #14
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
Increase SFDCAccessController coverage and assertions #14
Conversation
… Object and Field perms to a common method.
src/classes/testAccessController.cls
Outdated
@@ -38,6 +38,44 @@ | |||
@isTest | |||
private class testAccessController { | |||
|
|||
// Baseline Contact fields that will be accessiable when using the ReadOnly profile and createFieldPermissions() | |||
private static List<String> fieldsToCheck = new List<String>{'LastName','FirstName','Salutation','OtherStreet','OtherCity','OtherState','OtherPostalCode','OtherCountry','OtherLatitude','OtherLongitude','MailingStreet','MailingCity','MailingState','MailingPostalCode','MailingCountry','MailingLatitude','MailingLongitude','Phone','Fax','MobilePhone','HomePhone','OtherPhone','AssistantPhone','ReportsToId','Title','Department','AssistantName','LeadSource','Birthdate','Description','OwnerId','EmailBouncedReason','EmailBouncedDate','Jigsaw','CleanStatus', 'Email'}; |
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.
Jigsaw fields might go away with the data.com end of life. Please choose another standard field with a more certain future.
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.
I've removed the Jigsaw and CleanStatus data.com fields. They were mostly present as the ReadOnly profile granted access and I was trying to stress the methods under testing with the largest number of fields that standard profile allows.
src/classes/testAccessController.cls
Outdated
// should fail - so all good | ||
} | ||
|
||
try { |
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.
weird indent
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.
I've found that VSCode has defaulted to tabs with a size of 4. That's created an odd mixture of the existing 4-space indents and the newer 4-tab indents that doesn't look right on Github.
I did look at converting the entire class to consistent 4-space indenting, but it also picked up a large number of changes on the existing lines. I suspect this was part of the formatting problem I encountered when converting to the SFDX format.
For now I've just corrected this particular instance and will save the consistent document indentation for a subsequent pull request. Or would you prefer it all in one go?
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.
Save the whitespace diffs for a different PR please. Formatting changes fit better as their own verifiably formatting-only PR.
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.
OK. I think the PR has been corrected now and doesn't include the class wide formatting changes.
Remove references to Jigsaw and CleanStatus Data.com fields. I'd mostly just included every Contact field that the ReadOnly profile granted access to help test the limits of the existing methods. Correct spelling of "accessible". Corrected indentation of "try" prior to setArrayOperationMode(). Converted all indentation to be 4 Spaces (consistent with original formatting). Reran the tests against a scratch org. They are still all passing and coverage is still at 93.2%.
Revert indentation changes. I'll look at using 4 spaces consistently separately so it is easier to track the overall changes.
…ply the security stripping based on the access type.
Remote branch is too far ahead of what this PR was intended. Closing in favor of #16's cherry picked subset. |
Starting code coverage of SFDCAccessController by testAccessController was 54.4%. Many areas around testing negative cases for Object and Field level security were untested.
I've avoided adding a dedicated testing profile with no access and have instead used the standard ReadOnly profile. This should reduce the impact on other orgs if the source is installed directly rather than as a package.
The test coverage is now at 93.2%. More importantly, there are assertions that each of the test scenarios is producing the expected outcome.