function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patrick Mulligan 3Patrick Mulligan 3 

security superbadge

Hi all, I have managed to get past the first challenge, and partly past the second challenge. The second Apex test keeps failiing and I just want to make sure there is not a bug in the class. The reason I ask is because:

1) The org wide defaults are set to private.
2) I removed all sharing rules as a test and I could still not get it to fire.
3) The list view for test opps for Samantha Cordero returns only her test opps with opps owned by the sys admin on original org setup.
4) I even mass transfered all the opps owned by the sysadmin (myself) to Samantha

System.AssertException: Assertion Failed: Field Sales users should not be able to read Opportunities owned by someone else. However, the test returned records not owned by the user. #sadtrombone: Expected: 1, Actual: 2

So, if I have no sharing rules, and the OWD is set to private for opps, how can this even happen?  (I did pass the sharing rule setup earlier in the challenge, but I deleted them to test this).

Thanks
NagendraNagendra (Salesforce Developers) 
Hi Patrick,

May I request you to please double check with below steps in order to validate the challenge successfully.
  1. OWD settings for Opportunity object is 'Private'.
  2. Create public group as 'Project Managers' for Project Manager related requirements.
  3. Setup Profiles and Roles for Field Sales User, Inside Sales User, and Sales Executive User.
  4. Created one criteria-based sharing rule for Opportunity.Criteria: (Opportunity: TypeEQUALSExisting Customer - Upgrade) AND (Opportunity: StageEQUALSClosed Won)
    Shared with: Group: Project Managers
    Access level: Read Only
  5. Then, create another sharing rule for Opportunity (this one I created only after unsuccessful, run of the test cases). This sharing rule is owner based, with the following details:
    Criteria: Owner in All Internal Users (you may also use Sales Executive role as the criteria instead of All internal users)
    Shared with: Role: Inside Sales
    Access level: Read/Write
Mark this as solved if it's resolved.

Regards,
Nagendra.
Patrick Mulligan 3Patrick Mulligan 3
I did the steps above, and all is well until that second apex test. As I was walking through it, i would check the challenge as I created the sharing rules, it would pop up with the red box saying the sharing rule was not right (which was correct because it did not exist), as I created the two sharing rules, the red box went away, but no matter what I do it seems this second test fails.

My point is, the error message is saying: Field Sales users should not be able to read Opportunities owned by someone else. However, the test returned records not owned by the user. #sadtrombone: Expected: 1, Actual: 2"

This is what the requirement is, but even after I delete all sharing rules, and with the OWD set to private, I still get the same message!!! That should be impossible in this situation correct?!!! With not sharing rules, and the OWD set to private, should the message not be something to the opposite, somethink like "no sharing rules exist"? There shold be no opps available to read between field sales users at all given this scenario?
Derek Bennett 5Derek Bennett 5
I am stuck here as well. I got one test to pass but cannot pass the other:

System.AssertException: Assertion Failed: Inside Sales users should be able to read all Opportunities but the test did not find all records. #sadtrombone: Expected: 3, Actual: 2