Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testAccessControl Fails #94

Closed
corym-cp opened this issue Feb 5, 2021 · 7 comments
Closed

testAccessControl Fails #94

corym-cp opened this issue Feb 5, 2021 · 7 comments

Comments

@corym-cp
Copy link

corym-cp commented Feb 5, 2021

When attempting to validated any change set in sandbox or production after installing and configuring the SurveyForce package, we receive a failure on the SFDCAccessControllerTest, method testAccessControl with error message: "System.AssertException: Assertion Failed: Expected: false, Actual: true" Class.SFDCAccessControllerTest.testAccessControl: line 141, column 1

We have confirmed configuration is correct based on the Post Install Guide & Instructions. I have attached a debug log of the failure.

apex-07L3t00003o2UMUEA2.log

@jrattanpal
Copy link
Collaborator

Does user have "Create" access for "Contact" object?

That class s using that to validate it. I know it's not listed in there but, generally, an admin does it and they have access to that object.

If that's not the case AND you don't want to give create access then change that line of code to use another object with create access.

System.assertEquals(false, Access_Controller.isAuthorizedToCreate(Schema.Contact.SobjectType, contactLastModifiedDate));

Maybe change that to "Schema.Account.SobjectType" (or any other object)

@corym-cp
Copy link
Author

corym-cp commented Feb 5, 2021

Yes, I am the user running the test and I have full Admin across our Org to include full CRUD on all objects.

@jrattanpal
Copy link
Collaborator

I read it wrong. This is actually testing to make sure that it will fail because you shouldn't have access to create LastModifiedDate.

But I believe there is a permission to create Audit fields. I wonder if you have that on and if that is causing it. Because no one should have permission to create LastModifiedDate field.

@jrattanpal
Copy link
Collaborator

This is the feature I was talking about. Do you have this feature on?

https://help.salesforce.com/articleView?id=000328426&type=1&mode=1

@corym-cp
Copy link
Author

corym-cp commented Feb 5, 2021

HI jrattanpal, we do have this enabled and assigned to our custom admin profile. I am re-running tests in sandbox to confirm resolution after removing the permissions. I appreciate your guidance thus far, stay tuned for my update after test runs complete.

@corym-cp
Copy link
Author

corym-cp commented Feb 5, 2021

jrattanpal, removing the "Set Audit Fields upon Record Creation" permission from our profile. This allowed the test to successfully pass.

Thank you for the guidance!

@dschach
Copy link
Contributor

dschach commented Apr 8, 2021

I suggest putting a check in the method that looks for the presence of the field on the user profile, and then acting accordingly if that field is not found, and returning a value that will allow the assertion to pass if the field is found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants