Skip to content

Commit 5193c9c

Browse files
committed
Import PS Security module 3.0 before running a PS function
1 parent 07be14d commit 5193c9c

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

.github/workflows/windows.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
name: Windows Tests
22
on: [push, pull_request]
33
jobs:
4+
setup_powershell:
5+
strategy:
6+
matrix:
7+
go: ['1.22']
8+
platform: [windows-latest]
9+
runs-on: ${{ matrix.platform }}
10+
steps:
11+
- name: Run Windows Integration Tests
12+
run: |
13+
# required for running Volume and Disk tests
14+
Install-WindowsFeature -name Hyper-V-PowerShell
15+
# required for SMB test
16+
# Get-PSRepository
17+
# Set-PSRepository PSGallery -InstallationPolicy Trusted
18+
Install-Module -Name SecMgmt -AllowClobber
19+
$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;$secured;
20+
421
integration_tests:
522
strategy:
623
matrix:
7-
go: ['1.20']
24+
go: ['1.22']
825
platform: [windows-latest]
926
runs-on: ${{ matrix.platform }}
1027
steps:
@@ -22,7 +39,10 @@ jobs:
2239
run: |
2340
# required for running Volume and Disk tests
2441
Install-WindowsFeature -name Hyper-V-PowerShell
25-
42+
# required for SMB test
43+
Set-PSRepository PSGallery -InstallationPolicy Trusted
44+
Install-Module -Name SecMgmt -AllowClobber
45+
2646
# start the CSI Proxy before running tests on windows
2747
Start-Job -Name CSIProxy -ScriptBlock {
2848
.\bin\csi-proxy.exe
@@ -31,11 +51,12 @@ jobs:
3151
Write-Output "getting named pipes"
3252
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
3353
$env:CSI_PROXY_GH_ACTIONS="TRUE"
34-
go test -timeout 20m -v -race ./integrationtests/...
54+
55+
go test -timeout 20m -v -race ./integrationtests/... -run "Smb"
3556
unit_tests:
3657
strategy:
3758
matrix:
38-
go: ['1.20']
59+
go: ['1.22']
3960
platform: [windows-latest]
4061
runs-on: ${{ matrix.platform }}
4162
steps:
@@ -53,7 +74,7 @@ jobs:
5374
bump_version_test:
5475
strategy:
5576
matrix:
56-
go: ['1.20']
77+
go: ['1.22']
5778
platform: [ubuntu-latest]
5879
runs-on: ${{ matrix.platform }}
5980
steps:

integrationtests/smb_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func randomString(length int) string {
3030
}
3131

3232
func setupUser(username, password string) error {
33-
cmdLine := fmt.Sprintf(`$PWord = ConvertTo-SecureString $Env:password -AsPlainText -Force` +
34-
`;New-Localuser -name $Env:username -accountneverexpires -password $PWord`)
33+
cmdLine := fmt.Sprintf(`& {$PWord = ConvertTo-SecureString $Env:password -AsPlainText -Force` +
34+
`;New-Localuser -name $Env:username -accountneverexpires -password $PWord}`)
3535
cmd := exec.Command("powershell", "/c", cmdLine)
3636
cmd.Env = append(os.Environ(),
3737
fmt.Sprintf("username=%s", username),

0 commit comments

Comments
 (0)