From 7703b2f5c4a25df44920c3ee637280e26ee81108 Mon Sep 17 00:00:00 2001 From: Davi Henrique Date: Mon, 16 Sep 2024 12:20:21 -0300 Subject: [PATCH] [Added] Tests for registry.pol spelling cases Signed-off-by: Davi Henrique --- internal/ad/ad_test.go | 22 +++++++++++++++++- .../Policies/lowercase-registry/GPT.INI | 3 +++ .../lowercase-registry/Machine/registry.pol | Bin 0 -> 350 bytes .../lowercase-registry/User/registry.pol | Bin 0 -> 350 bytes .../Policies/mixedcase-registry/GPT.INI | 3 +++ .../mixedcase-registry/Machine/reGIStry.pol | Bin 0 -> 350 bytes .../mixedcase-registry/User/reGIStry.pol | Bin 0 -> 350 bytes 7 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/GPT.INI create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/Machine/registry.pol create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/User/registry.pol create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/mixedcase-registry/GPT.INI create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/mixedcase-registry/Machine/reGIStry.pol create mode 100644 internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/mixedcase-registry/User/reGIStry.pol diff --git a/internal/ad/ad_test.go b/internal/ad/ad_test.go index 14ee83e84..d6ebd5038 100644 --- a/internal/ad/ad_test.go +++ b/internal/ad/ad_test.go @@ -424,7 +424,7 @@ func TestGetPolicies(t *testing.T) { }}, }, - // Policy class directory spelling cases + // Policy class directory and Registry.pol spelling cases "Policy user directory is uppercase": { gpoListArgs: []string{"gpoonly.com", "bob:uppercase-class"}, want: policies.Policies{GPOs: []policies.GPO{standardUserGPO("uppercase-class")}}, @@ -450,6 +450,26 @@ func TestGetPolicies(t *testing.T) { {ID: "lowercase-class", Name: "lowercase-class-name", Rules: map[string][]entry.Entry{}}}, }, }, + "User policy Registry.pol is lower case": { + gpoListArgs: []string{"gpoonly.com", "bob:lowercase-registry"}, + want: policies.Policies{GPOs: []policies.GPO{standardUserGPO("lowercase-registry")}}, + }, + "Computer policy Registry.pol is lower case": { + objectName: hostname, + objectClass: ad.ComputerObject, + gpoListArgs: []string{"gpoonly.com", hostname + ":lowercase-registry"}, + want: policies.Policies{GPOs: []policies.GPO{standardComputerGPO("lowercase-registry")}}, + }, + "User policy Registry.pol is mixed case": { + gpoListArgs: []string{"gpoonly.com", "bob:mixedcase-registry"}, + want: policies.Policies{GPOs: []policies.GPO{standardUserGPO("mixedcase-registry")}}, + }, + "Computer policy Registry.pol is mixed case": { + objectName: hostname, + objectClass: ad.ComputerObject, + gpoListArgs: []string{"gpoonly.com", hostname + ":mixedcase-registry"}, + want: policies.Policies{GPOs: []policies.GPO{standardComputerGPO("mixedcase-registry")}}, + }, // Error cases "Machine doesn’t match": { diff --git a/internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/GPT.INI b/internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/GPT.INI new file mode 100644 index 000000000..c5498a917 --- /dev/null +++ b/internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/GPT.INI @@ -0,0 +1,3 @@ +[General] +Version=1000 +displayName=New Group Policy Object diff --git a/internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/Machine/registry.pol b/internal/ad/testdata/AD/SYSVOL/gpoonly.com/Policies/lowercase-registry/Machine/registry.pol new file mode 100644 index 0000000000000000000000000000000000000000..3b1e3b69db3764697f840f687c5665cd227c382b GIT binary patch literal 350 zcmbu2OA3H63`C!I@HSlux);TjcA>V4APRo)`c8WTk&uwj%S>7MIRRQ~b|x+!dJa4t zr8X-IqtbI~(=c$eiMlm8U3N{A`b-)|pQ|EtLDP`NdW!GGxv1V4APRo)`c8WTk&uwj%S>7MIRRQ~b|x+!dJa4t zr8X-IqtbI~(=c$eiMlm8U3N{A`b-)|pQ|EtLDP`NdW!GGxv1