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 1795003
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
42 changes: 33 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
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
shell: powershell
run: |
# required for running Volume and Disk tests
Install-WindowsFeature -name Hyper-V-PowerShell
$PSVersionTable
# 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 @@ -15,27 +34,32 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Build
shell: powershell
run: |
go build -v -a -o ./bin/csi-proxy.exe ./cmd/csi-proxy
go build -v -a -o ./bin/csi-proxy-api-gen.exe ./cmd/csi-proxy-api-gen
- name: Run Windows Integration Tests
shell: powershell
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
};
Start-Sleep -Seconds 30;
$flags = "-windows-service -log_file=.\csi-proxy.log -logtostderr=false"
& sc.exe create csiproxy binPath= ".\bin\csi-proxy.exe $flags"
& sc.exe failure csiproxy reset= 0 actions= restart/10000
& sc.exe start csiproxy
Start-Sleep -Seconds 10;
Write-Output "getting named pipes"
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
cat .\csi-proxy.log
$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 +77,7 @@ jobs:
bump_version_test:
strategy:
matrix:
go: ['1.20']
go: ['1.22']
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func randomString(length int) string {
func setupUser(username, password string) error {
cmdLine := fmt.Sprintf(`$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 1795003

Please sign in to comment.