|
13 | 13 | Validation of the iosdk installation
|
14 | 14 | #>
|
15 | 15 |
|
16 |
| -if ($args[0] -eq $null) { |
| 16 | +$version = "2020.0805.1627-snapshot" |
| 17 | +if ($null -eq $args[0]) { |
17 | 18 | Write-Output "usage: validate.ps1 <version>"
|
18 | 19 | exit
|
19 |
| -} |
20 |
| - |
| 20 | +} |
21 | 21 | $version = $args[0]
|
22 | 22 |
|
23 |
| - |
24 | 23 | $file = "iosdk_$version.exe"
|
25 |
| - |
26 | 24 | $url = "https://github.com/pagopa/io-sdk/releases/download/$version/$file"
|
27 |
| - |
28 |
| -Write-Output $url |
29 |
| - |
30 | 25 | $outpath = "$env:TEMP/$file"
|
31 | 26 |
|
32 | 27 | 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 |
38 | 29 |
|
39 | 30 | $env:Path = [System.Environment]::GetEnvironmentVariable("Path","User")
|
40 | 31 |
|
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 |
43 | 36 | }
|
44 | 37 |
|
45 |
| -#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\IOSDK\iosdk.exe" -ArgumentList "init, $HOME/tmp-iosdk-validation, pagopa/io-sdk-javascript, --io-apikey=123456" |
46 | 38 | & "$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" |
47 | 40 |
|
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" |
52 | 41 | & "$env:ProgramFiles\IOSDK\iosdk.exe" "status"
|
53 | 42 |
|
54 |
| -#Start-Process -NoNewWindow -Wait -Filepath "$env:ProgramFiles\Docker\Docker\Resources\bin\docker.exe" -ArgumentList "exec, iosdk-theia, /home/project/build.sh" |
55 | 43 | & "docker" "exec" "iosdk-theia" "/home/project/build.sh"
|
56 | 44 |
|
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" |
59 | 50 |
|
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 |
62 | 52 |
|
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 | +} |
64 | 58 |
|
65 |
| -Start-Process -Filepath "$env:ProgramFiles/IOSDK/uninstall.exe" -ArgumentList $args -Verb RunAs -Wait |
| 59 | +Remove-Item -Recurse -Force "$HOME\tmp-iosdk-validation" |
66 | 60 |
|
| 61 | +& Start-Process -Filepath "$env:ProgramFiles/IOSDK/uninstall.exe" -ArgumentList @("/S") -Verb RunAs -Wait |
0 commit comments