apex-enterprise-patterns / fflib-apex-common

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

fflib_SecurityUtilsTest fails in new production org #397

Closed scottmcclung closed 2 years ago

scottmcclung commented 2 years ago

When running the tests for fflib-apex-common against a new production org we're getting a failure in the fflib_SecurityUtilsTest class

fflib_SecurityUtilsTest.readonly_objectAndField_access
System.AssertException: Assertion Failed: Read only profile should be able to read Contact: Expected: null, Actual: FlsException:[SecurityException.m_objectType=Contact, SecurityException.m_operation=READ, m_fieldToken=Birthdate]: You do not have permission to read the field Birthdate on Contact Class.fflib_SecurityUtilsTest.readonly_objectAndField_access: line 261, column

It appears that the new org includes a Read Only profile but that profile does not include visibility on the Contact.Birthdate field like the test is expecting.
I'm seeing a similar configuration in new trial orgs.

A suggested fix to this is to assign the "ReadOnlyPermissionSet" to the RunAs user test user regardless of whether the setupTestUser() method assigns the Read Only or Minimum Access - Salesforce profiles.