diff --git a/.github/scripts/agent_installer_test.ps1 b/.github/scripts/agent_installer_test.ps1 index a52b126550d..e864b849d66 100644 --- a/.github/scripts/agent_installer_test.ps1 +++ b/.github/scripts/agent_installer_test.ps1 @@ -18,9 +18,45 @@ # This script test CMA installer in silent mode +Set-PSDebug -Trace 2 + +function f_start_process([string]$sProcess, [string]$sArgs, [ref]$pOutPut) { + <# + .SYNOPSIS + Starts a new process with the specified executable and arguments. + + .DESCRIPTION + The `f_start_process` function initiates a new process using the provided executable path and arguments. + + .PARAMETER sProcess + The path to the executable file to start. + + .PARAMETER sArgs + The arguments to pass to the executable. + + .PARAMETER pOutPut + variable where we will store stdout and stderr + #> + $oProcessInfo = New-Object System.Diagnostics.ProcessStartInfo + $oProcessInfo.FileName = $sProcess + $oProcessInfo.RedirectStandardError = $true + $oProcessInfo.RedirectStandardOutput = $true + $oProcessInfo.UseShellExecute = $false + $oProcessInfo.Arguments = $sArgs + $oProcess = New-Object System.Diagnostics.Process + $oProcess.StartInfo = $oProcessInfo + $oProcess.Start() | Out-Null + $oProcess.WaitForExit() | Out-Null + $sSTDOUT = $oProcess.StandardOutput.ReadToEnd() + $sSTDERR = $oProcess.StandardError.ReadToEnd() + $pOutPut.Value = "Commandline: $sProcess $sArgs`r`n" + $pOutPut.Value += "STDOUT: " + $sSTDOUT + "`r`n" + $pOutPut.Value += "STDERR: " + $sSTDERR + "`r`n" + return $oProcess.ExitCode +} -function test_args_to_registry { -<# +function test_args_to_registry ([string] $exe_path, [string[]] $exe_args, $expected_registry_values) { + <# .SYNOPSIS start a program and check values in registry @@ -33,17 +69,13 @@ function test_args_to_registry { .PARAMETER expected_registry_values hash_table as @{'host'='host_1';'endpoint'='127.0.0.1'} #> - param ( - [string] $exe_path, - [string[]] $exe_args, - $expected_registry_values - ) - Write-Host "arguments: $exe_args" + Write-Host "execute $exe_path arguments: $exe_args" + + $process_output = @{} + $exit_code = f_start_process $exe_path $exe_args ([ref]$process_output) - $process_info= Start-Process -PassThru $exe_path $exe_args - $process_info.WaitForExit() - if ($process_info.ExitCode -ne 0) { + if ($exit_code -ne 0) { Write-Host "fail to execute $exe_path with arguments $exe_args" Write-Host "exit status = " $process_info.ExitCode exit 1 @@ -55,26 +87,46 @@ function test_args_to_registry { Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent break } - catch { + catch { + reg query HKLM\SOFTWARE\Centreon\CentreonMonitoringAgent /v host continue } } - foreach ($value_name in $expected_registry_values.Keys) { - $expected_value = $($expected_registry_values[$value_name]) - $real_value = (Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent -Name $value_name).$value_name - if ($expected_value -ne $real_value) { - Write-Host "unexpected value for $value_name, expected: $expected_value, read: $real_value" - exit 1 + for (($i = 0); $i -lt 10; $i++) { + Start-Sleep -Seconds 1 + $read_success = 1 + foreach ($value_name in $expected_registry_values.Keys) { + $expected_value = $($expected_registry_values[$value_name]) + try { + $real_value = (Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent -Name $value_name).$value_name + if ($expected_value -ne $real_value) { + Write-Host "unexpected value for $value_name, expected: $expected_value, read: $real_value" + $read_success = 0 + break + } + } + catch { + $read_success = 0 + break + } } + if ($read_success -eq 1) { + break + } + } + + if ($read_success -ne 1) { + Write-Host "fail to read expected registry values in 10s installer output: $process_output" + exit 1 } } Write-Host "############################ all install uninstall ############################" -$args = '/S','--install_cma', '--install_plugins', '--hostname', "my_host_name_1", "--endpoint","127.0.0.1:4317" -$expected = @{ 'endpoint'='127.0.0.1:4317';'host'='my_host_name_1';'log_type'='EventLog'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0 } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--install_plugins', '--hostname', "my_host_name_1", "--endpoint", "127.0.0.1:4317" +$expected = @{ 'endpoint' = '127.0.0.1:4317'; 'host' = 'my_host_name_1'; 'log_type' = 'EventLog'; 'log_level' = 'error'; 'encryption' = 0; 'reversed_grpc_streaming' = 0 } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected if (!(Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent)) { Write-Host "no registry entry created" @@ -96,7 +148,7 @@ if (![System.Io.File]::Exists("C:\Program Files\Centreon\Plugins\centreon_plugin exit 1 } -$process_info= Start-Process -PassThru "C:\Program Files\Centreon\CentreonMonitoringAgent\uninstall.exe" "/S", "--uninstall_cma","--uninstall_plugins" +$process_info = Start-Process -PassThru "C:\Program Files\Centreon\CentreonMonitoringAgent\uninstall.exe" "/S", "--uninstall_cma", "--uninstall_plugins" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 0) { Write-Host "bad uninstaller exit code" @@ -107,7 +159,7 @@ if ($process_info.ExitCode -ne 0) { for (($i = 0); $i -lt 10; $i++) { Start-Sleep -Seconds 1 $info = Get-Process | Select-Object -Property ProcessName | Select-String centagent - if (! $info) { + if (! $info) { break } } @@ -141,14 +193,14 @@ if ($key_found) { Write-Host "############################ installer test ############################" -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--help" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--help" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 2) { Write-Host "bad --help exit code" exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--version" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--version" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 2) { Write-Host "bad --version exit code" @@ -156,70 +208,70 @@ if ($process_info.ExitCode -ne 2) { } #missing mandatory parameters -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad no parameter exit code " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad no endpoint exit code " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","turlututu" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "turlututu" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad wrong endpoint exit code " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_type","file" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--log_type", "file" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad no log file path " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_type","file","--log_file","C:" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--log_type", "file", "--log_file", "C:" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad log file path " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_level","dsfsfd" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--log_level", "dsfsfd" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "bad log level " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--reverse", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--encryption" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "reverse mode, encryption and no private_key " $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--reverse", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--encryption", "--private_key", "C:" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "reverse mode, encryption and bad private_key path" $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:\Users\Public\private_key.key" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--reverse", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--encryption", "--private_key", "C:\Users\Public\private_key.key" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "reverse mode, encryption and no certificate" $process_info.ExitCode exit 1 } -$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:\Users\Public\private_key.key", "--public_cert", "C:" +$process_info = Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma", "--hostname", "toto", "--endpoint", "127.0.0.1:4317", "--reverse", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--encryption", "--private_key", "C:\Users\Public\private_key.key", "--public_cert", "C:" Wait-Process -Id $process_info.Id if ($process_info.ExitCode -ne 1) { Write-Host "reverse mode, encryption and bad certificate path" $process_info.ExitCode @@ -227,52 +279,52 @@ if ($process_info.ExitCode -ne 1) { } -$args = '/S','--install_cma','--hostname', "my_host_name_1", "--endpoint","127.0.0.1:4317" -$expected = @{ 'endpoint'='127.0.0.1:4317';'host'='my_host_name_1';'log_type'='EventLog'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0 } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_1", "--endpoint", "127.0.0.1:4317" +$expected = @{ 'endpoint' = '127.0.0.1:4317'; 'host' = 'my_host_name_1'; 'log_type' = 'EventLog'; 'log_level' = 'error'; 'encryption' = 0; 'reversed_grpc_streaming' = 0 } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected -$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.2:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--log_max_file_size", "15", "--log_max_files", "10" -$expected = @{ 'endpoint'='127.0.0.2:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 0;'reversed_grpc_streaming'= 0; 'log_max_file_size' = 15; 'log_max_files' = 10; } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.2:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--log_max_file_size", "15", "--log_max_files", "10" +$expected = @{ 'endpoint' = '127.0.0.2:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma.log'; 'encryption' = 0; 'reversed_grpc_streaming' = 0; 'log_max_file_size' = 15; 'log_max_files' = 10; } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected -$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.3:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption" -$expected = @{ 'endpoint'='127.0.0.3:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0 } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.3:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption" +$expected = @{ 'endpoint' = '127.0.0.3:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0 } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected -$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.4:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption", "--private_key", "C:\Users crypto\private.key", "--public_cert", "D:\tutu\titi.crt", "--ca", "C:\Users\Public\ca.crt", "--ca_name", "tls_ca_name" -$expected = @{ 'endpoint'='127.0.0.4:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi.crt'; 'private_key'='C:\Users crypto\private.key'; 'ca_certificate' = 'C:\Users\Public\ca.crt'; 'ca_name' = 'tls_ca_name' } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.4:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption", "--private_key", "C:\Users crypto\private.key", "--public_cert", "D:\tutu\titi.crt", "--ca", "C:\Users\Public\ca.crt", "--ca_name", "tls_ca_name" +$expected = @{ 'endpoint' = '127.0.0.4:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi.crt'; 'private_key' = 'C:\Users crypto\private.key'; 'ca_certificate' = 'C:\Users\Public\ca.crt'; 'ca_name' = 'tls_ca_name' } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected -$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.5:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev.log", "--log_level", "trace", "--encryption", "--reverse", "--private_key", "C:\Users crypto\private_rev.key", "--public_cert", "D:\tutu\titi_rev.crt", "--ca", "C:\Users\Public\ca_rev.crt", "--ca_name", "tls_ca_name_rev" -$expected = @{ 'endpoint'='127.0.0.5:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma_rev.log'; 'encryption' = 1;'reversed_grpc_streaming'= 1; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } -test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected +$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.5:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev.log", "--log_level", "trace", "--encryption", "--reverse", "--private_key", "C:\Users crypto\private_rev.key", "--public_cert", "D:\tutu\titi_rev.crt", "--ca", "C:\Users\Public\ca_rev.crt", "--ca_name", "tls_ca_name_rev" +$expected = @{ 'endpoint' = '127.0.0.5:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 1; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } +test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected Write-Host "############################ modifier test ############################" -$args = '/S','--hostname', "my_host_name_10", "--endpoint","127.0.0.10:4317", "--no_reverse" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma_rev.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', '--hostname', "my_host_name_10", "--endpoint", "127.0.0.10:4317", "--no_reverse" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected -$args = '/S',"--log_type", "file", "--log_file", "C:\Users\Public\cma_rev2.log", "--log_level", "debug", "--log_max_file_size", "50", "--log_max_files", "20" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='File'; 'log_level' = 'debug'; 'log_file'='C:\Users\Public\cma_rev2.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'log_max_file_size' = 50; 'log_max_files' = 20;'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev2.log", "--log_level", "debug", "--log_max_file_size", "50", "--log_max_files", "20" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'debug'; 'log_file' = 'C:\Users\Public\cma_rev2.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'log_max_file_size' = 50; 'log_max_files' = 20; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected -$args = '/S',"--log_type", "EventLog", "--log_level", "error" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', "--log_type", "EventLog", "--log_level", "error" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected -$args = '/S',"--private_key", "C:\Users crypto\private_rev2.key", "--public_cert", "D:\tutu\titi_rev2.crt" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', "--private_key", "C:\Users crypto\private_rev2.key", "--public_cert", "D:\tutu\titi_rev2.crt" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected -$args = '/S',"--ca", "C:\Users\Public\ca_rev2.crt", "--ca_name", "tls_ca_name_rev2" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', "--ca", "C:\Users\Public\ca_rev2.crt", "--ca_name", "tls_ca_name_rev2" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected -$args = '/S',"--no_encryption" -$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' } -test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected +$exe_args = '/S', "--no_encryption" +$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 0; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' } +test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected diff --git a/agent/installer/silent.nsi b/agent/installer/silent.nsi index 1ac6a4e43f1..42048eb1603 100644 --- a/agent/installer/silent.nsi +++ b/agent/installer/silent.nsi @@ -125,6 +125,11 @@ Function cmd_line_to_registry Call silent_fatal_error ${EndIf} WriteRegStr HKLM ${CMA_REG_KEY} "host" "$0" + ${If} ${Errors} + StrCpy $1 "Failed to write registry key for host" + Call silent_fatal_error + ${EndIf} + ClearErrors ${GetOptions} $cmdline_parameters "--endpoint" $0 ${If} ${Errors} @@ -474,4 +479,4 @@ Function un.silent_verify_admin SetErrorLevel 1 Quit ${EndIf} -FunctionEnd \ No newline at end of file +FunctionEnd