mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 06:36:55 +01:00
Merge 3f9690ad45 into ac249ba4c9
This commit is contained in:
commit
c71f3d5778
3 changed files with 77 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
||||||
|
codeunit 50543 "Test Sample Posted Fixture Bad"
|
||||||
|
{
|
||||||
|
Subtype = Test;
|
||||||
|
TestPermissions = Disabled; // does not help: the check is the license, not the permission set
|
||||||
|
|
||||||
|
// Direct insert into a posted table: green under a container runner,
|
||||||
|
// "Your license does not grant you ... Insert" under a SaaS user license.
|
||||||
|
local procedure CreatePostedPurchaseInvoice(): Code[20]
|
||||||
|
var
|
||||||
|
PurchInvHeader: Record "Purch. Inv. Header";
|
||||||
|
begin
|
||||||
|
PurchInvHeader.Init();
|
||||||
|
PurchInvHeader."No." := 'PI-TEST-001';
|
||||||
|
PurchInvHeader.Insert();
|
||||||
|
exit(PurchInvHeader."No.");
|
||||||
|
end;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
procedure PostedInvoiceIsAvailable()
|
||||||
|
var
|
||||||
|
PurchInvHeader: Record "Purch. Inv. Header";
|
||||||
|
begin
|
||||||
|
PurchInvHeader.Get(CreatePostedPurchaseInvoice());
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
codeunit 50542 "Test Sample Posted Fixture Good"
|
||||||
|
{
|
||||||
|
Subtype = Test;
|
||||||
|
|
||||||
|
var
|
||||||
|
LibraryPurchase: Codeunit "Library - Purchase";
|
||||||
|
|
||||||
|
// Posted data is produced by posting, so the fixture runs under any license.
|
||||||
|
local procedure CreatePostedPurchaseInvoice(): Code[20]
|
||||||
|
var
|
||||||
|
PurchaseHeader: Record "Purchase Header";
|
||||||
|
begin
|
||||||
|
LibraryPurchase.CreatePurchaseInvoice(PurchaseHeader);
|
||||||
|
exit(LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true));
|
||||||
|
end;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
procedure PostedInvoiceIsAvailable()
|
||||||
|
var
|
||||||
|
PurchInvHeader: Record "Purch. Inv. Header";
|
||||||
|
begin
|
||||||
|
PurchInvHeader.Get(CreatePostedPurchaseInvoice());
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
bc-version: [all]
|
||||||
|
domain: testing
|
||||||
|
keywords: [license, entitlement, posted-tables, ledger, direct-insert, sandbox, saas, test-runner, environmental-failure, triage]
|
||||||
|
technologies: [al]
|
||||||
|
countries: [w1]
|
||||||
|
application-area: [all]
|
||||||
|
---
|
||||||
|
|
||||||
|
# License-entitlement failures on posted tables in a SaaS test run are environmental
|
||||||
|
|
||||||
|
> Contributions welcome — open a PR to refine or extend this article.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
A test session against a SaaS sandbox runs under the signed-in user's **license entitlement**, and entitlements grant only indirect access to posted and ledger tables. A test helper that inserts directly into such a table fails with `Your license does not grant you the following permissions on TableData <table>: Insert`. This is a license check, not a permission-set check: `TestPermissions = Disabled` and `SUPER` do not lift it. The same test is green under a container or pipeline test runner, whose license does not carry the restriction. The failure is therefore environmental — it says where the test ran, not that the change under review broke anything.
|
||||||
|
|
||||||
|
## Best Practice
|
||||||
|
|
||||||
|
Triage a license-entitlement failure on a posted or ledger table as environment-limited before suspecting the diff: confirm the same test failed identically on the pre-change baseline in the same environment. For a durable fix, create posted data through posting — the test library codeunits (`Library - Sales`, `Library - Purchase`) create and post documents — so the test runs under any license and exercises the posting path it depends on.
|
||||||
|
|
||||||
|
See sample: `license-entitlement-failures-on-posted-tables-are-environmental.good.al`.
|
||||||
|
|
||||||
|
## Anti Pattern
|
||||||
|
|
||||||
|
Reporting the failure as a regression of the change under review, "fixing" it by adding `TestPermissions = Disabled` or a broader permission set (neither is consulted by the license check), or building fixtures by `Init` + direct `Insert` into a posted table, which passes only where the runner's license allows it.
|
||||||
|
|
||||||
|
See sample: `license-entitlement-failures-on-posted-tables-are-environmental.bad.al`.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue