From b9997f0343c399461263b1f2442305a3a22579ab Mon Sep 17 00:00:00 2001 From: Eric Promislow Date: Wed, 21 Jun 2023 14:17:16 -0700 Subject: [PATCH] Correct the registry key name from 'Profiles' to 'Policies'. Signed-off-by: Eric Promislow --- .../preferences/list-settings-output.bats | 58 ++++++++++--------- src/go/rdctl/pkg/reg/reg.go | 6 +- src/go/rdctl/pkg/reg/reg_test.go | 32 +++++----- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/bats/tests/preferences/list-settings-output.bats b/bats/tests/preferences/list-settings-output.bats index 43cf14cfe8f..59a1fbb8370 100644 --- a/bats/tests/preferences/list-settings-output.bats +++ b/bats/tests/preferences/list-settings-output.bats @@ -58,7 +58,7 @@ RD_USE_IMAGE_ALLOW_LIST=true for option in reg reg,hklm reg,hklm,defaults reg,defaults; do run rdctl list-settings --output "$option" assert_success - assert_output --partial '[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application]' + assert_output --partial '[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application]' done } @@ -66,7 +66,7 @@ RD_USE_IMAGE_ALLOW_LIST=true for option in reg,hklm,locked reg,locked; do run rdctl list-settings --output "$option" assert_success - assert_output --partial '[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\locked\application]' + assert_output --partial '[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\locked\application]' done } @@ -74,14 +74,14 @@ RD_USE_IMAGE_ALLOW_LIST=true for option in reg,hkcu,defaults reg,hkcu; do run rdctl list-settings --output "$option" assert_success - assert_output --partial '[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\application]' + assert_output --partial '[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\application]' done } @test 'generates registry output for hkcu/locked' { run rdctl list-settings --output reg,hkcu,locked assert_success - assert_output --partial '[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\locked\application]' + assert_output --partial '[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\locked\application]' } # The result of the `assert_output` for heredocuments looks suspicious (I see it always passing), @@ -92,14 +92,14 @@ RD_USE_IMAGE_ALLOW_LIST=true assert_output <<'EOF' Windows Registry Editor Version 5.00 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies] -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop] -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults] "version"=dword:8 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application] "adminAccess"=dword:0 "debug"=dword:0 "pathManagementStrategy"="rcfiles" @@ -107,76 +107,80 @@ Windows Registry Editor Version 5.00 "startInBackground"=dword:0 "hideNotificationIcon"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application\extensions] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application\extensions] -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application\extensions\allowed] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application\extensions\allowed] "enabled"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application\telemetry] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application\telemetry] "enabled"=dword:1 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application\updater] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application\updater] "enabled"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\application\window] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\application\window] "quitOnClose"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\containerEngine] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\containerEngine] "name"="moby" -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\containerEngine\allowedImages] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\containerEngine\allowedImages] "enabled"=dword:1 "patterns"=hex(7):66,00,69,00,73,00,68,00,00,00,73,00,68,00,65,00,65,00,70,00,00,00,63,00,6f,00,77,00,73,00,00,00,00,00 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\virtualMachine] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\virtualMachine] "memoryInGB"=dword:4 "numberCPUs"=dword:2 "hostResolver"=dword:1 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\kubernetes] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\kubernetes] "version"="1.25.9" "port"=dword:192b "enabled"=dword:1 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\kubernetes\options] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\kubernetes\options] "traefik"=dword:1 "flannel"=dword:1 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\kubernetes\ingress] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\kubernetes\ingress] "localhostOnly"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\experimental] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\experimental] -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\experimental\virtualMachine] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\experimental\virtualMachine] "socketVMNet"=dword:0 "networkingTunnel"=dword:0 "type"="qemu" "useRosetta"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\experimental\virtualMachine\mount] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\experimental\virtualMachine\mount] "type"="reverse-sshfs" -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\experimental\virtualMachine\mount\9p] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\experimental\virtualMachine\mount\9p] "securityModel"="none" "protocolVersion"="9p2000.L" "msizeInKib"=dword:80 "cacheMode"="mmap" -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\experimental\virtualMachine\proxy] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\experimental\virtualMachine\proxy] "enabled"=dword:0 "address"="" "password"="" "port"=dword:c38 "username"="" -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\portForwarding] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\portForwarding] "includeKubernetesServices"=dword:0 -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\images] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\images] "showAll"=dword:1 "namespace"="k8s.io" -[HKEY_LOCAL_MACHINE\SOFTWARE\Profiles\Rancher Desktop\defaults\diagnostics] +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Rancher Desktop\defaults\diagnostics] "showMuted"=dword:0 EOF } + +@test 'needs a shutdown' { + rdctl shutdown +} diff --git a/src/go/rdctl/pkg/reg/reg.go b/src/go/rdctl/pkg/reg/reg.go index 5dd52a714a3..0b67f0747b7 100644 --- a/src/go/rdctl/pkg/reg/reg.go +++ b/src/go/rdctl/pkg/reg/reg.go @@ -148,13 +148,13 @@ func JsonToReg(hiveType string, profileType string, settingsBodyAsJSON string) ( return nil, fmt.Errorf("error in json: %s\n", err) } headerLines := []string{"Windows Registry Editor Version 5.00"} - bodyLines, _, err := convertToRegFormat([]string{fullHiveType, "SOFTWARE", "Profiles", "Rancher Desktop", profileType}, reflect.ValueOf(settings), "") + bodyLines, _, err := convertToRegFormat([]string{fullHiveType, "SOFTWARE", "Policies", "Rancher Desktop", profileType}, reflect.ValueOf(settings), "") if err != nil { return nil, err } if len(bodyLines) > 0 { - headerLines = append(headerLines, "", fmt.Sprintf("[%s\\%s\\%s]", fullHiveType, "SOFTWARE", "Profiles")) - headerLines = append(headerLines, "", fmt.Sprintf("[%s\\%s\\%s\\%s]", fullHiveType, "SOFTWARE", "Profiles", "Rancher Desktop")) + headerLines = append(headerLines, "", fmt.Sprintf("[%s\\%s\\%s]", fullHiveType, "SOFTWARE", "Policies")) + headerLines = append(headerLines, "", fmt.Sprintf("[%s\\%s\\%s\\%s]", fullHiveType, "SOFTWARE", "Policies", "Rancher Desktop")) } return append(headerLines, bodyLines...), nil } diff --git a/src/go/rdctl/pkg/reg/reg_test.go b/src/go/rdctl/pkg/reg/reg_test.go index 274750159f3..c10cfe74863 100644 --- a/src/go/rdctl/pkg/reg/reg_test.go +++ b/src/go/rdctl/pkg/reg/reg_test.go @@ -59,22 +59,22 @@ func TestJsonToRegFormat(t *testing.T) { { hiveType: "hkcu", profileType: "defaults", - expectedHeader: "HKEY_CURRENT_USER\\SOFTWARE\\Profiles\\Rancher Desktop\\defaults", + expectedHeader: "HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Rancher Desktop\\defaults", }, { hiveType: "hklm", profileType: "defaults", - expectedHeader: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Profiles\\Rancher Desktop\\defaults", + expectedHeader: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Rancher Desktop\\defaults", }, { hiveType: "hkcu", profileType: "locked", - expectedHeader: "HKEY_CURRENT_USER\\SOFTWARE\\Profiles\\Rancher Desktop\\locked", + expectedHeader: "HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Rancher Desktop\\locked", }, { hiveType: "hklm", profileType: "locked", - expectedHeader: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Profiles\\Rancher Desktop\\locked", + expectedHeader: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Rancher Desktop\\locked", }, } jsonBody := `{"version": 19, "application": { "pathManagementStrategy": "manual" } }` @@ -98,7 +98,7 @@ func TestJsonToRegFormat(t *testing.T) { "enabled": false, "list": ["wink", "blink", "pokinkleblink"] } } }, "containerEngine": { "name": "beatrice" }}` - header := "HKEY_CURRENT_USER\\SOFTWARE\\Profiles\\Rancher Desktop\\defaults" + header := "HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Rancher Desktop\\defaults" lines, err := JsonToReg("hkcu", "defaults", jsonBody) assert.NoError(t, err) //assert.Equal(t, []string{}, lines) @@ -126,7 +126,7 @@ func TestJsonToRegFormat(t *testing.T) { } } }` - header := "HKEY_CURRENT_USER\\SOFTWARE\\Profiles\\Rancher Desktop\\defaults" + header := "HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Rancher Desktop\\defaults" lines, err := JsonToReg("hkcu", "defaults", jsonBody) assert.NoError(t, err) //assert.Equal(t, []string{}, lines) @@ -167,37 +167,37 @@ func TestJsonToRegFormat(t *testing.T) { "name": "moby" } }` - header := "HKEY_CURRENT_USER\\SOFTWARE\\Profiles\\Rancher Desktop\\defaults" + header := "HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Rancher Desktop\\defaults" lines, err := JsonToReg("hkcu", "defaults", jsonBody) assert.NoError(t, err) expectedLines := []string{ `Windows Registry Editor Version 5.00`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies]`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop]`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults]`, `"version"=dword:8`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\application]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\application]`, `"adminAccess"=dword:0`, `"pathManagementStrategy"="manual"`, `"autoStart"=dword:0`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\application\extensions]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\application\extensions]`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\application\extensions\allowed]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\application\extensions\allowed]`, `"enabled"=dword:0`, `"list"=hex(7):66,00,6f,00,75,00,6e,00,64,00,00,00,66,00,75,00,6c,00,6c,00,79,00,00,00,62,00,61,00,77,00,64,00,79,00,00,00,74,00,61,00,72,00,6f,00,74,00,00,00,00,00`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\application\updater]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\application\updater]`, `"enabled"=dword:0`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\containerEngine]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\containerEngine]`, `"name"="moby"`, ``, - `[HKEY_CURRENT_USER\SOFTWARE\Profiles\Rancher Desktop\defaults\containerEngine\allowedImages]`, + `[HKEY_CURRENT_USER\SOFTWARE\Policies\Rancher Desktop\defaults\containerEngine\allowedImages]`, `"enabled"=dword:0`, `"patterns"=hex(7):66,00,61,00,62,00,6c,00,65,00,00,00,74,00,68,00,65,00,72,00,65,00,00,00,63,00,72,00,61,00,7a,00,79,00,00,00,77,00,68,00,69,00,6e,00,65,00,00,00,00,00`, }