apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
899 stars 514 forks source link

Fixes #440 - changes the few tests that are exercising CRUD/FLS enforcement to prefer the 'Minimum Access - Salesforce' profile since that is a more reliable Profile in most modern orgs #482

Closed daveespo closed 5 months ago

daveespo commented 6 months ago

My first cut at fixing this bug was to try to find an SObject that the Read Only profile DIDN'T grant Read access to. Well, that was a fool's errand because even though there were some Standard Objects that didn't have Object Read access, the FLS on the object granted Read access to every field on those Standard Objects.

I backed away from trying to find a way to thread that needle and instead applied a bit more of a pragmatic approach. Rather than preferring the 'Read Only' profile and if it doesn't exist, create a Minimum Access user and assign them a well-known set of Perms via a Perm Set, let's just start with that (i.e. always prefer the Minimum Access user)

There are potential regressions here for orgs that don't have the Minimum Access profile which does exist out in the wild. Those orgs will fall back to the 'Read Only' profile .. and it's likely that the same tests that are broken as reported in #440 will continue to be broken. But at least this patch fixes the more common case of people not being able to get a clean test run if they create a brand spanking new Developer Edition org (not scratch org)

I tested this on a clean DE org and on a Scratch Org of edition Developer -- tests pass cleanly in both (and prior to this fix, the tests failed as outlined in #440 in the DE org)


This change is Reviewable

foxysolutions commented 5 months ago

Thanks for the effort and solution @daveespo , looking good!