Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1327 Reduce UAC prompts during setup and cleanup
Instead of running every single command from a powershell elevated session, and prompting the user for elevated access this runs one powershell script for each setup and cleanup procedure which has all the commands that are to be ran to install and remove the tray For setup/installation of the tray this includes - * Adding logon as service permission for the current user * Creating the daemon service and starting it * Adding the tray binary to startup folder and starting the system tray For removal of the tray this includes - * Remove logon as service permission from current user * Stop and delete the daemon service * Kill running tray and remove the binary from startup folder
- Loading branch information
1 parent
3b40b22
commit 09715c5
Showing
4 changed files
with
318 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package preflight | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/code-ready/crc/pkg/os/windows/powershell" | ||
) | ||
|
||
func TestEscapeWindowsPassword(t *testing.T) { | ||
passwords := []string{ | ||
"tes;t@\"_\\/", | ||
"$kdhhjs;%&*'`", | ||
"``````$''\"", | ||
} | ||
|
||
for _, pass := range passwords { | ||
op := escapeWindowsPassword(pass) | ||
psCmd := fmt.Sprintf("$var=\"%s\"; $var", op) | ||
stdOut, stdErr, err := powershell.Execute(psCmd) | ||
if err != nil { | ||
t.Errorf("Error while executing powershell command: %v: %v", err, stdErr) | ||
} | ||
if strings.TrimSpace(stdOut) != pass { | ||
t.Errorf("Passwords don't match after escaping for powershell. Expected: %s, Actual: %s", pass, stdOut) | ||
} | ||
} | ||
} |
Oops, something went wrong.