From 3caa07ef332e262c845085d27ccbe1e63417621a Mon Sep 17 00:00:00 2001 From: Reede Stockton Date: Wed, 10 Jan 2024 12:49:52 -0800 Subject: [PATCH 1/4] Remove unnecessary security check. --- .../classes/GE_GiftEntryController.cls | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/force-app/main/default/classes/GE_GiftEntryController.cls b/force-app/main/default/classes/GE_GiftEntryController.cls index 7c75f999975..6353ce42e4f 100644 --- a/force-app/main/default/classes/GE_GiftEntryController.cls +++ b/force-app/main/default/classes/GE_GiftEntryController.cls @@ -426,13 +426,6 @@ public with sharing class GE_GiftEntryController { DataImport__c dataImportObject = (DataImport__c)JSON.deserialize(dataImport, DataImport__c.class); try { - // As currently implemented, Gift Entry already checks everything checked in canUpsertDataImport() before - // allowing access. As a result, canUpsertDataImport() should never return false. It is implemented solely - // as a defense against future modifications since it is an AuraEnabled method that could be used outside - // of the currently implemented flow. - if (!canUpsertDataImport(dataImportObject)) { - throw new UTIL_Permissions.InsufficientPermissionException(System.Label.commonAccessErrorMessage); - } upsert dataImportObject Id; return dataImportObject; @@ -445,23 +438,6 @@ public with sharing class GE_GiftEntryController { } } - private static Boolean canUpsertDataImport(DataImport__c dataImportObject) { - if (!UTIL_Permissions.canCreate(UTIL_Namespace.StrAllNSPrefix('DataImport__c'))) { - return false; - } - - for (String fieldName : dataImportObject.getPopulatedFieldsAsMap().keySet()) { - if (!UTIL_Permissions.canUpdate(UTIL_Namespace.StrAllNSPrefix('DataImport__c'), - UTIL_Namespace.StrAllNSPrefix(fieldName), false)) { - if (!fieldName.equalsIgnoreCase('Id')) { - return false; - } - } - } - - return true; - } - /******************************************************************************************************* * @description Run the DataImport process on a single gift * @param dataImport DataImport record to be processed From 5b8f1ad23cf7b135a7051d02b8512e85fb9f82b4 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 10 Jan 2024 17:35:04 -0500 Subject: [PATCH 2/4] Remove sorting and filtering by the MailingState__c field allow it to support encrption --- force-app/test/ADDR_Addresses_TEST.cls | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/force-app/test/ADDR_Addresses_TEST.cls b/force-app/test/ADDR_Addresses_TEST.cls index b4a46dc426b..088d667aa7c 100644 --- a/force-app/test/ADDR_Addresses_TEST.cls +++ b/force-app/test/ADDR_Addresses_TEST.cls @@ -809,9 +809,12 @@ public with sharing class ADDR_Addresses_TEST { ); insert contact; - Address__c overrideAddress = [SELECT Undeliverable__c - FROM Address__c - WHERE MailingState__c = 'Pennsylvania']; + UTIL_Finder queryByState = new UTIL_Finder(Address__c.SObjectType) + .withSelectFields(new List{ 'Undeliverable__c' }) + .withWhere(new UTIL_Where.FieldExpression(Address__c.MailingState__c).equals('Pennsylvania')); + + + Address__c overrideAddress = (Address__c)(queryByState.find()[0]); Test.startTest(); overrideAddress.Undeliverable__c = true; @@ -2229,10 +2232,12 @@ public with sharing class ADDR_Addresses_TEST { insert testContact; Test.stopTest(); - Address__c testAddress = [SELECT Latest_Start_Date__c, Default_Address__c - FROM Address__c - WHERE MailingState__c = 'Washington' - LIMIT 1]; + UTIL_Finder queryByState = new UTIL_Finder(Address__c.SObjectType) + .withSelectFields(new List{ 'Latest_Start_Date__c', 'Default_Address__c' }) + .withWhere(new UTIL_Where.FieldExpression(Address__c.MailingState__c).equals('Washington')) + .withLimit(1); + + Address__c testAddress = (Address__c)(queryByState.find()[0]); System.assertEquals(true, testAddress.Default_Address__c, 'Address should be set as the default address.'); System.assertEquals(System.today(), testAddress.Latest_Start_Date__c, 'The default address latest start date ' + 'should be set to today\'s date.'); @@ -2548,7 +2553,6 @@ public with sharing class ADDR_Addresses_TEST { MailingStreet__c, MailingCity__c, MailingState__c, MailingPostalCode__c, MailingCountry__c FROM Address__c - ORDER BY MailingState__c ]; } From 4cad52bb6bc7929c5e1b6bd22fb2f5a13890b91e Mon Sep 17 00:00:00 2001 From: Reede Stockton Date: Wed, 10 Jan 2024 16:03:15 -0800 Subject: [PATCH 3/4] Remove AuraHandledException catch block --- force-app/main/default/classes/GE_GiftEntryController.cls | 2 -- 1 file changed, 2 deletions(-) diff --git a/force-app/main/default/classes/GE_GiftEntryController.cls b/force-app/main/default/classes/GE_GiftEntryController.cls index 6353ce42e4f..30118bda8ae 100644 --- a/force-app/main/default/classes/GE_GiftEntryController.cls +++ b/force-app/main/default/classes/GE_GiftEntryController.cls @@ -429,8 +429,6 @@ public with sharing class GE_GiftEntryController { upsert dataImportObject Id; return dataImportObject; - } catch (UTIL_Permissions.InsufficientPermissionException e) { - throw new AuraHandledException(e.getMessage()); } catch (Exception e) { String JSONExceptionData = ERR_ExceptionData.createExceptionWrapperJSONString(e); From 802c1983fd2eb94814cad282453b363d69289554 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 12 Jan 2024 08:45:37 -0500 Subject: [PATCH 4/4] Remove use of UTIL_Finder because it appears when the field is encrypted, it's not available for SOSL fast enough for the test to work --- force-app/test/ADDR_Addresses_TEST.cls | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/force-app/test/ADDR_Addresses_TEST.cls b/force-app/test/ADDR_Addresses_TEST.cls index 088d667aa7c..33e7d6edae2 100644 --- a/force-app/test/ADDR_Addresses_TEST.cls +++ b/force-app/test/ADDR_Addresses_TEST.cls @@ -809,13 +809,14 @@ public with sharing class ADDR_Addresses_TEST { ); insert contact; - UTIL_Finder queryByState = new UTIL_Finder(Address__c.SObjectType) - .withSelectFields(new List{ 'Undeliverable__c' }) - .withWhere(new UTIL_Where.FieldExpression(Address__c.MailingState__c).equals('Pennsylvania')); - - - Address__c overrideAddress = (Address__c)(queryByState.find()[0]); - + Address__c overrideAddress; + for (Address__c addr : [SELECT Id, MailingState__c, Undeliverable__c FROM Address__c]) { + if (addr.MailingState__c == 'Pennsylvania') { + overrideAddress = addr; + break; + } + } + Test.startTest(); overrideAddress.Undeliverable__c = true; update overrideAddress; @@ -2232,12 +2233,14 @@ public with sharing class ADDR_Addresses_TEST { insert testContact; Test.stopTest(); - UTIL_Finder queryByState = new UTIL_Finder(Address__c.SObjectType) - .withSelectFields(new List{ 'Latest_Start_Date__c', 'Default_Address__c' }) - .withWhere(new UTIL_Where.FieldExpression(Address__c.MailingState__c).equals('Washington')) - .withLimit(1); + Address__c testAddress; + for (Address__c addr : [SELECT Id, MailingState__c, Latest_Start_Date__c, Default_Address__c FROM Address__c]) { + if (addr.MailingState__c == 'Washington') { + testAddress = addr; + break; + } + } - Address__c testAddress = (Address__c)(queryByState.find()[0]); System.assertEquals(true, testAddress.Default_Address__c, 'Address should be set as the default address.'); System.assertEquals(System.today(), testAddress.Latest_Start_Date__c, 'The default address latest start date ' + 'should be set to today\'s date.');