Skip to content

Commit

Permalink
Replace Standard User Profile with Minimum Access Profile
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr PG Gajek <[email protected]>
  • Loading branch information
pgajek2 committed Feb 16, 2024
1 parent 7796c88 commit f6d6305
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions force-app/main/default/classes/SOQL_Test.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ private class SOQL_Test {
Case testCase = new Case(Status = 'New', Origin = 'Web');
insert testCase;

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
Case resultCase = (Case) SOQL.of(Case.SObjectType).systemMode().withoutSharing().toObject();

Expand All @@ -1953,7 +1953,7 @@ private class SOQL_Test {
// Setup
insertCases();

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
List<Case> cases = SOQL.of(Case.SObjectType).systemMode().withoutSharing().toList();

Expand All @@ -1967,7 +1967,7 @@ private class SOQL_Test {
// Setup
insertCases();

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
Integer casesAmount = SOQL.of(Case.SObjectType).count().systemMode().withoutSharing().toInteger();

Expand All @@ -1981,7 +1981,7 @@ private class SOQL_Test {
// Setup
insert new Task(Subject = 'Test', Type = 'Other');

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
Task resultTask = (Task) SOQL.of(Task.SObjectType).systemMode().withSharing().toObject();

Expand All @@ -1995,7 +1995,7 @@ private class SOQL_Test {
// Setup
insertTasks();

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
List<Task> tasks = SOQL.of(Task.SObjectType).systemMode().withSharing().toList();

Expand All @@ -2008,7 +2008,7 @@ private class SOQL_Test {
static void toIntegerWithSharing() {
insertTasks();

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
Integer tasksAmount = SOQL.of(Task.SObjectType).count().systemMode().withSharing().toInteger();

Expand All @@ -2020,10 +2020,9 @@ private class SOQL_Test {
@IsTest
static void stripInaccessibleToObject() {
// Setup
Task testTask = new Task(Subject = 'Test', Type = 'Other');
insert testTask;
insert new Task(Subject = 'Test', Type = 'Other');

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
Task task = (Task) SOQL.of(Task.SObjectType)
.with(Task.Type)
Expand Down Expand Up @@ -2055,7 +2054,7 @@ private class SOQL_Test {
// Setup
insertTasks();

System.runAs(standardUser()) {
System.runAs(minimumAccessUser()) {
// Test
List<Task> tasks = SOQL.of(Task.SObjectType)
.with(Task.Type)
Expand Down Expand Up @@ -2446,15 +2445,15 @@ private class SOQL_Test {
};
}

static User standardUser() {
static User minimumAccessUser() {
return new User(
Alias = 'newUser',
Email = '[email protected]',
EmailEncodingKey = 'UTF-8',
LastName = 'Testing',
LanguageLocaleKey = 'en_US',
LocaleSidKey = 'en_US',
ProfileId = [SELECT Id FROM Profile WHERE Name = 'Standard User'].Id,
ProfileId = [SELECT Id FROM Profile WHERE Name = 'Minimum Access - Salesforce'].Id,
TimeZoneSidKey = 'America/Los_Angeles',
UserName = '[email protected]'
);
Expand Down

0 comments on commit f6d6305

Please sign in to comment.