bcquality/community/knowledge/testing/testpermissions-attribute-controls-test-context.good.al
2026-06-15 07:55:26 +08:00

28 lines
805 B
AL

codeunit 50102 "Customer Permission Tests"
{
Subtype = Test;
TestPermissions = Restrictive;
var
Assert: Codeunit Assert;
[Test]
procedure CustomerReadFailsWithoutPermission()
var
Customer: Record Customer;
begin
// Restrictive: test runner assigns no permission sets to the test user.
asserterror Customer.FindFirst();
Assert.ExpectedError('You do not have the following permissions');
end;
[Test]
[TestPermissions(TestPermissions::Disabled)]
procedure AdminCanReadAllCustomers()
var
Customer: Record Customer;
begin
// Disabled overrides codeunit-level Restrictive for this test only.
// Use for paths that legitimately require elevated access.
Customer.FindFirst();
end;
}