I have a custom object (Team__c) which is visible using a standard profile - Marketing User. However I have not provided any CRUD permissions on this custom object. I validated this on the Marketing User profile. This object X has some required fields which are visible by default for all standard profiles.
Existing CustomObject : Team__c
- req field: Name
User: markUser with profile 'Marketing User'. No other permissions
OWD settings Team__C : Public Read/Write
System.runAs(markUser){
boolean res = True;
// this should not return any results since Marketing User profile
// does not have access to Team__C object
try {
Team__c teamObj = [Select name from Team__c];
} catch(Exception e){
res = False;
}
System.assert(res);
}
I had created the Team__c object a long while back and I might have selected some permissions unintentionally. How do I remove the Team__c's object permissions for the profile?
Edit: I added/removed some information for more clarity.
I see that the OWD settings for Team object is Public Read/Write but the Marketing user profile does not have permissions on this object. Does OWD setting override object permissions?
system.assertEquals(<expected_value>, <actual_value>)
, right? You have it reversed... And even if the user didn't have visibility, if the query returned zero rows as written it would throw an exception and you would never hit the assertion in the first place.