From f21ad8772f0308cec5fac7142548c564e7774c62 Mon Sep 17 00:00:00 2001 From: Luc van Vugt <lvvugt@4ps.nl> Date: Mon, 27 Nov 2023 12:55:27 +0100 Subject: [PATCH] FIrst version upload --- .gitignore | 3 + App/.vscode/settings.json | 7 ++ App/app.json | 32 +++++++++ .../TestPermissions.PermissionSet.al | 7 ++ App/src/table/TestTable.Table.al | 20 ++++++ Test/.vscode/settings.json | 7 ++ Test/app.json | 69 +++++++++++++++++++ Test/test/TestTPDisabled.Codeunit.al | 41 +++++++++++ Test/test/TestTPNonRestrictive.Codeunit.al | 44 ++++++++++++ Test/test/TestTPRestrictive.Codeunit.al | 44 ++++++++++++ al.code-workspace | 8 ++- 11 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 App/.vscode/settings.json create mode 100644 App/app.json create mode 100644 App/src/permissionset/TestPermissions.PermissionSet.al create mode 100644 App/src/table/TestTable.Table.al create mode 100644 Test/.vscode/settings.json create mode 100644 Test/app.json create mode 100644 Test/test/TestTPDisabled.Codeunit.al create mode 100644 Test/test/TestTPNonRestrictive.Codeunit.al create mode 100644 Test/test/TestTPRestrictive.Codeunit.al diff --git a/.gitignore b/.gitignore index 9b1f2f8..395c952 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ rad.json .snapshots/ cache_* ~$* +**//.vs/ +**/.vscode/** +!**/.vscode/settings.json \ No newline at end of file diff --git a/App/.vscode/settings.json b/App/.vscode/settings.json new file mode 100644 index 0000000..97fe63e --- /dev/null +++ b/App/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "CRS.ObjectNameSuffix": " FLX", + "CRS.FileNamePattern": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al", + "CRS.FileNamePatternExtensions": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al", + "CRS.ExtensionObjectNamePattern": "", + "CRS.RemoveSuffixFromFilename": true +} \ No newline at end of file diff --git a/App/app.json b/App/app.json new file mode 100644 index 0000000..fb3501e --- /dev/null +++ b/App/app.json @@ -0,0 +1,32 @@ +{ + "id": "503632db-9392-4d1a-b6e0-770f167b3556", + "name": "TestPermissionTest app", + "publisher": "fluxxus.nl", + "version": "1.0.0.0", + "brief": "", + "description": "", + "privacyStatement": "", + "EULA": "", + "help": "", + "url": "", + "logo": "", + "dependencies": [], + "screenshots": [], + "platform": "1.0.0.0", + "application": "23.0.0.0", + "idRanges": [ + { + "from": 84100, + "to": 84149 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "runtime": "12.0", + "features": [ + "NoImplicitWith" + ] +} \ No newline at end of file diff --git a/App/src/permissionset/TestPermissions.PermissionSet.al b/App/src/permissionset/TestPermissions.PermissionSet.al new file mode 100644 index 0000000..6bd3e16 --- /dev/null +++ b/App/src/permissionset/TestPermissions.PermissionSet.al @@ -0,0 +1,7 @@ +permissionset 84100 "Test Permissions FLX" +{ + Assignable = true; + Caption = 'Test Permissions'; + + Permissions = tabledata "Test Table FLX" = RIDM; +} \ No newline at end of file diff --git a/App/src/table/TestTable.Table.al b/App/src/table/TestTable.Table.al new file mode 100644 index 0000000..58b6afd --- /dev/null +++ b/App/src/table/TestTable.Table.al @@ -0,0 +1,20 @@ +table 84100 "Test Table FLX" +{ + DataClassification = ToBeClassified; + Caption = 'Test Table'; + + fields + { + field(1; "Code"; Code[10]) + { + DataClassification = ToBeClassified; + Caption = 'Code'; + + } + field(2; Description; Text[100]) + { + DataClassification = ToBeClassified; + Caption = 'Description'; + } + } +} \ No newline at end of file diff --git a/Test/.vscode/settings.json b/Test/.vscode/settings.json new file mode 100644 index 0000000..97fe63e --- /dev/null +++ b/Test/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "CRS.ObjectNameSuffix": " FLX", + "CRS.FileNamePattern": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al", + "CRS.FileNamePatternExtensions": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al", + "CRS.ExtensionObjectNamePattern": "", + "CRS.RemoveSuffixFromFilename": true +} \ No newline at end of file diff --git a/Test/app.json b/Test/app.json new file mode 100644 index 0000000..10e032c --- /dev/null +++ b/Test/app.json @@ -0,0 +1,69 @@ +{ + "id": "4d5aa84e-5883-4b93-8f5c-7c4f09902cd7", + "name": "TestPermissionTest test app", + "publisher": "fluxxus.nl", + "version": "1.0.0.0", + "brief": "", + "description": "", + "privacyStatement": "", + "EULA": "", + "help": "", + "url": "", + "logo": "", + "dependencies": [ + { + "id": "503632db-9392-4d1a-b6e0-770f167b3556", + "publisher": "fluxxus.nl", + "version": "1.0.0.0", + "name": "TestPermissionTest app" + }, + { + "id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b", + "publisher": "Microsoft", + "version": "23.0.0.0", + "name": "Any" + }, + { + "id": "dd0be2ea-f733-4d65-bb34-a28f4624fb14", + "publisher": "Microsoft", + "version": "23.0.0.0", + "name": "Library Assert" + }, + { + "id": "5095f467-0a01-4b99-99d1-9ff1237d286f", + "publisher": "Microsoft", + "version": "23.0.0.0", + "name": "Library Variable Storage" + }, + { + "id": "5d86850b-0d76-4eca-bd7b-951ad998e997", + "publisher": "Microsoft", + "version": "23.0.0.0", + "name": "Tests-TestLibraries" + }, + { + "id": "23de40a6-dfe8-4f80-80db-d70f83ce8caf", + "name": "Test Runner", + "publisher": "Microsoft", + "version": "23.0.0.0" + } + ], + "screenshots": [], + "platform": "1.0.0.0", + "application": "23.0.0.0", + "idRanges": [ + { + "from": 84100, + "to": 84149 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "runtime": "12.0", + "features": [ + "NoImplicitWith" + ] +} \ No newline at end of file diff --git a/Test/test/TestTPDisabled.Codeunit.al b/Test/test/TestTPDisabled.Codeunit.al new file mode 100644 index 0000000..9e5522c --- /dev/null +++ b/Test/test/TestTPDisabled.Codeunit.al @@ -0,0 +1,41 @@ +codeunit 84100 "Test TP Disabled FLX" +{ + Subtype = Test; + TestPermissions = Disabled; + + [Test] + procedure TestTestPermissionsDisabled() + begin + Initialize(); + + CreateTestTable(); + end; + + var + Any: Codeunit "Any"; + IsInitialized: Boolean; + + local procedure Initialize() + var + LibraryTestInitialize: Codeunit "Library - Test Initialize"; + begin + LibraryTestInitialize.OnTestInitialize(Codeunit::"Test TP Disabled FLX"); + + if IsInitialized then + exit; + + LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Test TP Disabled FLX"); + + IsInitialized := true; + + LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Test TP Disabled FLX"); + end; + + local procedure CreateTestTable() + var + TestTable: Record "Test Table FLX"; + begin + TestTable.Code := Any.AlphabeticText(MaxStrLen(TestTable.Code)); + TestTable.Insert(); + end; +} \ No newline at end of file diff --git a/Test/test/TestTPNonRestrictive.Codeunit.al b/Test/test/TestTPNonRestrictive.Codeunit.al new file mode 100644 index 0000000..8647b63 --- /dev/null +++ b/Test/test/TestTPNonRestrictive.Codeunit.al @@ -0,0 +1,44 @@ +codeunit 84102 "Test TP NonRestrictive FLX" +{ + Subtype = Test; + TestPermissions = NonRestrictive; + + [Test] + procedure TestTestPermissionsNonRestrictive() + begin + Initialize(); + + CreateTestTable(); + end; + + var + Any: Codeunit "Any"; + LibraryLowerTestPermissions: Codeunit "Library - Lower Permissions"; + IsInitialized: Boolean; + + local procedure Initialize() + var + LibraryTestInitialize: Codeunit "Library - Test Initialize"; + begin + LibraryTestInitialize.OnTestInitialize(Codeunit::"Test TP NonRestrictive FLX"); + + if IsInitialized then + exit; + + LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Test TP NonRestrictive FLX"); + + LibraryLowerTestPermissions.AddPermissionSet('Test Permissions FLX'); + + IsInitialized := true; + + LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Test TP NonRestrictive FLX"); + end; + + local procedure CreateTestTable() + var + TestTable: Record "Test Table FLX"; + begin + TestTable.Code := Any.AlphabeticText(MaxStrLen(TestTable.Code)); + TestTable.Insert(); + end; +} \ No newline at end of file diff --git a/Test/test/TestTPRestrictive.Codeunit.al b/Test/test/TestTPRestrictive.Codeunit.al new file mode 100644 index 0000000..31c1ca1 --- /dev/null +++ b/Test/test/TestTPRestrictive.Codeunit.al @@ -0,0 +1,44 @@ +codeunit 84101 "Test TP Restrictive FLX" +{ + Subtype = Test; + TestPermissions = Restrictive; + + [Test] + procedure TestTestPermissionsRestrictive() + begin + Initialize(); + + CreateTestTable(); + end; + + var + Any: Codeunit "Any"; + LibraryLowerTestPermissions: Codeunit "Library - Lower Permissions"; + IsInitialized: Boolean; + + local procedure Initialize() + var + LibraryTestInitialize: Codeunit "Library - Test Initialize"; + begin + LibraryTestInitialize.OnTestInitialize(Codeunit::"Test TP Restrictive FLX"); + + if IsInitialized then + exit; + + LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Test TP Restrictive FLX"); + + LibraryLowerTestPermissions.AddPermissionSet('Test Permissions FLX'); + + IsInitialized := true; + + LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Test TP Restrictive FLX"); + end; + + local procedure CreateTestTable() + var + TestTable: Record "Test Table FLX"; + begin + TestTable.Code := Any.AlphabeticText(MaxStrLen(TestTable.Code)); + TestTable.Insert(); + end; +} \ No newline at end of file diff --git a/al.code-workspace b/al.code-workspace index 0cd1af6..23995fb 100644 --- a/al.code-workspace +++ b/al.code-workspace @@ -2,7 +2,13 @@ "folders": [ { "path": ".AL-Go" - } + }, + { + "path": "./App" + }, + { + "path": "./Test" + } ], "settings": {} }