Skip to content

Commit

Permalink
Import PS Security module 3.0 before running a PS function
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciopoppe committed Oct 23, 2024
1 parent 07be14d commit 4bce68e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
name: Windows Tests
on: [push, pull_request]
jobs:
setup_powershell:
strategy:
matrix:
go: ['1.22']
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Run Windows Integration Tests
run: |
# required for running Volume and Disk tests
Install-WindowsFeature -name Hyper-V-PowerShell
# required for SMB test
# Get-PSRepository
# Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name SecMgmt -AllowClobber
$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;$secured;
integration_tests:
strategy:
matrix:
go: ['1.20']
go: ['1.22']
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -22,7 +39,7 @@ jobs:
run: |
# required for running Volume and Disk tests
Install-WindowsFeature -name Hyper-V-PowerShell
# start the CSI Proxy before running tests on windows
Start-Job -Name CSIProxy -ScriptBlock {
.\bin\csi-proxy.exe
Expand All @@ -31,11 +48,12 @@ jobs:
Write-Output "getting named pipes"
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
$env:CSI_PROXY_GH_ACTIONS="TRUE"
go test -timeout 20m -v -race ./integrationtests/...
go test -timeout 20m -v -race ./integrationtests/... -run "Smb"
unit_tests:
strategy:
matrix:
go: ['1.20']
go: ['1.22']
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -53,7 +71,7 @@ jobs:
bump_version_test:
strategy:
matrix:
go: ['1.20']
go: ['1.22']
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions integrationtests/smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func randomString(length int) string {
}

func setupUser(username, password string) error {
cmdLine := fmt.Sprintf(`$PWord = ConvertTo-SecureString $Env:password -AsPlainText -Force` +
cmdLine := fmt.Sprintf(`$env:PSModulePath=""; $PWord = ConvertTo-SecureString $Env:password -AsPlainText -Force` +
`;New-Localuser -name $Env:username -accountneverexpires -password $PWord`)
cmd := exec.Command("powershell", "/c", cmdLine)
cmd := exec.Command("powershell", "-NonInteractive", "-NoProfile", cmdLine)
cmd.Env = append(os.Environ(),
fmt.Sprintf("username=%s", username),
fmt.Sprintf("password=%s", password))
Expand Down

0 comments on commit 4bce68e

Please sign in to comment.