Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit f77a36a

Browse files
udpdated validate in powershell
1 parent d18074d commit f77a36a

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

validate.ps1

+22-27
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,49 @@
1313
Validation of the iosdk installation
1414
#>
1515

16-
if ($args[0] -eq $null) {
16+
$version = "2020.0805.1627-snapshot"
17+
if ($null -eq $args[0]) {
1718
Write-Output "usage: validate.ps1 <version>"
1819
exit
19-
}
20-
20+
}
2121
$version = $args[0]
2222

23-
2423
$file = "iosdk_$version.exe"
25-
2624
$url = "https://github.com/pagopa/io-sdk/releases/download/$version/$file"
27-
28-
Write-Output $url
29-
3025
$outpath = "$env:TEMP/$file"
3126

3227
Invoke-WebRequest -Uri $url -OutFile $outpath
33-
34-
$args = @("/S")
35-
Start-Process -Filepath "$outpath" -ArgumentList $args -Verb RunAs
36-
37-
#Start-Sleep -s 5
28+
Start-Process -Filepath "$outpath" -ArgumentList @("/S") -Verb RunAs
3829

3930
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User")
4031

41-
if (Write-Output $env:Path | Select-String -Pattern iosdk) {
42-
Write-Output "PATH OK"
32+
if (! (Write-Output $env:Path | Select-String -Pattern iosdk)) {
33+
Write-Output "PATH not set properly"
34+
Write-Output "FAIL"
35+
exit
4336
}
4437

45-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "init, $HOME/tmp-iosdk-validation, pagopa/io-sdk-javascript, --io-apikey=123456"
4638
& "$env:ProgramFiles\IOSDK\iosdk.exe" "init" "$HOME/tmp-iosdk-validation" "pagopa/io-sdk-javascript" "--io-apikey=123456"
39+
& "$env:ProgramFiles\IOSDK\iosdk.exe" "start" "--skip-open-browser"
4740

48-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "start"
49-
& "$env:ProgramFiles\IOSDK\iosdk.exe" "start"
50-
51-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "status"
5241
& "$env:ProgramFiles\IOSDK\iosdk.exe" "status"
5342

54-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\Docker\Docker\Resources\bin\docker.exe" -ArgumentList "exec, iosdk-theia, /home/project/build.sh"
5543
& "docker" "exec" "iosdk-theia" "/home/project/build.sh"
5644

57-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "status"
58-
& "$env:ProgramFiles\IOSDK\iosdk.exe" "status"
45+
$dataFile = "$HOME/tmp-iosdk-validation/data/data.xlsx"
46+
$bytes = [System.IO.File]::ReadAllBytes($dataFile)
47+
$encoded = [System.Convert]::ToBase64String($bytes)
48+
$testJson = "{`"file`": `"'$encoded`"}"
49+
$testUrl = "http://localhost:3280/api/v1/web/guest/iosdk/import"
5950

60-
#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "stop"
61-
& "$env:ProgramFiles\IOSDK\iosdk.exe" "stop"
51+
$out = Invoke-RestMethod -Uri $testUrl -Method Post -ContentType "application/json" -Body $testJson
6252

63-
Remove-Item -Recurse -Force "$HOME\tmp-iosdk-validation"
53+
if($out.data[0].fiscal_code -eq "ISPXNB32R82Y766F") {
54+
Write-Output "SUCCESS"
55+
} else {
56+
Write-Output "FAIL"
57+
}
6458

65-
Start-Process -Filepath "$env:ProgramFiles/IOSDK/uninstall.exe" -ArgumentList $args -Verb RunAs -Wait
59+
Remove-Item -Recurse -Force "$HOME\tmp-iosdk-validation"
6660

61+
& Start-Process -Filepath "$env:ProgramFiles/IOSDK/uninstall.exe" -ArgumentList @("/S") -Verb RunAs -Wait

0 commit comments

Comments
 (0)