mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
merged develop into markdown
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -283,9 +283,6 @@ Installer Projects/Installer/Fragments/HelpFilesFragment.wxs
|
||||
InstallerProjects/Installer/Fragments/FilesFragment.wxs
|
||||
InstallerProjects/Installer/Resources/License.rtf
|
||||
|
||||
# user preference: .editorconfig - http://editorconfig.org/
|
||||
.editorconfig
|
||||
|
||||
# gh-pages info
|
||||
runlocal.bat
|
||||
/_site
|
||||
@@ -110,21 +110,6 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Portable|x86' ">
|
||||
<DefineConstants>HarvestPath=$(SolutionDir)mRemoteV1\bin\Release Portable;HelpFilesHarvestPath=$(SolutionDir)mRemoteV1\Resources\Help</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>:: When passing paths to powershell scripts, check if the path ends with a backslash "\"
|
||||
:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
|
||||
|
||||
powershell -noprofile -command "sleep 2"
|
||||
set /p buildenv=<buildenv.tmp
|
||||
set solutionDir=$(SolutionDir)\
|
||||
set targetDir=%25cd%25
|
||||
set psScriptsDir=$(SolutionDir)Tools
|
||||
set certPath=$(CertPath)
|
||||
set certPassword=$(CertPassword)
|
||||
|
||||
:: Call the post build powershell script
|
||||
powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_installer.ps1" -SolutionDir "%25solutionDir%25" -TargetDir "%25targetDir%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "%25certPath%25" -CertificatePassword "%25certPassword%25"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>REM Clean the TargetDir
|
||||
rmdir /S /Q "$(TargetDir)"
|
||||
@@ -137,4 +122,18 @@ REM Harvest bin directory of the mRemoteV1 project
|
||||
REM Convert the license file "COPYING.TXT" to "License.rtf" to be shown in the installer GUI
|
||||
"$(ProjectDir)Resources\Pandoc\pandoc.exe" -s -t rtf -o "$(ProjectDir)\Resources\License.rtf" "$(SolutionDir)COPYING.TXT"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>:: When passing paths to powershell scripts, check if the path ends with a backslash "\"
|
||||
:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
|
||||
|
||||
powershell -noprofile -command "sleep 2"
|
||||
|
||||
set /p buildenv=<buildenv.tmp
|
||||
|
||||
:: Manual builds, set the cert password and uncomment below.
|
||||
:: IF "%25APPVEYOR_BUILD_FOLDER"=="" ( set cert_pwd= )
|
||||
|
||||
:: Call the post build powershell script
|
||||
powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)Tools\postbuild_installer.ps1" -SolutionDir "$(SolutionDir)\" -TargetDir "%25cd%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "$(CertPath)" -CertificatePassword "%25cert_pwd%25" -ExcludeFromSigning "PuTTYNG.exe"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
12
README.MD
12
README.MD
@@ -4,15 +4,15 @@
|
||||
[](https://gitter.im/mRemoteNG/PublicChat)
|
||||
[](https://www.paypal.me/DavidSparer)
|
||||
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/529)
|
||||
[](https://github.com/mRemoteNG/mRemoteNG/releases/)
|
||||
|
||||
[](https://waffle.io/mRemoteNG/mRemoteNG)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/529)
|
||||
|
||||
| Update Channel | Build Status | Downloads |
|
||||
| ---------------|--------------|-----------|
|
||||
| Stable | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.11) |
|
||||
| Beta | | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.12) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.12) |
|
||||
| Stable | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.15) |
|
||||
| Beta | | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.15) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76.15) |
|
||||
|
||||
mRemoteNG is the next generation of mRemote, a full-featured, multi-tab remote connections manager.
|
||||
|
||||
@@ -54,6 +54,6 @@ If you find mRemoteNG useful and would like to contribute, it would be greatly a
|
||||
Check out the [Wiki page](https://github.com/mRemoteNG/mRemoteNG/wiki/Development) on how to configure your development environment and submit a pull request.
|
||||
|
||||
### Translate
|
||||
Check out the [Wiki page](https://github.com/mRemoteNG/mRemoteNG/wiki/How%20to%20Help%20Translating%20mRemoteNG) on how to help make mRemoteNG a polygot
|
||||
Check out the [Wiki page](https://github.com/mRemoteNG/mRemoteNG/wiki/How%20to%20Help%20Translating%20mRemoteNG) on how to help make mRemoteNG a polyglot
|
||||
|
||||
[](https://www.jetbrains.com/resharper/)
|
||||
|
||||
@@ -27,7 +27,7 @@ if ($ConfigurationName -eq "Release Portable") {
|
||||
|
||||
Copy-Item "mRemoteV1\Resources\PuTTYNG.exe" -Destination "mRemoteV1\bin\package"
|
||||
|
||||
Copy-Item "mRemoteV1\bin\$ConfigurationName\*" -Destination "mRemoteV1\bin\package" -Recurse -Force
|
||||
Copy-Item "mRemoteV1\bin\$ConfigurationName\*" -Destination "mRemoteV1\bin\package" -Recurse -Force -Exclude *.pdb
|
||||
Copy-Item "*.txt" -Destination "mRemoteV1\bin\package"
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
|
||||
83
Tools/appveyor_publish_build.ps1
Normal file
83
Tools/appveyor_publish_build.ps1
Normal file
@@ -0,0 +1,83 @@
|
||||
if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "NOT running via Appveyor - Exiting"
|
||||
Throw "NOT running via Appveyor - Exiting"
|
||||
}
|
||||
|
||||
$appvDir = $Env:APPVEYOR_BUILD_FOLDER
|
||||
|
||||
$SIGCHECK="Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="Tools\7zip\7za.exe"
|
||||
|
||||
Write-Output "Appveyor Build Dir: '$($appvDir)'"
|
||||
|
||||
Write-Output "Decrypt Cert"
|
||||
& appveyor-tools\secure-file -decrypt "$($Env:cert_path).enc" -secret "$Env:cert_decrypt_pwd"
|
||||
|
||||
if(-Not (Test-Path $Env:cert_path)) {
|
||||
Write-Output "decrypt cert does not exist..."
|
||||
Throw "Could not decrypt cert"
|
||||
}
|
||||
|
||||
Write-Output "Restoring NuGets"
|
||||
& nuget restore
|
||||
|
||||
|
||||
Write-Output "Build Release Installer"
|
||||
& msbuild "$($appvDir)\mRemoteV1.sln" /nologo /t:Clean,Build /p:Configuration="Release Installer" /p:Platform=x86 /p:CertPath="$($Env:cert_path)" /p:CertPassword="$Env:cert_pwd" /m /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
|
||||
Write-Output "Packaging debug symbols"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "mRemoteV1\bin\Release\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$zipFilePrefix = "mRemoteNG-symbols"
|
||||
|
||||
|
||||
$outputZipPath="Release\$zipFilePrefix-$($version).zip"
|
||||
|
||||
Write-Output "Creating debug symbols ZIP file $($outputZipPath)"
|
||||
Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue
|
||||
$SymPath = (Join-Path -Path "mRemoteV1\bin\Release" -ChildPath "*.pdb")
|
||||
if(Test-Path "$SymPath") {
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath "$SymPath"
|
||||
} else {
|
||||
Write-Output "No Debugging Symbols Found..."
|
||||
}
|
||||
|
||||
|
||||
Write-Output "Build Release Portable"
|
||||
& msbuild "$($appvDir)\mRemoteV1.sln" /nologo /t:Clean,Build /p:Configuration="Release Portable" /p:Platform=x86 /p:CertPath="$($Env:cert_path)" /p:CertPassword="$Env:cert_pwd" /m /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
|
||||
|
||||
Write-Output "Packaging Release Portable ZIP"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "mRemoteV1\bin\Release Portable\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$zipFilePrefix = "mRemoteNG-Portable-symbols"
|
||||
$outputZipPath="Release\$zipFilePrefix-$($version).zip"
|
||||
|
||||
Write-Output "Creating debug symbols ZIP file $($outputZipPath)"
|
||||
Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue
|
||||
$SymPath = (Join-Path -Path "mRemoteV1\bin\Release Portable" -ChildPath "*.pdb")
|
||||
if(Test-Path "$SymPath") {
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath "$SymPath"
|
||||
} else {
|
||||
Write-Output "No Debugging Symbols Found..."
|
||||
}
|
||||
|
||||
$PortableZip="Release\mRemoteNG-Portable-$($version).zip"
|
||||
|
||||
Remove-Item -Recurse "mRemoteV1\bin\package" -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item "mRemoteV1\bin\package" -ItemType "directory" | Out-Null
|
||||
|
||||
Copy-Item "mRemoteV1\Resources\PuTTYNG.exe" -Destination "mRemoteV1\bin\package"
|
||||
|
||||
Copy-Item "mRemoteV1\bin\Release Portable\*" -Destination "mRemoteV1\bin\package" -Recurse -Force
|
||||
Copy-Item "*.txt" -Destination "mRemoteV1\bin\package"
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip ".\mRemoteV1\bin\package\*.*"
|
||||
@@ -33,11 +33,12 @@ Format-Table -AutoSize -Wrap -InputObject @{
|
||||
"TargetDir" = $TargetDir
|
||||
"TargetFileName" = $TargetFileName
|
||||
"ConfigurationName" = $ConfigurationName
|
||||
"CertificatePath" = $CertificatePath
|
||||
"ExcludeFromSigning" = $ExcludeFromSigning
|
||||
}
|
||||
|
||||
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning -SolutionDir $SolutionDir
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath -SolutionDir $SolutionDir
|
||||
& "$PSScriptRoot\rename_installer_with_version.ps1" -SolutionDir $SolutionDir
|
||||
& "$PSScriptRoot\copy_release_installer.ps1" -SourcePath $TargetDir -DestinationDir (Join-Path -Path $SolutionDir -ChildPath "Release")
|
||||
@@ -33,6 +33,7 @@ Format-Table -AutoSize -Wrap -InputObject @{
|
||||
"TargetDir" = $TargetDir
|
||||
"TargetFileName" = $TargetFileName
|
||||
"ConfigurationName" = $ConfigurationName
|
||||
"CertificatePath" = $CertificatePath
|
||||
"ExcludeFromSigning" = $ExcludeFromSigning
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ Format-Table -AutoSize -Wrap -InputObject @{
|
||||
& "$PSScriptRoot\set_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
|
||||
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
|
||||
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning -SolutionDir $SolutionDir
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath -SolutionDir $SolutionDir
|
||||
& "$PSScriptRoot\zip_symbols.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\zip_portable_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
@@ -12,12 +12,16 @@ param (
|
||||
$Exclude,
|
||||
|
||||
[string]
|
||||
[AllowEmptyString()]
|
||||
# The code signing certificate to use when signing the files.
|
||||
$CertificatePath,
|
||||
|
||||
[string]
|
||||
# Password to unlock the code signing certificate.
|
||||
$CertificatePassword
|
||||
$CertificatePassword,
|
||||
|
||||
[string]
|
||||
$SolutionDir
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
@@ -26,51 +30,59 @@ Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
$timeserver = "http://timestamp.verisign.com/scripts/timstamp.dll"
|
||||
|
||||
|
||||
if ($ConfigurationName -notmatch "Release") {
|
||||
Write-Output "This is not a release build - we won't sign files."
|
||||
return
|
||||
}
|
||||
# validate release versions and if the certificate value was passed
|
||||
if ($ConfigurationName -match "Release" -And ($CertificatePath)) {
|
||||
|
||||
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf)) {
|
||||
Write-Output "Certificate is not present - we won't sign files."
|
||||
return
|
||||
}
|
||||
if(-Not ([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) ) {
|
||||
$CertificatePath = Join-Path -Path $SolutionDir -ChildPath $CertificatePath
|
||||
}
|
||||
|
||||
if ($CertificatePassword -eq "") {
|
||||
Write-Output "No certificate password was provided - we won't sign files."
|
||||
return
|
||||
}
|
||||
# make sure the cert is actually available
|
||||
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
|
||||
{
|
||||
Write-Output "Certificate is not present - we won't sign files."
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
$certKeyStore = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet
|
||||
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertificatePath, $CertificatePassword, $certKeyStore) -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Output "Error loading certificate file - we won't sign files."
|
||||
Write-Output $Error[0]
|
||||
return
|
||||
}
|
||||
if ($CertificatePassword -eq "") {
|
||||
Write-Output "No certificate password was provided - we won't sign files."
|
||||
return
|
||||
}
|
||||
|
||||
# Sign MSI if we are building a release version and the certificate is available
|
||||
Write-Output "Signing Binaries"
|
||||
Write-Output "Getting files from path: $TargetDir"
|
||||
$signableFiles = Get-ChildItem -Path $TargetDir -Recurse | ?{$_.Extension -match "dll|exe|msi"} | ?{$Exclude -notcontains $_.Name}
|
||||
try {
|
||||
$certKeyStore = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet
|
||||
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertificatePath, $CertificatePassword, $certKeyStore) -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Output "Error loading certificate file - we won't sign files."
|
||||
Write-Output $Error[0]
|
||||
return
|
||||
}
|
||||
|
||||
$excluded_files = Get-ChildItem -Path $TargetDir -Recurse | ?{$_.Extension -match "dll|exe|msi"} | ?{$Exclude -contains $_.Name}
|
||||
$excluded_files | ForEach-Object `
|
||||
-Begin { Write-Output "The following files were excluded from signing due to being on the exclusion list:" } `
|
||||
-Process { Write-Output "-- $($_.FullName)" }
|
||||
# Sign MSI if we are building a release version and the certificate is available
|
||||
Write-Output "Signing Binaries"
|
||||
Write-Output "Getting files from path: $TargetDir"
|
||||
$signableFiles = Get-ChildItem -Path $TargetDir -Recurse | ?{$_.Extension -match "dll|exe|msi"} | ?{$Exclude -notcontains $_.Name}
|
||||
|
||||
Write-Output "Signable files count: $($signableFiles.Count)"
|
||||
$excluded_files = Get-ChildItem -Path $TargetDir -Recurse | ?{$_.Extension -match "dll|exe|msi"} | ?{$Exclude -contains $_.Name}
|
||||
$excluded_files | ForEach-Object `
|
||||
-Begin { Write-Output "The following files were excluded from signing due to being on the exclusion list:" } `
|
||||
-Process { Write-Output "-- $($_.FullName)" }
|
||||
|
||||
Write-Output "Signable files count: $($signableFiles.Count)"
|
||||
|
||||
|
||||
foreach ($file in $signableFiles) {
|
||||
Set-AuthenticodeSignature -Certificate $cert -TimestampServer $timeserver -IncludeChain all -FilePath $file.FullName
|
||||
}
|
||||
foreach ($file in $signableFiles) {
|
||||
Set-AuthenticodeSignature -Certificate $cert -TimestampServer $timeserver -IncludeChain all -FilePath $file.FullName
|
||||
}
|
||||
|
||||
|
||||
# Release certificate
|
||||
if ($cert -ne $null) {
|
||||
$cert.Dispose()
|
||||
# Release certificate
|
||||
if ($cert -ne $null) {
|
||||
$cert.Dispose()
|
||||
}
|
||||
} else {
|
||||
Write-Output "This is not a release build or CertificatePath wasn't provided - we won't sign files."
|
||||
Write-Output "Config: $($ConfigurationName)`tCertPath: $($CertificatePath)"
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
@@ -9,15 +9,25 @@ param (
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
[AllowEmptyString()]
|
||||
# The code signing certificate to use when signing the files.
|
||||
$CertificatePath
|
||||
$CertificatePath,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$SolutionDir
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
|
||||
# validate release versions and if the certificate is available
|
||||
if ($ConfigurationName -match "Release") {
|
||||
# validate release versions and if the certificate value was passed
|
||||
if ($ConfigurationName -match "Release" -And ($CertificatePath)) {
|
||||
|
||||
if(-Not ([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) ) {
|
||||
$CertificatePath = Join-Path -Path $SolutionDir -ChildPath $CertificatePath
|
||||
}
|
||||
|
||||
# make sure the cert is actually available
|
||||
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
|
||||
{
|
||||
Write-Output "Certificate is not present - files likely not signed - we won't verify file signatures."
|
||||
@@ -42,7 +52,8 @@ if ($ConfigurationName -match "Release") {
|
||||
Write-Output "All files have valid signatures."
|
||||
}
|
||||
} else {
|
||||
Write-Output "This is not a release build - we won't verify file signatures."
|
||||
Write-Output "This is not a release build or CertificatePath wasn't provided - we won't verify file signatures."
|
||||
Write-Output "Config: $($ConfigurationName)`tCertPath: $($CertificatePath)"
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
@@ -1,6 +1,8 @@
|
||||
version: 1.76.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
skip_tags: true
|
||||
skip_branch_with_pr: true
|
||||
image: Visual Studio 2017
|
||||
configuration:
|
||||
- Release
|
||||
@@ -28,7 +30,7 @@ build:
|
||||
parallel: true
|
||||
verbosity: normal
|
||||
after_build:
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \".\\mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force -Exclude *.pdb\n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \".\\mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
version: 1.76.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
environment:
|
||||
cert_path: tools\cert\CodeSigning_Cert_mRemoteNG_DigiCert.p12
|
||||
cert_decrypt_pwd:
|
||||
secure: QK1ldldzIUSVA0u+OtbHixPmsXHAO9ksOKcyByq0FHM=
|
||||
cert_pwd:
|
||||
secure: Fni66m2OgoTxjRzahUNUUNHl5gGwTXLvXIMQYiOMqX8=
|
||||
image: Visual Studio 2017
|
||||
configuration:
|
||||
- Release Portable
|
||||
- Release
|
||||
- Release Installer
|
||||
platform: x86
|
||||
shallow_clone: true
|
||||
clone_depth: 1
|
||||
install:
|
||||
- ps: >-
|
||||
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
|
||||
|
||||
date
|
||||
|
||||
mRemoteV1\Resources\CitrixReceiver.exe ENABLE_SSON="No" /silent /noreboot /EnableCEIP=false /AutoUpdateCheck=disabled /EnableTracing=false | out-null
|
||||
|
||||
date
|
||||
before_build:
|
||||
- cmd: >-
|
||||
echo %TIME%
|
||||
|
||||
nuget restore
|
||||
|
||||
echo %TIME%
|
||||
|
||||
appveyor-tools\secure-file -decrypt %cert_path%.enc -secret %cert_decrypt_pwd%
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release Portable" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- configuration: "Release Installer"
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release Installer" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- configuration: Release
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
after_build:
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \".\\mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
artifacts:
|
||||
- path: Release\*.msi
|
||||
name: mRemoteNG-installer.msi
|
||||
- path: Release\mRemoteNG-Portable-1.*.zip
|
||||
name: mRemoteNG-portable.zip
|
||||
- path: Release\mRemoteNG-Portable-symbols*.zip
|
||||
name: mRemoteNG-Portable-symbols.zip
|
||||
- path: Release\mRemoteNG-symbols*.zip
|
||||
name: mRemoteNG-symbols.zip
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -12,6 +13,8 @@
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -34,8 +37,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -89,6 +92,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.Console" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.11.0" targetFramework="net46" />
|
||||
<package id="NUnit.Console" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.3" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.VSProjectLoader" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.Runners" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.5" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net46" />
|
||||
<package id="NUnit.Runners" version="3.9.0" targetFramework="net46" />
|
||||
<package id="SpecFlow" version="2.2.1" targetFramework="net46" />
|
||||
<package id="SpecFlow.NUnit" version="2.2.1" targetFramework="net46" />
|
||||
<package id="SpecFlow.NUnit.Runners" version="2.2.1" targetFramework="net46" />
|
||||
|
||||
47
mRemoteNGTests/App/ImportTests.cs
Normal file
47
mRemoteNGTests/App/ImportTests.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.IO;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNGTests.Properties;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.App
|
||||
{
|
||||
public class ImportTests
|
||||
{
|
||||
[Test]
|
||||
public void ErrorHandlerCalledWhenUnsupportedFileExtensionFound()
|
||||
{
|
||||
using (FileTestHelpers.DisposableTempFile(out var file, ".blah"))
|
||||
{
|
||||
var conService = new ConnectionsService(PuttySessionsManager.Instance);
|
||||
var container = new ContainerInfo();
|
||||
var exceptionOccurred = false;
|
||||
|
||||
Import.HeadlessFileImport(new []{file}, container, conService, s => exceptionOccurred = true);
|
||||
|
||||
Assert.That(exceptionOccurred);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnErrorInOneFileDoNotPreventOtherFilesFromProcessing()
|
||||
{
|
||||
using (FileTestHelpers.DisposableTempFile(out var badFile, ".blah"))
|
||||
using (FileTestHelpers.DisposableTempFile(out var rdpFile, ".rdp"))
|
||||
{
|
||||
File.AppendAllText(rdpFile, Resources.test_remotedesktopconnection_rdp);
|
||||
var conService = new ConnectionsService(PuttySessionsManager.Instance);
|
||||
var container = new ContainerInfo();
|
||||
var exceptionCount = 0;
|
||||
|
||||
Import.HeadlessFileImport(new[] { badFile, rdpFile }, container, conService, s => exceptionCount++);
|
||||
|
||||
Assert.That(exceptionCount, Is.EqualTo(1));
|
||||
Assert.That(container.Children, Has.One.Items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
PostExtApp = "SomePostExtApp",
|
||||
MacAddress = "SomeMacAddress",
|
||||
UserField = "SomeUserField",
|
||||
Favorite = true,
|
||||
ExtApp = "SomeExtApp",
|
||||
VNCProxyUsername = "SomeVNCProxyUsername",
|
||||
VNCProxyPassword = "SomeVNCProxyPassword",
|
||||
@@ -111,6 +112,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
RedirectPrinters = true,
|
||||
RedirectSmartCards = true,
|
||||
RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer,
|
||||
RedirectAudioCapture = true,
|
||||
RedirectKeys = true,
|
||||
VNCCompression = ProtocolVNC.Compression.Comp4,
|
||||
VNCEncoding = ProtocolVNC.Encoding.EncRRE,
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlRootNodeSerializerTests
|
||||
public class XmlRootNodeSerializerTests
|
||||
{
|
||||
private XmlRootNodeSerializer _rootNodeSerializer;
|
||||
private ICryptographyProvider _cryptographyProvider;
|
||||
@@ -34,6 +34,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
}
|
||||
|
||||
[Test]
|
||||
[SetUICulture("en-US")]
|
||||
public void RootNodeInfoNameSerialized()
|
||||
{
|
||||
var element = _rootNodeSerializer.SerializeRootNodeInfo(_rootNodeInfo, _cryptographyProvider, _version);
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.Properties;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
{
|
||||
public class RemoteDesktopConnectionManager27DeserializerTests
|
||||
public class RemoteDesktopConnectionManager27DeserializerTests
|
||||
{
|
||||
private string _connectionFileContents;
|
||||
private RemoteDesktopConnectionManagerDeserializer _deserializer;
|
||||
private ConnectionTreeModel _connectionTreeModel;
|
||||
private const string ExpectedName = "server1_displayname";
|
||||
private const string ExpectedHostname = "server1";
|
||||
private const string ExpectedDescription = "Comment text here";
|
||||
@@ -44,265 +45,80 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
{
|
||||
_connectionFileContents = Resources.test_rdcman_v2_7_schema3;
|
||||
_deserializer = new RemoteDesktopConnectionManagerDeserializer();
|
||||
_connectionTreeModel = _deserializer.Deserialize(_connectionFileContents);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionTreeModelHasARootNode()
|
||||
{
|
||||
var numberOfRootNodes = _connectionTreeModel.RootNodes.Count;
|
||||
var connectionTreeModel = _deserializer.Deserialize(_connectionFileContents);
|
||||
var numberOfRootNodes = connectionTreeModel.RootNodes.Count;
|
||||
Assert.That(numberOfRootNodes, Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RootNodeHasContents()
|
||||
{
|
||||
var rootNodeContents = _connectionTreeModel.RootNodes.First().Children;
|
||||
var connectionTreeModel = _deserializer.Deserialize(_connectionFileContents);
|
||||
var rootNodeContents = connectionTreeModel.RootNodes.First().Children;
|
||||
Assert.That(rootNodeContents, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSubRootFoldersImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var connectionTreeModel = _deserializer.Deserialize(_connectionFileContents);
|
||||
var rootNode = connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var rootNodeContents = importedRdcmanRootNode.Children.Count(node => node.Name == "Group1" || node.Name == "Group2");
|
||||
Assert.That(rootNodeContents, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionDisplayNameImported()
|
||||
[TestCaseSource(nameof(ExpectedPropertyValues))]
|
||||
public void PropertiesWithValuesAreCorrectlyImported(Func<ConnectionInfo, object> propSelector, object expectedValue)
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Name, Is.EqualTo(ExpectedName));
|
||||
var connectionTreeModel = _deserializer.Deserialize(_connectionFileContents);
|
||||
|
||||
var connection = connectionTreeModel
|
||||
.GetRecursiveChildList()
|
||||
.OfType<ContainerInfo>()
|
||||
.First(node => node.Name == "Group1")
|
||||
.Children
|
||||
.First();
|
||||
|
||||
Assert.That(propSelector(connection), Is.EqualTo(expectedValue));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionHostnameImported()
|
||||
[TestCaseSource(nameof(NullPropertyValues))]
|
||||
public void PropertiesWithoutValuesAreIgnored(Func<ConnectionInfo, object> propSelector)
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Hostname, Is.EqualTo(ExpectedHostname));
|
||||
var connectionTreeModel = _deserializer.Deserialize(Resources.test_rdcman_v2_7_schema3_empty_values);
|
||||
|
||||
var importedConnection = connectionTreeModel
|
||||
.GetRecursiveChildList()
|
||||
.OfType<ContainerInfo>()
|
||||
.First(node => node.Name == "Group1")
|
||||
.Children
|
||||
.First();
|
||||
|
||||
Assert.That(propSelector(importedConnection), Is.EqualTo(propSelector(new ConnectionInfo())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionDescriptionImported()
|
||||
[TestCaseSource(nameof(NullPropertyValues))]
|
||||
public void NonExistantPropertiesAreIgnored(Func<ConnectionInfo, object> propSelector)
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Description, Is.EqualTo(ExpectedDescription));
|
||||
var connectionTreeModel = _deserializer.Deserialize(Resources.test_rdcman_v2_7_schema3_null_values);
|
||||
|
||||
var importedConnection = connectionTreeModel
|
||||
.GetRecursiveChildList()
|
||||
.OfType<ContainerInfo>()
|
||||
.First(node => node.Name == "Group1")
|
||||
.Children
|
||||
.First();
|
||||
|
||||
Assert.That(propSelector(importedConnection), Is.EqualTo(propSelector(new ConnectionInfo())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionUsernameImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Username, Is.EqualTo(ExpectedUsername));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionDomainImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Domain, Is.EqualTo(ExpectedDomain));
|
||||
}
|
||||
|
||||
// Since password is encrypted with a machine key, cant test decryption on another machine
|
||||
//[Test]
|
||||
//public void ConnectionPasswordImported()
|
||||
//{
|
||||
// var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
// var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
// var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
// var connection = group1.Children.First();
|
||||
// Assert.That(connection.Password, Is.EqualTo(ExpectedPassword));
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void ConnectionProtocolSetToRdp()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Protocol, Is.EqualTo(ProtocolType.RDP));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionUseConsoleSessionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.UseConsoleSession, Is.EqualTo(ExpectedUseConsoleSession));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionPortImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Port, Is.EqualTo(ExpectedPort));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionGatewayUsageMethodImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RDGatewayUsageMethod, Is.EqualTo(ExpectedGatewayUsageMethod));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionGatewayHostnameImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RDGatewayHostname, Is.EqualTo(ExpectedGatewayHostname));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionGatewayUsernameImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RDGatewayUsername, Is.EqualTo(ExpectedGatewayUsername));
|
||||
}
|
||||
|
||||
// Since password is encrypted with a machine key, cant test decryption on another machine
|
||||
//[Test]
|
||||
//public void ConnectionGatewayPasswordImported()
|
||||
//{
|
||||
// var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
// var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
// var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
// var connection = group1.Children.First();
|
||||
// Assert.That(connection.RDGatewayPassword, Is.EqualTo(ExpectedGatewayPassword));
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void ConnectionGatewayDomainImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RDGatewayDomain, Is.EqualTo(ExpectedGatewayDomain));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionResolutionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Resolution, Is.EqualTo(ExpectedRdpResolution));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionColorDepthImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.Colors, Is.EqualTo(ExpectedRdpColorDepth));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionAudioRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectSound, Is.EqualTo(ExpectedAudioRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionKeyRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectKeys, Is.EqualTo(ExpectedKeyRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionDriveRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectDiskDrives, Is.EqualTo(ExpectedDriveRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionPortRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectPorts, Is.EqualTo(ExpectedPortRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionPrinterRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectPrinters, Is.EqualTo(ExpectedPrinterRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionSmartcardRedirectionImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RedirectSmartCards, Is.EqualTo(ExpectedSmartcardRedirection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionauthenticationLevelImported()
|
||||
{
|
||||
var rootNode = _connectionTreeModel.RootNodes.First();
|
||||
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
|
||||
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
|
||||
var connection = group1.Children.First();
|
||||
Assert.That(connection.RDPAuthenticationLevel, Is.EqualTo(ExpectedAuthLevel));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Test]
|
||||
public void ExceptionThrownOnBadSchemaVersion()
|
||||
{
|
||||
var badFileContents = Resources.test_rdcman_v2_2_badschemaversion;
|
||||
@@ -322,5 +138,61 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
|
||||
var badFileContents = Resources.test_rdcman_noversion;
|
||||
Assert.That(() => _deserializer.Deserialize(badFileContents), Throws.TypeOf<FileFormatException>());
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ExpectedPropertyValues()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Name), ExpectedName).SetName(nameof(ConnectionInfo.Name)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Hostname), ExpectedHostname).SetName(nameof(ConnectionInfo.Hostname)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Description), ExpectedDescription).SetName(nameof(ConnectionInfo.Description)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Username), ExpectedUsername).SetName(nameof(ConnectionInfo.Username)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Domain), ExpectedDomain).SetName(nameof(ConnectionInfo.Domain)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Protocol), ProtocolType.RDP).SetName(nameof(ConnectionInfo.Protocol)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.UseConsoleSession), ExpectedUseConsoleSession).SetName(nameof(ConnectionInfo.UseConsoleSession)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Port), ExpectedPort).SetName(nameof(ConnectionInfo.Port)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayUsageMethod), ExpectedGatewayUsageMethod).SetName(nameof(ConnectionInfo.RDGatewayUsageMethod)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayHostname), ExpectedGatewayHostname).SetName(nameof(ConnectionInfo.RDGatewayHostname)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayUsername), ExpectedGatewayUsername).SetName(nameof(ConnectionInfo.RDGatewayUsername)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayDomain), ExpectedGatewayDomain).SetName(nameof(ConnectionInfo.RDGatewayDomain)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Resolution), ExpectedRdpResolution).SetName(nameof(ConnectionInfo.Resolution)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Colors), ExpectedRdpColorDepth).SetName(nameof(ConnectionInfo.Colors)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectSound), ExpectedAudioRedirection).SetName(nameof(ConnectionInfo.RedirectSound)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectKeys), ExpectedKeyRedirection).SetName(nameof(ConnectionInfo.RedirectKeys)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDPAuthenticationLevel), ExpectedAuthLevel).SetName(nameof(ConnectionInfo.RDPAuthenticationLevel)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectSmartCards), ExpectedSmartcardRedirection).SetName(nameof(ConnectionInfo.RedirectSmartCards)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectPrinters), ExpectedPrinterRedirection).SetName(nameof(ConnectionInfo.RedirectPrinters)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectPorts), ExpectedPortRedirection).SetName(nameof(ConnectionInfo.RedirectPorts)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectDiskDrives), ExpectedDriveRedirection).SetName(nameof(ConnectionInfo.RedirectDiskDrives)),
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> NullPropertyValues()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Name)).SetName(nameof(ConnectionInfo.Name)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Hostname)).SetName(nameof(ConnectionInfo.Hostname)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Description)).SetName(nameof(ConnectionInfo.Description)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Username)).SetName(nameof(ConnectionInfo.Username)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Domain)).SetName(nameof(ConnectionInfo.Domain)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Protocol)).SetName(nameof(ConnectionInfo.Protocol)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.UseConsoleSession)).SetName(nameof(ConnectionInfo.UseConsoleSession)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Port)).SetName(nameof(ConnectionInfo.Port)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayUsageMethod)).SetName(nameof(ConnectionInfo.RDGatewayUsageMethod)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayHostname)).SetName(nameof(ConnectionInfo.RDGatewayHostname)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayUsername)).SetName(nameof(ConnectionInfo.RDGatewayUsername)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDGatewayDomain)).SetName(nameof(ConnectionInfo.RDGatewayDomain)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Resolution)).SetName(nameof(ConnectionInfo.Resolution)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.Colors)).SetName(nameof(ConnectionInfo.Colors)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectSound)).SetName(nameof(ConnectionInfo.RedirectSound)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectKeys)).SetName(nameof(ConnectionInfo.RedirectKeys)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RDPAuthenticationLevel)).SetName(nameof(ConnectionInfo.RDPAuthenticationLevel)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectSmartCards)).SetName(nameof(ConnectionInfo.RedirectSmartCards)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectPrinters)).SetName(nameof(ConnectionInfo.RedirectPrinters)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectPorts)).SetName(nameof(ConnectionInfo.RedirectPorts)),
|
||||
new TestCaseData((Func<ConnectionInfo,object>)(con => con.RedirectDiskDrives)).SetName(nameof(ConnectionInfo.RedirectDiskDrives)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace mRemoteNGTests.Config.Serializers.Versioning
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var sqlConnector = Substitute.For<SqlDatabaseConnector>("", "", "", "");
|
||||
var sqlConnector = Substitute.For<MSSqlDatabaseConnector>("", "", "", "");
|
||||
_versionUpgrader = new SqlVersion22To23Upgrader(sqlConnector);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mRemoteNGTests.Config.Serializers.Versioning
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var sqlConnector = Substitute.For<SqlDatabaseConnector>("", "", "", "");
|
||||
var sqlConnector = Substitute.For<MSSqlDatabaseConnector>("", "", "", "");
|
||||
_versionUpgrader = new SqlVersion23To24Upgrader(sqlConnector);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mRemoteNGTests.Config.Serializers.Versioning
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var sqlConnector = Substitute.For<SqlDatabaseConnector>("", "", "", "");
|
||||
var sqlConnector = Substitute.For<MSSqlDatabaseConnector>("", "", "", "");
|
||||
_versionUpgrader = new SqlVersion24To25Upgrader(sqlConnector);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mRemoteNGTests.Config.Serializers.Versioning
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var sqlConnector = Substitute.For<SqlDatabaseConnector>("", "", "", "");
|
||||
var sqlConnector = Substitute.For<MSSqlDatabaseConnector>("", "", "", "");
|
||||
_versionUpgrader = new SqlVersion25To26Upgrader(sqlConnector);
|
||||
}
|
||||
|
||||
|
||||
@@ -412,6 +412,15 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(wasCalled, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FavoriteNotifiesOnValueChange()
|
||||
{
|
||||
var wasCalled = false;
|
||||
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
|
||||
_testAbstractConnectionInfoData.Favorite = true;
|
||||
Assert.That(wasCalled, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VncCompressionNotifiesOnValueChange()
|
||||
{
|
||||
|
||||
@@ -53,7 +53,8 @@ namespace mRemoteNGTests.Connection
|
||||
[Test]
|
||||
public void CloneCorrectlySetsParentOfInheritanceObject()
|
||||
{
|
||||
var clonedConnection = _connectionInfo.Clone();
|
||||
var originalConnection = new ConnectionInfo();
|
||||
var clonedConnection = originalConnection.Clone();
|
||||
Assert.That(clonedConnection.Inheritance.Parent, Is.EqualTo(clonedConnection));
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public static IEnumerable<PropertyInfo> GetProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object()).GetProperties();
|
||||
return new ConnectionInfoInheritance(new ConnectionInfo()).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mRemoteNGTests.Connection
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new ConnectionInfo(), true);
|
||||
inheritanceSource.TurnOnInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace mRemoteNGTests.Connection
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var saveTarget = new ConnectionInfoInheritance(new object(), true);
|
||||
var saveTarget = new ConnectionInfoInheritance(new ConnectionInfo(), true);
|
||||
saveTarget.TurnOffInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace mRemoteNGTests.Connection
|
||||
public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.Domain = true;
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new object());
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new ConnectionInfo());
|
||||
Assert.That(inheritanceInstance.Domain, Is.True);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace mRemoteNGTests.Connection
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new object());
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new ConnectionInfo());
|
||||
|
||||
var valueInDestination = property.GetValue(inheritanceInstance);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
@@ -57,7 +57,7 @@ namespace mRemoteNGTests.Connection
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object(), true).GetProperties();
|
||||
return new ConnectionInfoInheritance(new ConnectionInfo(), true).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
52
mRemoteNGTests/Properties/Resources.Designer.cs
generated
52
mRemoteNGTests/Properties/Resources.Designer.cs
generated
@@ -298,6 +298,58 @@ namespace mRemoteNGTests.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
|
||||
///<RDCMan programVersion="2.7" schemaVersion="3">
|
||||
/// <file>
|
||||
/// <credentialsProfiles />
|
||||
/// <properties>
|
||||
/// <expanded>True</expanded>
|
||||
/// <name>test_RDCMan_connections</name>
|
||||
/// </properties>
|
||||
/// <smartGroup>
|
||||
/// <properties>
|
||||
/// <expanded>False</expanded>
|
||||
/// <name>AllServers</name>
|
||||
/// </properties>
|
||||
/// <ruleGroup operator="All">
|
||||
/// <rule>
|
||||
/// <property>DisplayName</property>
|
||||
/// <operator>Matches</operator>
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string test_rdcman_v2_7_schema3_empty_values {
|
||||
get {
|
||||
return ResourceManager.GetString("test_rdcman_v2_7_schema3_empty_values", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
|
||||
///<RDCMan programVersion="2.7" schemaVersion="3">
|
||||
/// <file>
|
||||
/// <credentialsProfiles />
|
||||
/// <properties>
|
||||
/// <expanded>True</expanded>
|
||||
/// <name>test_RDCMan_connections</name>
|
||||
/// </properties>
|
||||
/// <smartGroup>
|
||||
/// <properties>
|
||||
/// <expanded>False</expanded>
|
||||
/// <name>AllServers</name>
|
||||
/// </properties>
|
||||
/// <ruleGroup operator="All">
|
||||
/// <rule>
|
||||
/// <property>DisplayName</property>
|
||||
/// <operator>Matches</operator>
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string test_rdcman_v2_7_schema3_null_values {
|
||||
get {
|
||||
return ResourceManager.GetString("test_rdcman_v2_7_schema3_null_values", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to screen mode id:i:1
|
||||
///use multimon:i:0
|
||||
|
||||
@@ -175,6 +175,12 @@
|
||||
<data name="test_rdcman_v2_7_schema3" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\test_RDCMan_v2_7_schema3.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="test_rdcman_v2_7_schema3_empty_values" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\test_rdcman_v2_7_schema3_empty_values.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="test_rdcman_v2_7_schema3_null_values" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\test_rdcman_v2_7_schema3_null_values.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="test_remotedesktopconnection_rdp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\test_remotedesktopconnection.rdp;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
|
||||
</data>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RDCMan programVersion="2.7" schemaVersion="3">
|
||||
<file>
|
||||
<credentialsProfiles />
|
||||
<properties>
|
||||
<expanded>True</expanded>
|
||||
<name>test_RDCMan_connections</name>
|
||||
</properties>
|
||||
<smartGroup>
|
||||
<properties>
|
||||
<expanded>False</expanded>
|
||||
<name>AllServers</name>
|
||||
</properties>
|
||||
<ruleGroup operator="All">
|
||||
<rule>
|
||||
<property>DisplayName</property>
|
||||
<operator>Matches</operator>
|
||||
<value>server</value>
|
||||
</rule>
|
||||
</ruleGroup>
|
||||
</smartGroup>
|
||||
<group>
|
||||
<properties>
|
||||
<expanded>True</expanded>
|
||||
<name>Group1</name>
|
||||
</properties>
|
||||
<server>
|
||||
<properties>
|
||||
<displayName></displayName>
|
||||
<name></name>
|
||||
<comment></comment>
|
||||
</properties>
|
||||
<logonCredentials inherit="None">
|
||||
<profileName scope="Local"></profileName>
|
||||
<userName></userName>
|
||||
<password></password>
|
||||
<domain></domain>
|
||||
</logonCredentials>
|
||||
<connectionSettings inherit="None">
|
||||
<connectToConsole></connectToConsole>
|
||||
<startProgram />
|
||||
<workingDir />
|
||||
<port></port>
|
||||
<loadBalanceInfo />
|
||||
</connectionSettings>
|
||||
<gatewaySettings inherit="None">
|
||||
<enabled></enabled>
|
||||
<hostName></hostName>
|
||||
<logonMethod></logonMethod>
|
||||
<localBypass></localBypass>
|
||||
<credSharing></credSharing>
|
||||
<profileName scope="Local"></profileName>
|
||||
<userName></userName>
|
||||
<password />
|
||||
<domain></domain>
|
||||
</gatewaySettings>
|
||||
<remoteDesktop inherit="None">
|
||||
<sameSizeAsClientArea></sameSizeAsClientArea>
|
||||
<fullScreen></fullScreen>
|
||||
<colorDepth></colorDepth>
|
||||
</remoteDesktop>
|
||||
<localResources inherit="None">
|
||||
<audioRedirection></audioRedirection>
|
||||
<audioRedirectionQuality></audioRedirectionQuality>
|
||||
<audioCaptureRedirection></audioCaptureRedirection>
|
||||
<keyboardHook></keyboardHook>
|
||||
<redirectClipboard></redirectClipboard>
|
||||
<redirectDrives></redirectDrives>
|
||||
<redirectDrivesList>
|
||||
<item></item>
|
||||
<item></item>
|
||||
<item></item>
|
||||
<item></item>
|
||||
<item></item>
|
||||
</redirectDrivesList>
|
||||
<redirectPrinters></redirectPrinters>
|
||||
<redirectPorts></redirectPorts>
|
||||
<redirectSmartCards></redirectSmartCards>
|
||||
<redirectPnpDevices></redirectPnpDevices>
|
||||
</localResources>
|
||||
<displaySettings inherit="None">
|
||||
<thumbnailScale></thumbnailScale>
|
||||
<smartSizeDockedWindows></smartSizeDockedWindows>
|
||||
<smartSizeUndockedWindows></smartSizeUndockedWindows>
|
||||
</displaySettings>
|
||||
<securitySettings inherit="None">
|
||||
<authentication></authentication>
|
||||
</securitySettings>
|
||||
</server>
|
||||
</group>
|
||||
</file>
|
||||
<connected />
|
||||
<favorites />
|
||||
<recentlyUsed />
|
||||
</RDCMan>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RDCMan programVersion="2.7" schemaVersion="3">
|
||||
<file>
|
||||
<credentialsProfiles />
|
||||
<properties>
|
||||
<expanded>True</expanded>
|
||||
<name>test_RDCMan_connections</name>
|
||||
</properties>
|
||||
<smartGroup>
|
||||
<properties>
|
||||
<expanded>False</expanded>
|
||||
<name>AllServers</name>
|
||||
</properties>
|
||||
<ruleGroup operator="All">
|
||||
<rule>
|
||||
<property>DisplayName</property>
|
||||
<operator>Matches</operator>
|
||||
<value>server</value>
|
||||
</rule>
|
||||
</ruleGroup>
|
||||
</smartGroup>
|
||||
<group>
|
||||
<properties>
|
||||
<expanded>True</expanded>
|
||||
<name>Group1</name>
|
||||
</properties>
|
||||
<server>
|
||||
<properties>
|
||||
</properties>
|
||||
<logonCredentials inherit="None">
|
||||
</logonCredentials>
|
||||
<connectionSettings inherit="None">
|
||||
</connectionSettings>
|
||||
<gatewaySettings inherit="None">
|
||||
</gatewaySettings>
|
||||
<remoteDesktop inherit="None">
|
||||
</remoteDesktop>
|
||||
<localResources inherit="None">
|
||||
</localResources>
|
||||
<displaySettings inherit="None">
|
||||
</displaySettings>
|
||||
<securitySettings inherit="None">
|
||||
</securitySettings>
|
||||
</server>
|
||||
</group>
|
||||
</file>
|
||||
<connected />
|
||||
<favorites />
|
||||
<recentlyUsed />
|
||||
</RDCMan>
|
||||
@@ -1,93 +1,17 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
internal static class ConnectionInfoHelpers
|
||||
internal static class ConnectionInfoHelpers
|
||||
{
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="ConnectionInfo"/> object with randomized
|
||||
/// values in all fields.
|
||||
/// </summary>
|
||||
internal static ConnectionInfo GetRandomizedConnectionInfo(bool randomizeInheritance = false)
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo
|
||||
{
|
||||
// string types
|
||||
Name = RandomString(),
|
||||
Hostname = RandomString(),
|
||||
Description = RandomString(),
|
||||
Domain = RandomString(),
|
||||
ExtApp = RandomString(),
|
||||
Icon = RandomString(),
|
||||
LoadBalanceInfo = RandomString(),
|
||||
MacAddress = RandomString(),
|
||||
Panel = RandomString(),
|
||||
Password = RandomString(),
|
||||
PostExtApp = RandomString(),
|
||||
PreExtApp = RandomString(),
|
||||
PuttySession = RandomString(),
|
||||
RDGatewayHostname = RandomString(),
|
||||
RDGatewayUsername = RandomString(),
|
||||
RDGatewayDomain = RandomString(),
|
||||
RDGatewayPassword = RandomString(),
|
||||
UserField = RandomString(),
|
||||
Username = RandomString(),
|
||||
VNCProxyIP = RandomString(),
|
||||
VNCProxyPassword = RandomString(),
|
||||
VNCProxyUsername = RandomString(),
|
||||
|
||||
// bool types
|
||||
AutomaticResize = RandomBool(),
|
||||
CacheBitmaps = RandomBool(),
|
||||
DisplayThemes = RandomBool(),
|
||||
DisplayWallpaper = RandomBool(),
|
||||
EnableDesktopComposition = RandomBool(),
|
||||
EnableFontSmoothing = RandomBool(),
|
||||
IsContainer = RandomBool(),
|
||||
IsDefault = RandomBool(),
|
||||
IsQuickConnect = RandomBool(),
|
||||
PleaseConnect = RandomBool(),
|
||||
RDPAlertIdleTimeout = RandomBool(),
|
||||
RedirectDiskDrives = RandomBool(),
|
||||
RedirectKeys = RandomBool(),
|
||||
RedirectPorts = RandomBool(),
|
||||
RedirectPrinters = RandomBool(),
|
||||
RedirectSmartCards = RandomBool(),
|
||||
UseConsoleSession = RandomBool(),
|
||||
UseCredSsp = RandomBool(),
|
||||
VNCViewOnly = RandomBool(),
|
||||
|
||||
// ints
|
||||
Port = RandomInt(),
|
||||
RDPMinutesToIdleTimeout = RandomInt(),
|
||||
VNCProxyPort = RandomInt(),
|
||||
|
||||
// enums
|
||||
Colors = RandomEnum<RdpProtocol.RDPColors>(),
|
||||
ICAEncryptionStrength = RandomEnum<IcaProtocol.EncryptionStrength> (),
|
||||
Protocol = RandomEnum<ProtocolType>(),
|
||||
RDGatewayUsageMethod = RandomEnum<RdpProtocol.RDGatewayUsageMethod>(),
|
||||
RDGatewayUseConnectionCredentials = RandomEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(),
|
||||
RDPAuthenticationLevel = RandomEnum<RdpProtocol.AuthenticationLevel>(),
|
||||
RedirectSound = RandomEnum<RdpProtocol.RDPSounds>(),
|
||||
RenderingEngine = RandomEnum<HTTPBase.RenderingEngine>(),
|
||||
Resolution = RandomEnum<RdpProtocol.RDPResolutions>(),
|
||||
SoundQuality = RandomEnum<RdpProtocol.RDPSoundQuality>(),
|
||||
VNCAuthMode = RandomEnum<ProtocolVNC.AuthMode>(),
|
||||
VNCColors = RandomEnum<ProtocolVNC.Colors>(),
|
||||
VNCCompression = RandomEnum<ProtocolVNC.Compression>(),
|
||||
VNCEncoding = RandomEnum<ProtocolVNC.Encoding>(),
|
||||
VNCProxyType = RandomEnum<ProtocolVNC.ProxyType>(),
|
||||
VNCSmartSizeMode = RandomEnum<ProtocolVNC.SmartSizeMode>(),
|
||||
};
|
||||
var connectionInfo = new ConnectionInfo().RandomizeValues();
|
||||
|
||||
if (randomizeInheritance)
|
||||
connectionInfo.Inheritance = GetRandomizedInheritance(connectionInfo);
|
||||
@@ -95,38 +19,24 @@ namespace mRemoteNGTests.TestHelpers
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
internal static ContainerInfo GetRandomizedContainerInfo(bool randomizeInheritance = false)
|
||||
{
|
||||
var containerInfo = new ContainerInfo().RandomizeValues();
|
||||
|
||||
if (randomizeInheritance)
|
||||
containerInfo.Inheritance = GetRandomizedInheritance(containerInfo);
|
||||
|
||||
return containerInfo;
|
||||
}
|
||||
|
||||
internal static ConnectionInfoInheritance GetRandomizedInheritance(ConnectionInfo parent)
|
||||
{
|
||||
var inheritance = new ConnectionInfoInheritance(parent, true);
|
||||
foreach (var property in inheritance.GetProperties())
|
||||
{
|
||||
property.SetValue(inheritance, RandomBool());
|
||||
property.SetValue(inheritance, Randomizer.RandomBool());
|
||||
}
|
||||
return inheritance;
|
||||
}
|
||||
|
||||
internal static string RandomString()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
internal static bool RandomBool()
|
||||
{
|
||||
return _random.Next() % 2 == 0;
|
||||
}
|
||||
|
||||
internal static int RandomInt()
|
||||
{
|
||||
return _random.Next();
|
||||
}
|
||||
|
||||
internal static T RandomEnum<T>() where T : struct, IConvertible
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("T must be an enum");
|
||||
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
return (T)values.GetValue(_random.Next(values.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
@@ -18,9 +19,17 @@ namespace mRemoteNGTests.TestHelpers
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
public static string NewTempFilePath()
|
||||
public static void DeleteDirectory(string directory)
|
||||
{
|
||||
if (Directory.Exists(directory))
|
||||
Directory.Delete(directory, true);
|
||||
}
|
||||
|
||||
public static string NewTempFilePath(string extension = "")
|
||||
{
|
||||
var newPath = Path.Combine(GetTestSpecificTempDirectory(), Path.GetRandomFileName());
|
||||
if (!string.IsNullOrWhiteSpace(extension))
|
||||
newPath = newPath + extension;
|
||||
var folderPath = Path.GetDirectoryName(newPath);
|
||||
if (!Directory.Exists(folderPath))
|
||||
Directory.CreateDirectory(folderPath);
|
||||
@@ -35,5 +44,15 @@ namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
return Path.Combine(Path.GetTempPath(), "mRemoteNGTests", Path.GetRandomFileName());
|
||||
}
|
||||
|
||||
public static DisposableAction DisposableTempFile(out string filePath, string extension = "")
|
||||
{
|
||||
var file = NewTempFilePath(extension);
|
||||
filePath = file;
|
||||
File.AppendAllText(file, "");
|
||||
return new DisposableAction(
|
||||
() => {},
|
||||
() => DeleteDirectory(Path.GetDirectoryName(file)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using Enum = System.Enum;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
internal static class Randomizer
|
||||
internal static class Randomizer
|
||||
{
|
||||
private static readonly Random Random = new Random();
|
||||
|
||||
@@ -98,7 +98,8 @@ namespace mRemoteNGTests.TestHelpers
|
||||
if (opByType.TryGetValue(property.PropertyType, out var mutator))
|
||||
mutator(property, con);
|
||||
|
||||
else if (opByType.TryGetValue(property.PropertyType.BaseType, out var mutator2))
|
||||
else if (property.PropertyType.BaseType != null &&
|
||||
opByType.TryGetValue(property.PropertyType.BaseType, out var mutator2))
|
||||
mutator2(property, con);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,13 @@
|
||||
public TType RedirectSmartCards { get; set; }
|
||||
public TType RedirectSound { get; set; }
|
||||
public TType SoundQuality { get; set; }
|
||||
public TType RedirectAudioCapture { get; set; }
|
||||
public TType PreExtApp { get; set; }
|
||||
public TType PostExtApp { get; set; }
|
||||
public TType MacAddress { get; set; }
|
||||
public TType UserField { get; set; }
|
||||
public TType VNCCompression { get; set; }
|
||||
public TType UserField { get; set; }
|
||||
public TType Favorite { get; set; }
|
||||
public TType VNCCompression { get; set; }
|
||||
public TType VNCEncoding { get; set; }
|
||||
public TType VNCAuthMode { get; set; }
|
||||
public TType VNCProxyType { get; set; }
|
||||
|
||||
42
mRemoteNGTests/Tools/DisposableActionTests.cs
Normal file
42
mRemoteNGTests/Tools/DisposableActionTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using mRemoteNG.Tools;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tools
|
||||
{
|
||||
public class DisposableActionTests
|
||||
{
|
||||
[Test]
|
||||
public void InitializerActionRunsWhenObjectIsCreated()
|
||||
{
|
||||
var initializerRan = false;
|
||||
new DisposableAction(() => initializerRan = true, () => { });
|
||||
|
||||
Assert.That(initializerRan);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisposalActionRunsWhenDisposeIsCalled()
|
||||
{
|
||||
var disposeActionRan = false;
|
||||
var action = new DisposableAction(() => {}, () => disposeActionRan = true);
|
||||
|
||||
Assert.That(disposeActionRan, Is.False);
|
||||
action.Dispose();
|
||||
Assert.That(disposeActionRan, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisposeActionOnlyExecutedOnceWhenCallingDisposeMultipleTimes()
|
||||
{
|
||||
var invokeCount = 0;
|
||||
var action = new DisposableAction(() => { }, () => invokeCount++);
|
||||
|
||||
action.Dispose();
|
||||
action.Dispose();
|
||||
action.Dispose();
|
||||
action.Dispose();
|
||||
action.Dispose();
|
||||
Assert.That(invokeCount, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,16 @@
|
||||
using System.Threading;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools.Clipboard;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public class ConnectionTreeTests
|
||||
public class ConnectionTreeTests
|
||||
{
|
||||
private ConnectionTreeSearchTextFilter _filter;
|
||||
private ConnectionTree _connectionTree;
|
||||
@@ -73,8 +75,9 @@ namespace mRemoteNGTests.UI.Controls
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddConnection();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
@@ -91,8 +94,9 @@ namespace mRemoteNGTests.UI.Controls
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddFolder();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
@@ -106,8 +110,9 @@ namespace mRemoteNGTests.UI.Controls
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = root;
|
||||
_connectionTree.SelectedObject = root;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
@@ -115,14 +120,33 @@ namespace mRemoteNGTests.UI.Controls
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CanDuplicateConnectionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo();
|
||||
root.AddChild(con1);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = con1;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(root.Children, Has.Exactly(2).Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicateRootPuttyNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
@@ -154,8 +178,9 @@ namespace mRemoteNGTests.UI.Controls
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = null;
|
||||
_connectionTree.SelectedObject = null;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
@@ -194,9 +219,105 @@ namespace mRemoteNGTests.UI.Controls
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.SelectedObject = null;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = null;
|
||||
|
||||
Assert.DoesNotThrow(() => _connectionTree.RenameSelectedNode());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CopyHostnameCopiesTheHostnameOfTheSelectedConnection()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo {Hostname = "MyHost"};
|
||||
root.AddChild(con1);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = con1;
|
||||
|
||||
var clipboard = Substitute.For<IClipboard>();
|
||||
_connectionTree.CopyHostnameSelectedNode(clipboard);
|
||||
clipboard.Received(1).SetText(con1.Hostname);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CopyHostnameCopiesTheNodeNameOfTheSelectedContainer()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var container = new ContainerInfo { Name = "MyFolder" };
|
||||
root.AddChild(container);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = container;
|
||||
|
||||
var clipboard = Substitute.For<IClipboard>();
|
||||
_connectionTree.CopyHostnameSelectedNode(clipboard);
|
||||
clipboard.Received(1).SetText(container.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CopyHostnameDoesNotCopyAnythingIfNoNodeSelected()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo { Hostname = "MyHost" };
|
||||
root.AddChild(con1);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = null;
|
||||
|
||||
var clipboard = Substitute.For<IClipboard>();
|
||||
_connectionTree.CopyHostnameSelectedNode(clipboard);
|
||||
clipboard.DidNotReceiveWithAnyArgs().SetText("");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CopyHostnameDoesNotCopyAnythingIfHostnameOfSelectedConnectionIsEmpty()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo { Hostname = string.Empty };
|
||||
root.AddChild(con1);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = con1;
|
||||
|
||||
var clipboard = Substitute.For<IClipboard>();
|
||||
_connectionTree.CopyHostnameSelectedNode(clipboard);
|
||||
clipboard.DidNotReceiveWithAnyArgs().SetText("");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CopyHostnameDoesNotCopyAnythingIfNameOfSelectedContainerIsEmpty()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ContainerInfo { Name = string.Empty};
|
||||
root.AddChild(con1);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
_connectionTree.SelectedObject = con1;
|
||||
|
||||
var clipboard = Substitute.For<IClipboard>();
|
||||
_connectionTree.CopyHostnameSelectedNode(clipboard);
|
||||
clipboard.DidNotReceiveWithAnyArgs().SetText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
133
mRemoteNGTests/UI/Controls/FilteredPropertyGridTests.cs
Normal file
133
mRemoteNGTests/UI/Controls/FilteredPropertyGridTests.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using mRemoteNG.UI.Controls.FilteredPropertyGrid;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public class FilteredPropertyGridTests
|
||||
{
|
||||
[Test]
|
||||
public void AllPropertiesVisibleByDefault()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new {Prop1 = "hello"};
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.That(grid.VisibleProperties, Is.EquivalentTo(new []{ nameof(obj.Prop1) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertiesOnTheHiddenPropertiesListAreNotShown()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world" };
|
||||
grid.HiddenProperties = new[] { nameof(obj.Prop1) };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.That(grid.VisibleProperties, Is.EquivalentTo(new[] { nameof(obj.Prop2) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnlyPropertiesOnTheBrowsablePropertiesListAreShown()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world" };
|
||||
grid.BrowsableProperties = new[] { nameof(obj.Prop1) };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.That(grid.VisibleProperties, Is.EquivalentTo(new[] { nameof(obj.Prop1) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void APropertyOnBothTheBrowsableAndHiddenListWillNotBeShown()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world", Prop3 = "!" };
|
||||
grid.BrowsableProperties = new[] { nameof(obj.Prop1), nameof(obj.Prop2) };
|
||||
grid.HiddenProperties = new[] { nameof(obj.Prop1) };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.That(grid.VisibleProperties, Is.EquivalentTo(new[] { nameof(obj.Prop2) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExceptionThrownWhenNonExistantPropertyFoundInBrowsablePropertiesList()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello" };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() =>
|
||||
grid.BrowsableProperties = new[] {"NonExistantProperty"});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HiddenPropertiesListCanHandleNonExistentProperties()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello" };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
Assert.DoesNotThrow(() => grid.HiddenProperties = new[] { "NonExistantProperty" });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetVisibleGridItemsReturnsAllExpandedItems()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = new{Prop3 = "world"} };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
var visibleGridItems = grid.GetVisibleGridItems();
|
||||
|
||||
Assert.That(visibleGridItems.Select(i => i.Label),
|
||||
Is.EquivalentTo(new[]
|
||||
{
|
||||
nameof(obj.Prop1),
|
||||
nameof(obj.Prop2)
|
||||
}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSelectGridItem()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world" };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
grid.SelectGridItem(nameof(obj.Prop2));
|
||||
|
||||
Assert.That(grid.SelectedGridItem.PropertyDescriptor?.Name,
|
||||
Is.EqualTo(nameof(obj.Prop2)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextGridItemPropertyReturnsTheCorrectItem()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world" };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
grid.SelectGridItem(nameof(obj.Prop1));
|
||||
var nextGridItem = grid.FindNextGridItemProperty(grid.SelectedGridItem);
|
||||
|
||||
Assert.That(nextGridItem?.PropertyDescriptor?.Name,
|
||||
Is.EqualTo(nameof(obj.Prop2)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindPreviousGridItemPropertyReturnsTheCorrectItem()
|
||||
{
|
||||
var grid = new FilteredPropertyGrid();
|
||||
var obj = new { Prop1 = "hello", Prop2 = "world", Prop3 = "!" };
|
||||
grid.SelectedObject = obj;
|
||||
|
||||
grid.SelectGridItem(nameof(obj.Prop3));
|
||||
var nextGridItem = grid.FindPreviousGridItemProperty(grid.SelectedGridItem);
|
||||
|
||||
Assert.That(nextGridItem?.PropertyDescriptor?.Name,
|
||||
Is.EqualTo(nameof(obj.Prop2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using NUnit.Framework;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using NUnit.Extensions.Forms;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Forms
|
||||
{
|
||||
[TestFixture]
|
||||
[TestFixture]
|
||||
public class PasswordFormTests
|
||||
{
|
||||
PasswordForm _passwordForm;
|
||||
@@ -27,6 +27,7 @@ namespace mRemoteNGTests.UI.Forms
|
||||
}
|
||||
|
||||
[Test]
|
||||
[SetUICulture("en-US")]
|
||||
public void PasswordFormText()
|
||||
{
|
||||
FormTester formTester = new FormTester("PasswordForm");
|
||||
|
||||
@@ -12,17 +12,14 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowGeneralTests
|
||||
public class ConfigWindowGeneralTests
|
||||
{
|
||||
private ConfigWindow _configWindow;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_configWindow = new ConfigWindow
|
||||
{
|
||||
PropertiesVisible = true
|
||||
};
|
||||
_configWindow = new ConfigWindow();
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(ConnectionInfoGeneralTestCases))]
|
||||
@@ -57,7 +54,92 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ConnectionInfoGeneralTestCases()
|
||||
[Test]
|
||||
public void SwitchFromInheritanceToConnectionPropertiesWhenClickingRootNode()
|
||||
{
|
||||
// connection with a normal parent container
|
||||
var connection = new ConnectionInfo();
|
||||
connection.SetParent(new ContainerInfo());
|
||||
|
||||
_configWindow.SelectedTreeNode = connection;
|
||||
_configWindow.ShowInheritanceProperties();
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
Assert.That(_configWindow.PropertiesVisible, Is.True,
|
||||
() => "The property mode should switch from inheritance to connection properties when clicking on the root node.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SwitchFromInheritanceToConnectionPropertiesWhenClickingRootPuttyNode()
|
||||
{
|
||||
// connection with a normal parent container
|
||||
var connection = new ConnectionInfo();
|
||||
connection.SetParent(new ContainerInfo());
|
||||
|
||||
_configWindow.SelectedTreeNode = connection;
|
||||
_configWindow.ShowInheritanceProperties();
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootPuttySessionsNodeInfo();
|
||||
Assert.That(_configWindow.PropertiesVisible, Is.True,
|
||||
() => "The property mode should switch from inheritance to connection properties when clicking on the root node.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SwitchFromInheritanceToConnectionPropertiesWhenClickingChildOfRootNode()
|
||||
{
|
||||
// connection with a normal parent container
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var containerWhoseParentIsRoot = new ContainerInfo();
|
||||
var connection = new ConnectionInfo();
|
||||
root.AddChild(containerWhoseParentIsRoot);
|
||||
containerWhoseParentIsRoot.AddChild(connection);
|
||||
|
||||
_configWindow.SelectedTreeNode = connection;
|
||||
_configWindow.ShowInheritanceProperties();
|
||||
|
||||
_configWindow.SelectedTreeNode = containerWhoseParentIsRoot;
|
||||
Assert.That(_configWindow.PropertiesVisible, Is.True,
|
||||
() => "The property mode should switch from inheritance to connection properties " +
|
||||
"when clicking on a container whose parent is the root node.");
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(EveryNodeType))]
|
||||
public void DefaultConnectionPropertiesCanBeShownRegardlessOfWhichNodeIsSelected(ConnectionInfo selectedObject)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = selectedObject;
|
||||
Assert.That(_configWindow.CanShowDefaultProperties, Is.True);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(EveryNodeType))]
|
||||
public void DefaultInheritancePropertiesCanBeShownRegardlessOfWhichNodeIsSelected(ConnectionInfo selectedObject)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = selectedObject;
|
||||
Assert.That(_configWindow.CanShowDefaultInheritance, Is.True);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(EveryNodeType))]
|
||||
public void ConnectionPropertiesCanAlwaysBeShownUnlessNothingIsSelected(ConnectionInfo selectedObject)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = selectedObject;
|
||||
|
||||
var selectedObjectNotNull = selectedObject != null;
|
||||
Assert.That(_configWindow.CanShowProperties, Is.EqualTo(selectedObjectNotNull));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(EveryNodeType))]
|
||||
public void InheritancePropertiesAreVisibleInCertainCases(ConnectionInfo selectedObject)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = selectedObject;
|
||||
|
||||
var shouldBeAvailable = selectedObject != null &&
|
||||
!(selectedObject is RootNodeInfo) &&
|
||||
!(selectedObject is PuttySessionInfo) &&
|
||||
!(selectedObject.Parent is RootNodeInfo);
|
||||
|
||||
Assert.That(_configWindow.CanShowInheritance, Is.EqualTo(shouldBeAvailable));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ConnectionInfoGeneralTestCases()
|
||||
{
|
||||
var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType<ProtocolType>();
|
||||
var testCases = new List<TestCaseData>();
|
||||
@@ -80,6 +162,56 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
return testCases;
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> EveryNodeType()
|
||||
{
|
||||
var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType<ProtocolType>().ToList();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var container = new ContainerInfo();
|
||||
var connectionsWithNormalParent = protocolTypes
|
||||
.Select(protocolType =>
|
||||
{
|
||||
var c = new ConnectionInfo {Protocol = protocolType};
|
||||
c.SetParent(container);
|
||||
return new TestCaseData(c).SetName(protocolType + ", Connection, NormalParent");
|
||||
});
|
||||
|
||||
var connectionsWithRootParent = protocolTypes
|
||||
.Select(protocolType =>
|
||||
{
|
||||
var c = new ConnectionInfo { Protocol = protocolType };
|
||||
c.SetParent(root);
|
||||
return new TestCaseData(c).SetName(protocolType + ", Connection, RootParent");
|
||||
});
|
||||
|
||||
var contianersWithNormalParent = protocolTypes
|
||||
.Select(protocolType =>
|
||||
{
|
||||
var c = new ContainerInfo { Protocol = protocolType };
|
||||
c.SetParent(container);
|
||||
return new TestCaseData(c).SetName(protocolType + ", Connection, NormalParent");
|
||||
});
|
||||
|
||||
var containersWithRootParent = protocolTypes
|
||||
.Select(protocolType =>
|
||||
{
|
||||
var c = new ContainerInfo { Protocol = protocolType };
|
||||
c.SetParent(root);
|
||||
return new TestCaseData(c).SetName(protocolType + ", Connection, RootParent");
|
||||
});
|
||||
|
||||
return connectionsWithNormalParent
|
||||
.Concat(connectionsWithRootParent)
|
||||
.Concat(contianersWithNormalParent)
|
||||
.Concat(containersWithRootParent)
|
||||
.Concat(new[]
|
||||
{
|
||||
new TestCaseData(root).SetName("RootNode"),
|
||||
new TestCaseData(new RootPuttySessionsNodeInfo()).SetName("RootPuttyNode"),
|
||||
new TestCaseData(new PuttySessionInfo()).SetName("PuttyNode"),
|
||||
new TestCaseData(null).SetName("Null"),
|
||||
});
|
||||
}
|
||||
|
||||
internal static ConnectionInfo ConstructConnectionInfo(ProtocolType protocol, bool isContainer)
|
||||
{
|
||||
// build connection info. set certain connection properties so
|
||||
@@ -114,6 +246,7 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
nameof(ConnectionInfo.PostExtApp),
|
||||
nameof(ConnectionInfo.MacAddress),
|
||||
nameof(ConnectionInfo.UserField),
|
||||
nameof(ConnectionInfo.Favorite),
|
||||
};
|
||||
|
||||
if (!isContainer)
|
||||
@@ -153,6 +286,7 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
nameof(ConnectionInfo.RedirectPorts),
|
||||
nameof(ConnectionInfo.RedirectSmartCards),
|
||||
nameof(ConnectionInfo.RedirectSound),
|
||||
nameof(ConnectionInfo.RedirectAudioCapture),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.VNC:
|
||||
|
||||
@@ -6,7 +6,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public abstract class ConfigWindowSpecialTestsBase
|
||||
public abstract class ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected abstract ProtocolType Protocol { get; }
|
||||
protected bool TestAgainstContainerInfo { get; set; } = false;
|
||||
@@ -20,10 +20,7 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
ConnectionInfo = ConfigWindowGeneralTests.ConstructConnectionInfo(Protocol, TestAgainstContainerInfo);
|
||||
ExpectedPropertyList = ConfigWindowGeneralTests.BuildExpectedConnectionInfoPropertyList(Protocol, TestAgainstContainerInfo);
|
||||
|
||||
ConfigWindow = new ConfigWindow
|
||||
{
|
||||
PropertiesVisible = true,
|
||||
};
|
||||
ConfigWindow = new ConfigWindow();
|
||||
}
|
||||
|
||||
public void RunVerification()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -17,6 +18,8 @@
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -55,21 +58,21 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
|
||||
<HintPath>..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.4.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
|
||||
<HintPath>..\packages\BouncyCastle.1.8.4\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.4.2.0\lib\net45\Castle.Core.dll</HintPath>
|
||||
<HintPath>..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NSubstitute, Version=3.1.0.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NSubstitute.3.1.0\lib\net46\NSubstitute.dll</HintPath>
|
||||
<Reference Include="NSubstitute, Version=4.0.0.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NSubstitute.4.0.0\lib\net46\NSubstitute.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NUnitForms">
|
||||
<HintPath>nUnitForms\bin\NUnitForms.dll</HintPath>
|
||||
@@ -82,8 +85,11 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
@@ -108,6 +114,7 @@
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="App\ImportTests.cs" />
|
||||
<Compile Include="App\UpdaterTests.cs" />
|
||||
<Compile Include="BinaryFileTests.cs" />
|
||||
<Compile Include="Config\Connections\Multiuser\ConnectionsUpdateAvailableEventArgsTests.cs" />
|
||||
@@ -176,6 +183,7 @@
|
||||
<Compile Include="TestHelpers\FileTestHelpers.cs" />
|
||||
<Compile Include="TestHelpers\Randomizer.cs" />
|
||||
<Compile Include="TestHelpers\SerializableConnectionInfoAllPropertiesOfType.cs" />
|
||||
<Compile Include="Tools\DisposableActionTests.cs" />
|
||||
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
|
||||
<Compile Include="Tools\FullyObservableCollectionTests.cs" />
|
||||
<Compile Include="Tools\OptionalTests.cs" />
|
||||
@@ -210,6 +218,7 @@
|
||||
<Compile Include="Tree\ClickHandlers\SwitchToConnectionClickHandlerTests.cs" />
|
||||
<Compile Include="Tree\SelectedConnectionDeletionConfirmerTests.cs" />
|
||||
<Compile Include="UI\Controls\ConnectionTreeTests.cs" />
|
||||
<Compile Include="UI\Controls\FilteredPropertyGridTests.cs" />
|
||||
<Compile Include="UI\Controls\PageSequenceTests.cs" />
|
||||
<Compile Include="UI\Controls\SecureTextBoxTestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -268,6 +277,8 @@
|
||||
<None Include="Resources\test_rdcman_v2_2_badschemaversion.rdg" />
|
||||
<None Include="Resources\test_rdcman_v2_2_schema1.rdg" />
|
||||
<None Include="Resources\test_RDCMan_v2_7_schema3.rdg" />
|
||||
<None Include="Resources\test_rdcman_v2_7_schema3_empty_values.rdg" />
|
||||
<None Include="Resources\test_rdcman_v2_7_schema3_null_values.rdg" />
|
||||
<None Include="Resources\test_remotedesktopconnection.rdp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -326,6 +337,12 @@
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle" version="1.8.1" targetFramework="net46" />
|
||||
<package id="Castle.Core" version="4.2.0" targetFramework="net46" />
|
||||
<package id="BouncyCastle" version="1.8.4" targetFramework="net46" />
|
||||
<package id="Castle.Core" version="4.3.1" targetFramework="net46" />
|
||||
<package id="DockPanelSuite" version="3.0.6" targetFramework="net46" />
|
||||
<package id="log4net" version="2.0.8" targetFramework="net46" />
|
||||
<package id="NSubstitute" version="3.1.0" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.Console" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NSubstitute" version="4.0.0" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.11.0" targetFramework="net46" />
|
||||
<package id="NUnit.Console" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.9.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.3" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.VSProjectLoader" version="3.7.0" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.5" targetFramework="net46" />
|
||||
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net46" />
|
||||
<package id="ObjectListView.Official" version="2.9.1" targetFramework="net46" />
|
||||
<package id="OpenCover" version="4.6.519" targetFramework="net46" />
|
||||
<package id="ReportGenerator" version="3.0.2" targetFramework="net46" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net46" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net46" />
|
||||
</packages>
|
||||
44
mRemoteV1/.editorconfig
Normal file
44
mRemoteV1/.editorconfig
Normal file
@@ -0,0 +1,44 @@
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = crlf
|
||||
indent_style = space
|
||||
|
||||
[*.xml]
|
||||
indent_size = 4
|
||||
|
||||
[*.cs]
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8-bom
|
||||
|
||||
# Organize usings
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# this. preferences
|
||||
dotnet_style_qualification_for_field = false:none
|
||||
dotnet_style_qualification_for_property = false:none
|
||||
dotnet_style_qualification_for_method = false:none
|
||||
dotnet_style_qualification_for_event = false:none
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
@@ -21,7 +21,8 @@ namespace mRemoteNG.App
|
||||
{
|
||||
if (Settings.Default.OverrideFIPSCheck)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...", true);
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,7 +35,12 @@ namespace mRemoteNG.App
|
||||
//About to pop up a message, let's not block it...
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, errorText, "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.OkCancel, ESysIcons.Warning, ESysIcons.Warning);
|
||||
var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName,
|
||||
Language.strCompatibilityProblemDetected, errorText, "",
|
||||
"",
|
||||
Language.strCheckboxDoNotShowThisMessageAgain,
|
||||
ETaskDialogButtons.OkCancel, ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked && ShouldIStayOrShouldIGo == DialogResult.OK)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.ErrorMsg, "User requests that FIPS check be overridden", true);
|
||||
@@ -58,7 +64,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static bool FipsPolicyEnabledForServer2008AndNewer()
|
||||
{
|
||||
var regKey = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var regKey =
|
||||
Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var fipsPolicy = regKey?.GetValue("Enabled");
|
||||
if (fipsPolicy == null) return false;
|
||||
fipsPolicy = Convert.ToInt32(fipsPolicy);
|
||||
@@ -83,9 +90,14 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
if (proccesses.Length <= 0) return;
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected, Application.ProductName), "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok, ESysIcons.Warning, ESysIcons.Warning);
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected,
|
||||
string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected,
|
||||
Application.ProductName), "",
|
||||
"", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok,
|
||||
ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
Settings.Default.CompatibilityWarnLenovoAutoScrollUtility = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,92 +17,101 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
public static class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
case ExportForm.ExportScope.SelectedConnection:
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Export.ExportToFile() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName,
|
||||
SaveFormat saveFormat,
|
||||
SaveFilter saveFilter,
|
||||
ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString.ConvertToSecureString() ?? new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
case SaveFormat.mRCSV:
|
||||
serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString
|
||||
.ConvertToSecureString() ??
|
||||
new RootNodeInfo(RootNodeType
|
||||
.Connection)
|
||||
.PasswordString
|
||||
.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
case SaveFormat.mRCSV:
|
||||
serializer =
|
||||
new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
fileDataProvider.Save(serializedData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Import;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Import
|
||||
public static class Import
|
||||
{
|
||||
public static void ImportFromFile(ContainerInfo importDestinationContainer)
|
||||
{
|
||||
@@ -35,22 +36,12 @@ namespace mRemoteNG.App
|
||||
if (openFileDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
foreach (var fileName in openFileDialog.FileNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
var importer = BuildConnectionImporterFromFileExtension(fileName);
|
||||
importer.Import(fileName, importDestinationContainer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
HeadlessFileImport(
|
||||
openFileDialog.FileNames,
|
||||
importDestinationContainer,
|
||||
Runtime.ConnectionsService,
|
||||
fileName => MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -59,12 +50,40 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
public static void HeadlessFileImport(
|
||||
IEnumerable<string> filePaths,
|
||||
ContainerInfo importDestinationContainer,
|
||||
ConnectionsService connectionsService,
|
||||
Action<string> exceptionAction = null)
|
||||
{
|
||||
using (connectionsService.BatchedSavingContext())
|
||||
{
|
||||
foreach (var fileName in filePaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
var importer = BuildConnectionImporterFromFileExtension(fileName);
|
||||
importer.Import(fileName, importDestinationContainer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exceptionAction?.Invoke(fileName);
|
||||
Runtime.MessageCollector.AddExceptionMessage($"Error occurred while importing file '{fileName}'.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath,
|
||||
ContainerInfo importDestinationContainer,
|
||||
bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOu);
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
using (Runtime.ConnectionsService.BatchedSavingContext())
|
||||
{
|
||||
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOu);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -72,13 +91,17 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts,
|
||||
ProtocolType protocol,
|
||||
ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var importer = new PortScanImporter(protocol);
|
||||
importer.Import(hosts, importDestinationContainer);
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
using (Runtime.ConnectionsService.BatchedSavingContext())
|
||||
{
|
||||
var importer = new PortScanImporter(protocol);
|
||||
importer.Import(hosts, importDestinationContainer);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class ConnectionsFileInfo
|
||||
public static class ConnectionsFileInfo
|
||||
{
|
||||
public static readonly string DefaultConnectionsPath = SettingsFileInfo.SettingsPath;
|
||||
public static readonly string DefaultConnectionsFile = "confCons.xml";
|
||||
public static readonly string DefaultConnectionsFileNew = "confConsNew.xml";
|
||||
public static readonly double ConnectionFileVersion = 2.6;
|
||||
public static readonly double ConnectionFileVersion = 2.7;
|
||||
}
|
||||
}
|
||||
@@ -9,45 +9,53 @@ using static System.Environment;
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static readonly string ProductName = Application.ProductName;
|
||||
public static readonly string Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;
|
||||
|
||||
public static readonly string Copyright =
|
||||
((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
|
||||
typeof(AssemblyCopyrightAttribute), false))
|
||||
.Copyright;
|
||||
|
||||
public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
|
||||
public static string UserAgent
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
System.Version.TryParse(ApplicationVersion, out var v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,22 @@ namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class SettingsFileInfo
|
||||
{
|
||||
private static readonly string ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
private static readonly string ExePath =
|
||||
Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
|
||||
public static string SettingsPath =>
|
||||
Runtime.IsPortableEdition
|
||||
? ExePath
|
||||
: Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
|
||||
public static string SettingsPath => Runtime.IsPortableEdition ? ExePath : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
public static string LayoutFileName { get; } = "pnlLayout.xml";
|
||||
public static string ExtAppsFilesName { get; } = "extApps.xml";
|
||||
public static string ThemesFileName { get; } = "Themes.xml";
|
||||
public static string ThemeFolder { get; } = SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
public static string InstalledThemeFolder { get; } = ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
|
||||
public static string ThemeFolder { get; } =
|
||||
SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
|
||||
public static string InstalledThemeFolder { get; } =
|
||||
ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
@@ -27,7 +28,9 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static string GetChannelFileName(string channel)
|
||||
{
|
||||
return Runtime.IsPortableEdition ? GetChannelFileNamePortableEdition(channel) : GetChannelFileNameNormalEdition(channel);
|
||||
return Runtime.IsPortableEdition
|
||||
? GetChannelFileNamePortableEdition(channel)
|
||||
: GetChannelFileNameNormalEdition(channel);
|
||||
}
|
||||
|
||||
private static string GetChannelFileNameNormalEdition(string channel)
|
||||
@@ -62,7 +65,8 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static Uri GetUpdateTxtUri(string channel)
|
||||
{
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress), new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress),
|
||||
new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
}
|
||||
|
||||
private static bool IsValidChannel(string s)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
public ConnectionIconLoader(string folderPath)
|
||||
{
|
||||
if(string.IsNullOrEmpty(folderPath))
|
||||
if (string.IsNullOrEmpty(folderPath))
|
||||
throw new ArgumentException($"{nameof(folderPath)} must be a valid folder path.");
|
||||
|
||||
_path = folderPath;
|
||||
|
||||
@@ -3,14 +3,16 @@ using mRemoteNG.Config.Connections;
|
||||
|
||||
namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class CredsAndConsSetup
|
||||
public class CredsAndConsSetup
|
||||
{
|
||||
public void LoadCredsAndCons()
|
||||
{
|
||||
new SaveConnectionsOnEdit(Runtime.ConnectionsService);
|
||||
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation && !File.Exists(Runtime.ConnectionsService.GetStartupConnectionFileName()))
|
||||
Runtime.ConnectionsService.NewConnectionsFile(Runtime.ConnectionsService.GetStartupConnectionFileName());
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation &&
|
||||
!File.Exists(Runtime.ConnectionsService.GetStartupConnectionFileName()))
|
||||
Runtime.ConnectionsService.NewConnectionsFile(Runtime.ConnectionsService
|
||||
.GetStartupConnectionFileName());
|
||||
|
||||
Runtime.LoadConnections();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class MessageCollectorSetup
|
||||
{
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector, IList<IMessageWriter> messageWriterList)
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector,
|
||||
IList<IMessageWriter> messageWriterList)
|
||||
{
|
||||
messageCollector.CollectionChanged += (o, args) =>
|
||||
{
|
||||
@@ -37,34 +38,37 @@ namespace mRemoteNG.App.Initialization
|
||||
private static IMessageWriter BuildTextLogMessageWriter()
|
||||
{
|
||||
return new MessageTypeFilterDecorator(
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildNotificationPanelMessageWriter()
|
||||
{
|
||||
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new NotificationPanelMessageWriter(Windows.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new
|
||||
NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new
|
||||
NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new
|
||||
NotificationPanelMessageWriter(Windows
|
||||
.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildPopupMessageWriter()
|
||||
{
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
osVersion = Convert.ToString(managementObject.GetPropertyValue("Caption")).Trim();
|
||||
@@ -54,6 +55,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system information from WMI.", ex);
|
||||
}
|
||||
|
||||
var osData = string.Join(" ", osVersion, servicePack);
|
||||
return osData;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
servicePack = $"Service Pack {servicePackNumber}";
|
||||
}
|
||||
|
||||
return servicePack;
|
||||
}
|
||||
|
||||
@@ -73,7 +76,8 @@ namespace mRemoteNG.App.Initialization
|
||||
var architecture = string.Empty;
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
var addressWidth = Convert.ToInt32(managementObject.GetPropertyValue("AddressWidth"));
|
||||
@@ -84,6 +88,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system address width from WMI.", ex);
|
||||
}
|
||||
|
||||
return architecture;
|
||||
}
|
||||
|
||||
@@ -110,7 +115,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
private void LogCultureData()
|
||||
{
|
||||
var data = $"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
var data =
|
||||
$"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, data, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Windows.Forms;
|
||||
using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Config;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public class Logger
|
||||
public class Logger
|
||||
{
|
||||
public static readonly Logger Instance = new Logger();
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace mRemoteNG.App
|
||||
fileAppender.File = path;
|
||||
fileAppender.ActivateOptions();
|
||||
}
|
||||
|
||||
Log = LogManager.GetLogger("Logger");
|
||||
}
|
||||
|
||||
@@ -56,7 +58,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static string GetLogPathNormalEdition()
|
||||
{
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Application.ProductName);
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
Application.ProductName);
|
||||
}
|
||||
|
||||
private static string GetLogPathPortableEdition()
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace mRemoteNG.App
|
||||
public static class NativeMethods
|
||||
{
|
||||
#region Functions
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool AppendMenu(IntPtr hMenu, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
|
||||
@@ -19,7 +20,10 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr CreatePopupMenu();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle,
|
||||
IntPtr childAfter,
|
||||
string lclassName,
|
||||
string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr GetForegroundWindow();
|
||||
@@ -28,7 +32,11 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool InsertMenu(IntPtr hMenu, int uPosition, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
internal static extern bool InsertMenu(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr uIDNewItem,
|
||||
string lpNewItem);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int IsIconic(IntPtr hWnd);
|
||||
@@ -55,7 +63,10 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, string lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd, [In] uint msg, [Out] StringBuilder wParam, [In] IntPtr lParam);
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd,
|
||||
[In] uint msg,
|
||||
[Out] StringBuilder wParam,
|
||||
[In] IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
|
||||
@@ -64,7 +75,11 @@ namespace mRemoteNG.App
|
||||
internal static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu, int uPosition, int uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr hBitmapUnchecked,
|
||||
IntPtr hBitmapChecked);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|
||||
@@ -93,9 +108,11 @@ namespace mRemoteNG.App
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
internal static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Structures
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WINDOWPOS
|
||||
{
|
||||
@@ -131,9 +148,11 @@ namespace mRemoteNG.App
|
||||
public long right;
|
||||
public long bottom;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
public static int MAKELONG(int wLow, int wHigh)
|
||||
{
|
||||
return wLow | wHigh << 16;
|
||||
@@ -163,28 +182,37 @@ namespace mRemoteNG.App
|
||||
{
|
||||
return HIWORD(value.ToInt32());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
|
||||
public const int TRUE = 1;
|
||||
|
||||
#region GetWindowLong
|
||||
|
||||
public const int GWL_STYLE = (-16);
|
||||
|
||||
#endregion
|
||||
|
||||
#region AppendMenu / ModifyMenu / DeleteMenu / RemoveMenu
|
||||
|
||||
public const int MF_BYCOMMAND = 0x0;
|
||||
public const int MF_BYPOSITION = 0x400;
|
||||
public const int MF_STRING = 0x0;
|
||||
public const int MF_POPUP = 0x10;
|
||||
public const int MF_SEPARATOR = 0x800;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_LBUTTONDOWN / WM_LBUTTONUP
|
||||
|
||||
public const int MK_LBUTTON = 0x1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowWindow
|
||||
|
||||
public const uint SW_HIDE = 0;
|
||||
public const uint SW_SHOWNORMAL = 1;
|
||||
public const uint SW_SHOWMINIMIZED = 2;
|
||||
@@ -196,9 +224,11 @@ namespace mRemoteNG.App
|
||||
public const uint SW_SHOWMINNOACTIVE = 7;
|
||||
public const uint SW_SHOWNA = 8;
|
||||
public const uint SW_RESTORE = 9;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetWindowPos / WM_WINDOWPOSCHANGING / WM_WINDOWPOSCHANGED
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current size (ignores the cx and cy parameters).
|
||||
/// </summary>
|
||||
@@ -283,15 +313,19 @@ namespace mRemoteNG.App
|
||||
///
|
||||
/// </summary>
|
||||
public const int SWP_STATECHANGED = 0x8000;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Placement Flags (WPF)
|
||||
|
||||
public const uint WPF_SETMINPOSITION = 0x1;
|
||||
public const uint WPF_RESTORETOMAXIMIZED = 0x2;
|
||||
public const uint WPF_ASYNCWINDOWPLACEMENT = 0x4;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_ACTIVATE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -309,9 +343,11 @@ namespace mRemoteNG.App
|
||||
/// windows use different input queues, the message is sent asynchronously, so the window is activated immediately.
|
||||
/// </summary>
|
||||
public const int WA_CLICKACTIVE = 0x2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Messages
|
||||
|
||||
/// <summary>
|
||||
/// Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.
|
||||
/// </summary>
|
||||
@@ -466,29 +502,38 @@ namespace mRemoteNG.App
|
||||
/// Sent to the first window in the clipboard viewer chain when a window is being removed from the chain.
|
||||
/// </summary>
|
||||
public const int WM_CHANGECBCHAIN = 0x30D;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Styles
|
||||
|
||||
public const int WS_MAXIMIZE = 0x1000000;
|
||||
public const int WS_VISIBLE = 0x10000000;
|
||||
public const int WS_CHILD = 0x40000000;
|
||||
public const int WS_EX_MDICHILD = 0x40;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual Key Codes
|
||||
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_C = 0x67;
|
||||
|
||||
#endregion
|
||||
|
||||
#region EM
|
||||
|
||||
public const uint ECM_FIRST = 0x1500;
|
||||
public const uint EM_SETCUEBANNER = ECM_FIRST + 1;
|
||||
public const uint EM_GETCUEBANNER = ECM_FIRST + 2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region LB
|
||||
|
||||
public const int LB_ERR = -1;
|
||||
public const int LB_SELECTSTRING = 0x18C;
|
||||
|
||||
#endregion
|
||||
|
||||
#region TCM
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using mRemoteNG.UI.Forms;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -67,9 +67,12 @@ namespace mRemoteNG.App
|
||||
var currentProcess = Process.GetCurrentProcess();
|
||||
foreach (var enumeratedProcess in Process.GetProcessesByName(currentProcess.ProcessName))
|
||||
{
|
||||
if (enumeratedProcess.Id != currentProcess.Id && enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName && enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
if (enumeratedProcess.Id != currentProcess.Id &&
|
||||
enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName &&
|
||||
enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
windowHandle = enumeratedProcess.MainWindowHandle;
|
||||
}
|
||||
|
||||
return windowHandle;
|
||||
}
|
||||
|
||||
@@ -82,12 +85,18 @@ namespace mRemoteNG.App
|
||||
|
||||
private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
if (!FrmSplashScreen.getInstance().IsDisposed)
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
var window = new UnhandledExceptionWindow(e.Exception, false);
|
||||
window.ShowDialog(FrmMain.Default);
|
||||
}
|
||||
|
||||
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (!FrmSplashScreen.getInstance().IsDisposed)
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
var window = new UnhandledExceptionWindow(e.ExceptionObject as Exception, e.IsTerminating);
|
||||
window.ShowDialog(FrmMain.Default);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,17 @@ namespace mRemoteNG.App
|
||||
public static MessageCollector MessageCollector { get; } = new MessageCollector();
|
||||
public static NotificationAreaIcon NotificationAreaIcon { get; set; }
|
||||
public static ExternalToolsService ExternalToolsService { get; } = new ExternalToolsService();
|
||||
public static SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static SecureString EncryptionKey { get; set; } =
|
||||
new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static ICredentialRepositoryList CredentialProviderCatalog { get; } = new CredentialRepositoryList();
|
||||
public static ConnectionsService ConnectionsService { get; } = new ConnectionsService(PuttySessionsManager.Instance);
|
||||
|
||||
public static ConnectionsService ConnectionsService { get; } =
|
||||
new ConnectionsService(PuttySessionsManager.Instance);
|
||||
|
||||
#region Connections Loading/Saving
|
||||
|
||||
public static void LoadConnectionsAsync()
|
||||
{
|
||||
var t = new Thread(LoadConnectionsBGd);
|
||||
@@ -106,8 +112,14 @@ namespace mRemoteNG.App
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain,
|
||||
Language.strCommandOpenConnectionFile,
|
||||
string.Format(Language.strCommandExitProgram,
|
||||
Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed,
|
||||
Language.strLoadFromSqlFailedContent,
|
||||
MiscTools.GetExceptionMessageRecursive(ex), "", "",
|
||||
commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
@@ -122,9 +134,13 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ex is FileNotFoundException && !withDialog)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), ex,
|
||||
MessageClass.InformationMsg);
|
||||
|
||||
string[] commandButtons =
|
||||
{
|
||||
@@ -140,13 +156,13 @@ namespace mRemoteNG.App
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
@@ -167,17 +183,24 @@ namespace mRemoteNG.App
|
||||
Application.Exit();
|
||||
answered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string
|
||||
.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), exc,
|
||||
MessageClass.InformationMsg);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
|
||||
MessageCollector.AddExceptionStackTrace(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoaded,
|
||||
connectionFileName), ex);
|
||||
if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
|
||||
{
|
||||
LoadConnections(withDialog);
|
||||
@@ -185,12 +208,16 @@ namespace mRemoteNG.App
|
||||
else
|
||||
{
|
||||
MessageBox.Show(FrmMain.Default,
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, ConnectionsService.GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine,
|
||||
Application.ProductName,
|
||||
ConnectionsService.GetStartupConnectionFileName(),
|
||||
MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -25,7 +26,10 @@ namespace mRemoteNG.App
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
public static void Cleanup(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -58,9 +62,13 @@ namespace mRemoteNG.App
|
||||
Runtime.ConnectionsService.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
private static void SaveSettings(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip,
|
||||
frmMain);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
|
||||
@@ -37,15 +37,16 @@ namespace mRemoteNG.App
|
||||
|
||||
public void InitializeProgram(MessageCollector messageCollector)
|
||||
{
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " +
|
||||
Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
var startupLogger = new StartupDataLogger(messageCollector);
|
||||
startupLogger.LogStartupData();
|
||||
CompatibilityChecker.CheckCompatibility(messageCollector);
|
||||
ParseCommandLineArgs(messageCollector);
|
||||
IeBrowserEmulation.Register();
|
||||
_connectionIconLoader.GetConnectionIcons();
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a=>"ConDefault"+a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a=>"InhDefault"+a);
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a => "ConDefault" + a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a => "InhDefault" + a);
|
||||
}
|
||||
|
||||
private static void ParseCommandLineArgs(MessageCollector messageCollector)
|
||||
@@ -59,7 +60,8 @@ namespace mRemoteNG.App
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Determining if we need a database syncronizer");
|
||||
if (!Settings.Default.UseSQLServer) return;
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Creating database syncronizer");
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer =
|
||||
new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer.Enable();
|
||||
}
|
||||
|
||||
@@ -74,7 +76,12 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
|
||||
var nextUpdateCheck = Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(TimeSpan.FromDays(Convert.ToDouble(Settings.Default.CheckForUpdatesFrequencyDays))));
|
||||
var nextUpdateCheck =
|
||||
Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(
|
||||
TimeSpan
|
||||
.FromDays(Convert.ToDouble(Settings
|
||||
.Default
|
||||
.CheckForUpdatesFrequencyDays))));
|
||||
if (!Settings.Default.UpdatePending && DateTime.UtcNow < nextUpdateCheck)
|
||||
{
|
||||
return;
|
||||
@@ -100,6 +107,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Error != null)
|
||||
{
|
||||
throw e.Error;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class SupportedCultures : Dictionary<string, string>
|
||||
{
|
||||
{
|
||||
private static SupportedCultures _Instance;
|
||||
|
||||
private static SupportedCultures SingletonInstance
|
||||
@@ -19,7 +19,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
|
||||
private SupportedCultures()
|
||||
private SupportedCultures()
|
||||
{
|
||||
foreach (var CultureName in Settings.Default.SupportedUICultures.Split(','))
|
||||
{
|
||||
@@ -30,7 +30,8 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Print($"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
Debug.Print(
|
||||
$"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,51 +42,52 @@ namespace mRemoteNG.App
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
|
||||
SingletonInstance.Keys.CopyTo(Names, 0);
|
||||
SingletonInstance.Values.CopyTo(NativeNames, 0);
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
public static List<string> CultureNativeNames
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ using System.Security.Cryptography;
|
||||
#if !PORTABLE
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
#else
|
||||
#else
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endif
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
@@ -66,7 +67,12 @@ namespace mRemoteNG.App.Update
|
||||
SetProxySettings(shouldWeUseProxy, proxyAddress, port, useAuthentication, username, password);
|
||||
}
|
||||
|
||||
public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password)
|
||||
public void SetProxySettings(bool useProxy,
|
||||
string address,
|
||||
int port,
|
||||
bool useAuthentication,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
if (useProxy && !string.IsNullOrEmpty(address))
|
||||
{
|
||||
@@ -107,7 +113,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
}
|
||||
|
||||
if (IsGetChangeLogRunning)
|
||||
@@ -131,27 +138,29 @@ namespace mRemoteNG.App.Update
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
}
|
||||
#if !PORTABLE
|
||||
CurrentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
CurrentUpdateInfo.UpdateFilePath =
|
||||
Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
#else
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
FileName = CurrentUpdateInfo.FileName,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
CurrentUpdateInfo.UpdateFilePath = sfd.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, CurrentUpdateInfo.UpdateFilePath);
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress,
|
||||
CurrentUpdateInfo.UpdateFilePath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -191,7 +200,9 @@ namespace mRemoteNG.App.Update
|
||||
}
|
||||
|
||||
private static DownloadStringCompletedEventArgs NewDownloadStringCompletedEventArgs(string result,
|
||||
Exception exception, bool cancelled, object userToken)
|
||||
Exception exception,
|
||||
bool cancelled,
|
||||
object userToken)
|
||||
{
|
||||
var type = typeof(DownloadStringCompletedEventArgs);
|
||||
const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
@@ -201,7 +212,7 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
if (constructor == null)
|
||||
return null;
|
||||
return (DownloadStringCompletedEventArgs) constructor.Invoke(arguments);
|
||||
return (DownloadStringCompletedEventArgs)constructor.Invoke(arguments);
|
||||
}
|
||||
|
||||
private DownloadStringCompletedEventArgs DownloadString(Uri address)
|
||||
@@ -326,11 +337,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,11 +353,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +369,15 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,11 +387,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ namespace mRemoteNG.App.Update
|
||||
public class UpdateFile
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Local
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public Dictionary<string, string> Items { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
public Dictionary<string, string> Items { get; } =
|
||||
new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public UpdateFile(string content)
|
||||
{
|
||||
FromString(content);
|
||||
@@ -24,8 +28,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(content)) return;
|
||||
|
||||
char[] keyValueSeparators = { ':', '=' };
|
||||
char[] commentCharacters = { '#', ';', '\'' };
|
||||
char[] keyValueSeparators = {':', '='};
|
||||
char[] commentCharacters = {'#', ';', '\''};
|
||||
|
||||
// no separators means no valid update data...
|
||||
if (content.Trim().IndexOfAny(keyValueSeparators) == -1) return;
|
||||
@@ -47,7 +51,7 @@ namespace mRemoteNG.App.Update
|
||||
continue;
|
||||
|
||||
// make sure we have valid data in both parts before adding to the collection. If either part is empty, then it's not valid data.
|
||||
if(string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
if (string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
continue;
|
||||
|
||||
Items.Add(parts[0].Trim(), parts[1].Trim());
|
||||
@@ -83,13 +87,14 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
var value = GetString("dURL");
|
||||
var sv = value.Split('/');
|
||||
return sv[sv.Length-1];
|
||||
return sv[sv.Length - 1];
|
||||
}
|
||||
|
||||
public string GetChecksum(string key = "Checksum")
|
||||
{
|
||||
return GetString(key).Replace(" ", "").ToUpperInvariant();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
|
||||
namespace mRemoteNG.App.Update
|
||||
@@ -43,6 +44,7 @@ namespace mRemoteNG.App.Update
|
||||
newInfo.Checksum = updateFile.GetChecksum();
|
||||
newInfo.IsValid = newInfo.CheckIfValid();
|
||||
}
|
||||
|
||||
return newInfo;
|
||||
}
|
||||
|
||||
@@ -50,11 +52,11 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(Version.ToString()))
|
||||
return false;
|
||||
if(string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
if (string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ChangeLogAddress.AbsoluteUri))
|
||||
return false;
|
||||
#if false
|
||||
#if false
|
||||
if (string.IsNullOrEmpty(ImageAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ImageLinkAddress.AbsoluteUri))
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace mRemoteNG.App
|
||||
internal static SSHTransferWindow SshtransferForm { get; private set; } = new SSHTransferWindow();
|
||||
|
||||
|
||||
|
||||
public static void Show(WindowType windowType)
|
||||
{
|
||||
try
|
||||
@@ -55,6 +54,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
}
|
||||
|
||||
break;
|
||||
case WindowType.SSHTransfer:
|
||||
if (SshtransferForm == null || SshtransferForm.IsDisposed)
|
||||
@@ -90,7 +90,8 @@ namespace mRemoteNG.App
|
||||
_ultravncscForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.ComponentsCheck:
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Showing ComponentsCheck window", true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Showing ComponentsCheck window", true);
|
||||
if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
|
||||
_componentscheckForm = new ComponentsCheckWindow();
|
||||
_componentscheckForm.Show(dockPanel);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace mRemoteNG.Config
|
||||
{
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
}
|
||||
@@ -36,10 +36,11 @@ namespace mRemoteNG.Config.Connections
|
||||
/// </summary>
|
||||
public string NewSourcePath { get; }
|
||||
|
||||
public ConnectionsLoadedEventArgs(
|
||||
Optional<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
|
||||
bool previousSourceWasDatabase, bool newSourceIsDatabase,
|
||||
string newSourcePath)
|
||||
public ConnectionsLoadedEventArgs(Optional<ConnectionTreeModel> previousTreeModelModel,
|
||||
ConnectionTreeModel newTreeModelModel,
|
||||
bool previousSourceWasDatabase,
|
||||
bool newSourceIsDatabase,
|
||||
string newSourcePath)
|
||||
{
|
||||
if (previousTreeModelModel == null)
|
||||
throw new ArgumentNullException(nameof(previousTreeModelModel));
|
||||
@@ -55,4 +56,4 @@ namespace mRemoteNG.Config.Connections
|
||||
NewSourcePath = newSourcePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@ namespace mRemoteNG.Config.Connections
|
||||
public bool UsingDatabase { get; }
|
||||
public string ConnectionFileName { get; }
|
||||
|
||||
public ConnectionsSavedEventArgs(ConnectionTreeModel modelThatWasSaved, bool previouslyUsingDatabase, bool usingDatabase, string connectionFileName)
|
||||
public ConnectionsSavedEventArgs(ConnectionTreeModel modelThatWasSaved,
|
||||
bool previouslyUsingDatabase,
|
||||
bool usingDatabase,
|
||||
string connectionFileName)
|
||||
{
|
||||
if (modelThatWasSaved == null)
|
||||
throw new ArgumentNullException(nameof(modelThatWasSaved));
|
||||
@@ -21,4 +24,4 @@ namespace mRemoteNG.Config.Connections
|
||||
ConnectionFileName = connectionFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,11 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
public void Save(ConnectionTreeModel connectionTreeModel, string propertyNameTrigger = "")
|
||||
{
|
||||
var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
|
||||
var csvConnectionsSerializer =
|
||||
new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
|
||||
var dataProvider = new FileDataProvider(_connectionFileName);
|
||||
var csvContent = csvConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
dataProvider.Save(csvContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@ using mRemoteNG.Config.DatabaseConnectors;
|
||||
|
||||
namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
public delegate void ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
public delegate void
|
||||
ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
|
||||
public class ConnectionsUpdateAvailableEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
_updateChecker.UpdateCheckStarted += OnUpdateCheckStarted;
|
||||
_updateChecker.UpdateCheckFinished += OnUpdateCheckFinished;
|
||||
_updateChecker.ConnectionsUpdateAvailable += (sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateChecker.ConnectionsUpdateAvailable +=
|
||||
(sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateTimer.Elapsed += (sender, args) => _updateChecker.IsUpdateAvailableAsync();
|
||||
ConnectionsUpdateAvailable += Load;
|
||||
}
|
||||
@@ -81,6 +82,7 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToAlsoFreeManagedObjects) return;
|
||||
|
||||
@@ -4,23 +4,23 @@ using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Messages;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data.Common;
|
||||
using System.Threading;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsUpdateChecker : IConnectionsUpdateChecker
|
||||
{
|
||||
private readonly SqlDatabaseConnector _sqlConnector;
|
||||
private readonly SqlCommand _sqlQuery;
|
||||
private readonly IDatabaseConnector _dbConnector;
|
||||
private readonly DbCommand _dbQuery;
|
||||
private DateTime LastUpdateTime => Runtime.ConnectionsService.LastSqlUpdate;
|
||||
private DateTime _lastDatabaseUpdateTime;
|
||||
|
||||
|
||||
public SqlConnectionsUpdateChecker()
|
||||
{
|
||||
_sqlConnector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
_sqlQuery = new SqlCommand("SELECT * FROM tblUpdate", _sqlConnector.SqlConnection);
|
||||
_dbConnector = DatabaseConnectorFactory.DatabaseConnectorFromSettings();
|
||||
_dbQuery = _dbConnector.DbCommand("SELECT * FROM tblUpdate");
|
||||
_lastDatabaseUpdateTime = default(DateTime);
|
||||
}
|
||||
|
||||
@@ -46,11 +46,13 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
try
|
||||
{
|
||||
_sqlConnector.Connect();
|
||||
_dbConnector.Connect();
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Unable to connect to Sql DB to check for updates." + Environment.NewLine + e.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Unable to connect to Sql DB to check for updates." +
|
||||
Environment.NewLine + e.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,9 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private bool CheckIfIAmTheLastOneUpdated(DateTime lastUpdateInDb)
|
||||
{
|
||||
DateTime lastSqlUpdateWithoutMilliseconds = new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond), LastUpdateTime.Kind);
|
||||
DateTime lastSqlUpdateWithoutMilliseconds =
|
||||
new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond),
|
||||
LastUpdateTime.Kind);
|
||||
return lastUpdateInDb == lastSqlUpdateWithoutMilliseconds;
|
||||
}
|
||||
|
||||
@@ -72,7 +76,7 @@ namespace mRemoteNG.Config.Connections
|
||||
var lastUpdateInDb = default(DateTime);
|
||||
try
|
||||
{
|
||||
var sqlReader = _sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
var sqlReader = _dbQuery.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
sqlReader.Read();
|
||||
if (sqlReader.HasRows)
|
||||
lastUpdateInDb = Convert.ToDateTime(sqlReader["LastUpdate"]);
|
||||
@@ -80,20 +84,25 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Error executing Sql query to get updates from the DB." + Environment.NewLine + ex.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Error executing Sql query to get updates from the DB." +
|
||||
Environment.NewLine + ex.Message, true);
|
||||
}
|
||||
|
||||
_lastDatabaseUpdateTime = lastUpdateInDb;
|
||||
return lastUpdateInDb;
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler UpdateCheckStarted;
|
||||
|
||||
private void RaiseUpdateCheckStartedEvent()
|
||||
{
|
||||
UpdateCheckStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event UpdateCheckFinishedEventHandler UpdateCheckFinished;
|
||||
|
||||
private void RaiseUpdateCheckFinishedEvent(bool updateAvailable)
|
||||
{
|
||||
var args = new ConnectionsUpdateCheckFinishedEventArgs {UpdateAvailable = updateAvailable};
|
||||
@@ -101,10 +110,11 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
|
||||
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
|
||||
|
||||
private void RaiseConnectionsUpdateAvailableEvent()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Remote connection update is available");
|
||||
var args = new ConnectionsUpdateAvailableEventArgs(_sqlConnector, _lastDatabaseUpdateTime);
|
||||
var args = new ConnectionsUpdateAvailableEventArgs(_dbConnector, _lastDatabaseUpdateTime);
|
||||
ConnectionsUpdateAvailable?.Invoke(this, args);
|
||||
}
|
||||
|
||||
@@ -116,9 +126,9 @@ namespace mRemoteNG.Config.Connections
|
||||
private void Dispose(bool itIsSafeToDisposeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToDisposeManagedObjects) return;
|
||||
_sqlConnector.Disconnect();
|
||||
_sqlConnector.Dispose();
|
||||
_sqlQuery.Dispose();
|
||||
_dbConnector.Disconnect();
|
||||
_dbConnector.Dispose();
|
||||
_dbQuery.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,11 @@ namespace mRemoteNG.Config.Connections
|
||||
connectionsService.ConnectionsLoaded += ConnectionsServiceOnConnectionsLoaded;
|
||||
}
|
||||
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender,
|
||||
ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
{
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged +=
|
||||
ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
|
||||
|
||||
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)
|
||||
@@ -31,12 +33,15 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender,
|
||||
PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit(propertyChangedEventArgs.PropertyName);
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender,
|
||||
NotifyCollectionChangedEventArgs
|
||||
notifyCollectionChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit();
|
||||
}
|
||||
@@ -51,4 +56,4 @@ namespace mRemoteNG.Config.Connections
|
||||
_connectionsService.SaveConnectionsAsync(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@
|
||||
mRCSV,
|
||||
SQL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.MsSql;
|
||||
using mRemoteNG.Config.Serializers.Versioning;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Authentication;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsLoader : IConnectionsLoader
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> _localConnectionPropertiesDeserializer;
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>
|
||||
_localConnectionPropertiesDeserializer;
|
||||
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; } =
|
||||
() => MiscTools.PasswordDialog("", false);
|
||||
|
||||
public SqlConnectionsLoader(
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
_localConnectionPropertiesDeserializer = localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_localConnectionPropertiesDeserializer =
|
||||
localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_dataProvider = dataProvider.ThrowIfNull(nameof(dataProvider));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Load()
|
||||
{
|
||||
var connector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
var connector = DatabaseConnectorFactory.DatabaseConnectorFromSettings();
|
||||
var dataProvider = new SqlDataProvider(connector);
|
||||
var metaDataRetriever = new SqlDatabaseMetaDataRetriever();
|
||||
var databaseVersionVerifier = new SqlDatabaseVersionVerifier(connector);
|
||||
var cryptoProvider = new LegacyRijndaelCryptographyProvider();
|
||||
|
||||
var metaData = metaDataRetriever.GetDatabaseMetaData(connector);
|
||||
var metaData = metaDataRetriever.GetDatabaseMetaData(connector) ??
|
||||
HandleFirstRun(metaDataRetriever, connector);
|
||||
var decryptionKey = GetDecryptionKey(metaData);
|
||||
|
||||
if (!decryptionKey.Any())
|
||||
@@ -60,7 +64,9 @@ namespace mRemoteNG.Config.Connections
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var cipherText = metaData.Protected;
|
||||
var authenticator = new PasswordAuthenticator(cryptographyProvider, cipherText, AuthenticationRequestor);
|
||||
var authenticated = authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword.ConvertToSecureString());
|
||||
var authenticated =
|
||||
authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword
|
||||
.ConvertToSecureString());
|
||||
|
||||
if (authenticated)
|
||||
return authenticator.LastAuthenticatedPassword;
|
||||
@@ -74,16 +80,23 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
rootNode
|
||||
.GetRecursiveChildList()
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.ForEach(x =>
|
||||
{
|
||||
x.Connection.PleaseConnect = x.LocalProperties.Connected;
|
||||
x.Connection.Favorite = x.LocalProperties.Favorite;
|
||||
if (x.Connection is ContainerInfo container)
|
||||
container.IsExpanded = x.LocalProperties.Expanded;
|
||||
});
|
||||
}
|
||||
|
||||
private SqlConnectionListMetaData HandleFirstRun(SqlDatabaseMetaDataRetriever metaDataRetriever, IDatabaseConnector connector)
|
||||
{
|
||||
metaDataRetriever.WriteDatabaseMetaData(new RootNodeInfo(RootNodeType.Connection), connector);
|
||||
return metaDataRetriever.GetDatabaseMetaData(connector);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
using mRemoteNG.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.MsSql;
|
||||
using mRemoteNG.Config.Serializers.Versioning;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
@@ -12,27 +18,19 @@ using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using mRemoteNG.Connection;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
|
||||
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
|
||||
{
|
||||
private SecureString _password = Runtime.EncryptionKey;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public SqlConnectionsSaver(
|
||||
SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>
|
||||
localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
{
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
@@ -49,33 +47,36 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (PropertyIsLocalOnly(propertyNameTrigger))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SqlUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var sqlConnector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings())
|
||||
using (var dbConnector = DatabaseConnectorFactory.DatabaseConnectorFromSettings())
|
||||
{
|
||||
sqlConnector.Connect();
|
||||
var databaseVersionVerifier = new SqlDatabaseVersionVerifier(sqlConnector);
|
||||
dbConnector.Connect();
|
||||
var databaseVersionVerifier = new SqlDatabaseVersionVerifier(dbConnector);
|
||||
var metaDataRetriever = new SqlDatabaseMetaDataRetriever();
|
||||
var metaData = metaDataRetriever.GetDatabaseMetaData(sqlConnector);
|
||||
var metaData = metaDataRetriever.GetDatabaseMetaData(dbConnector);
|
||||
|
||||
if (!databaseVersionVerifier.VerifyDatabaseVersion(metaData.ConfVersion))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strErrorConnectionListSaveFailed);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
Language.strErrorConnectionListSaveFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateRootNodeTable(rootTreeNode, sqlConnector);
|
||||
UpdateConnectionsTable(rootTreeNode, sqlConnector);
|
||||
UpdateUpdatesTable(sqlConnector);
|
||||
metaDataRetriever.WriteDatabaseMetaData(rootTreeNode, dbConnector);
|
||||
UpdateConnectionsTable(rootTreeNode, dbConnector);
|
||||
UpdateUpdatesTable(dbConnector);
|
||||
|
||||
}
|
||||
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Saved connections to database");
|
||||
@@ -92,7 +93,8 @@ namespace mRemoteNG.Config.Connections
|
||||
private bool PropertyIsLocalOnly(string property)
|
||||
{
|
||||
return property == nameof(ConnectionInfo.OpenConnections) ||
|
||||
property == nameof(ContainerInfo.IsExpanded);
|
||||
property == nameof(ContainerInfo.IsExpanded) ||
|
||||
property == nameof(ContainerInfo.Favorite);
|
||||
}
|
||||
|
||||
private void UpdateLocalConnectionProperties(ContainerInfo rootNode)
|
||||
@@ -101,7 +103,8 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
ConnectionId = info.ConstantID,
|
||||
Connected = info.OpenConnections.Count > 0,
|
||||
Expanded = info is ContainerInfo c && c.IsExpanded
|
||||
Expanded = info is ContainerInfo c && c.IsExpanded,
|
||||
Favorite = info.Favorite,
|
||||
});
|
||||
|
||||
var serializedProperties = _localPropertiesSerializer.Serialize(a);
|
||||
@@ -109,7 +112,7 @@ namespace mRemoteNG.Config.Connections
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Saved local connection properties");
|
||||
}
|
||||
|
||||
private void UpdateRootNodeTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
|
||||
private void UpdateRootNodeTable(RootNodeInfo rootTreeNode, IDatabaseConnector databaseConnector)
|
||||
{
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
string strProtected;
|
||||
@@ -117,62 +120,63 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
if (rootTreeNode.Password)
|
||||
{
|
||||
_password = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsProtected", _password);
|
||||
var password = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsProtected", password);
|
||||
}
|
||||
else
|
||||
{
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", Runtime.EncryptionKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", Runtime.EncryptionKey);
|
||||
}
|
||||
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblRoot", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
var dbQuery = databaseConnector.DbCommand("DELETE FROM tblRoot");
|
||||
dbQuery.ExecuteNonQuery();
|
||||
|
||||
if (rootTreeNode != null)
|
||||
{
|
||||
sqlQuery =
|
||||
new SqlCommand(
|
||||
dbQuery =
|
||||
databaseConnector.DbCommand(
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")");
|
||||
dbQuery.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateConnectionsTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
|
||||
private void UpdateConnectionsTable(RootNodeInfo rootTreeNode, IDatabaseConnector databaseConnector)
|
||||
{
|
||||
var cryptoProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider, rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider,
|
||||
rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var dataTable = serializer.Serialize(rootTreeNode);
|
||||
var dataProvider = new SqlDataProvider(sqlDatabaseConnector);
|
||||
var dataProvider = new SqlDataProvider(databaseConnector);
|
||||
|
||||
var dbQuery = databaseConnector.DbCommand("DELETE FROM tblCons");
|
||||
dbQuery.ExecuteNonQuery();
|
||||
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblCons", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
dataProvider.Save(dataTable);
|
||||
}
|
||||
|
||||
private void UpdateUpdatesTable(SqlDatabaseConnector sqlDatabaseConnector)
|
||||
private void UpdateUpdatesTable(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblUpdate", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) + "\')", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
var dbQuery = databaseConnector.DbCommand("DELETE FROM tblUpdate");
|
||||
dbQuery.ExecuteNonQuery();
|
||||
dbQuery = databaseConnector.DbCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) + "\')");
|
||||
dbQuery.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private bool SqlUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,4 @@ namespace mRemoteNG.Config.Connections
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,17 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
cryptographyProvider,
|
||||
connectionTreeModel
|
||||
.RootNodes.OfType<RootNodeInfo>()
|
||||
.First().PasswordString
|
||||
.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer =
|
||||
new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
var xml = xmlConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
|
||||
var fileDataProvider = new FileDataProviderWithRollingBackup(_connectionFileName);
|
||||
@@ -51,4 +55,4 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,14 @@ namespace mRemoteNG.Config
|
||||
private readonly IEqualityComparer<ICredentialRecord> _credentialComparer = new CredentialDomainUserComparer();
|
||||
|
||||
// maps a connectioninfo (by its id) to the credential object that was harvested
|
||||
public Dictionary<Guid, ICredentialRecord> ConnectionToCredentialMap { get; } = new Dictionary<Guid, ICredentialRecord>();
|
||||
public Dictionary<Guid, ICredentialRecord> ConnectionToCredentialMap { get; } =
|
||||
new Dictionary<Guid, ICredentialRecord>();
|
||||
|
||||
public IEnumerable<ICredentialRecord> Harvest(XDocument xDocument, SecureString decryptionKey)
|
||||
{
|
||||
if (xDocument == null)
|
||||
throw new ArgumentNullException(nameof(xDocument));
|
||||
|
||||
|
||||
var cryptoProvider = new CryptoProviderFactoryFromXml(xDocument.Root).Build();
|
||||
|
||||
foreach (var element in xDocument.Descendants("Node"))
|
||||
@@ -37,7 +38,9 @@ namespace mRemoteNG.Config
|
||||
|
||||
if (ConnectionToCredentialMap.Values.Contains(newCredential, _credentialComparer))
|
||||
{
|
||||
var existingCredential = ConnectionToCredentialMap.Values.First(record => _credentialComparer.Equals(newCredential, record));
|
||||
var existingCredential =
|
||||
ConnectionToCredentialMap.Values.First(record =>
|
||||
_credentialComparer.Equals(newCredential, record));
|
||||
ConnectionToCredentialMap.Add(connectionId, existingCredential);
|
||||
}
|
||||
else
|
||||
@@ -47,21 +50,24 @@ namespace mRemoteNG.Config
|
||||
return ConnectionToCredentialMap.Values.Distinct(_credentialComparer);
|
||||
}
|
||||
|
||||
private ICredentialRecord BuildCredential(XElement element, ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
|
||||
private ICredentialRecord BuildCredential(XElement element,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString decryptionKey)
|
||||
{
|
||||
var credential = new CredentialRecord
|
||||
{
|
||||
Title = $"{element.Attribute("Username")?.Value}\\{element.Attribute("Domain")?.Value}",
|
||||
Username = element.Attribute("Username")?.Value,
|
||||
Domain = element.Attribute("Domain")?.Value,
|
||||
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey).ConvertToSecureString()
|
||||
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey)
|
||||
.ConvertToSecureString()
|
||||
};
|
||||
return credential;
|
||||
}
|
||||
|
||||
private static bool EntryHasSomeCredentialData(XElement e)
|
||||
{
|
||||
return e.Attribute("Username")?.Value != "" ||
|
||||
return e.Attribute("Username")?.Value != "" ||
|
||||
e.Attribute("Domain")?.Value != "" ||
|
||||
e.Attribute("Password")?.Value != "";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureDeserializer<string, IEnumerable<ICredentialRecord>> _deserializer;
|
||||
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider, ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider,
|
||||
ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureSerializer<IEnumerable<ICredentialRecord>, string> _serializer;
|
||||
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider, ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider,
|
||||
ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly CredentialRepositoryListDeserializer _deserializer;
|
||||
|
||||
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider, CredentialRepositoryListDeserializer deserializer)
|
||||
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider,
|
||||
CredentialRepositoryListDeserializer deserializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace mRemoteNG.Config
|
||||
_dataProvider.Save(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,14 @@ namespace mRemoteNG.Config.DataProviders
|
||||
if (WeDontNeedToBackup(fileName))
|
||||
return;
|
||||
|
||||
var backupFileName = string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
var backupFileName =
|
||||
string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
File.Copy(fileName, backupFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg);
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex,
|
||||
MessageClass.WarningMsg);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace mRemoteNG.Config.DataProviders
|
||||
return;
|
||||
|
||||
var filesToDelete = files
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
|
||||
@@ -22,12 +22,15 @@ namespace mRemoteNG.Config.DataProviders
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Could not load file. File does not exist '{FilePath}'", ex);
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(
|
||||
$"Could not load file. File does not exist '{FilePath}'",
|
||||
ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);
|
||||
}
|
||||
|
||||
return fileContents;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public interface IDataProvider<TFormat>
|
||||
{
|
||||
|
||||
@@ -1,68 +1,95 @@
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.App;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public class SqlDataProvider : IDataProvider<DataTable>
|
||||
{
|
||||
public SqlDatabaseConnector SqlDatabaseConnector { get; }
|
||||
public IDatabaseConnector DatabaseConnector { get; }
|
||||
|
||||
public SqlDataProvider(SqlDatabaseConnector sqlDatabaseConnector)
|
||||
public SqlDataProvider(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
SqlDatabaseConnector = sqlDatabaseConnector;
|
||||
DatabaseConnector = databaseConnector;
|
||||
}
|
||||
|
||||
public DataTable Load()
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var sqlQuery = new SqlCommand("SELECT * FROM tblCons ORDER BY PositionID ASC");
|
||||
SqlDatabaseConnector.AssociateItemToThisConnector(sqlQuery);
|
||||
if (!SqlDatabaseConnector.IsConnected)
|
||||
var dbQuery = DatabaseConnector.DbCommand("SELECT * FROM tblCons ORDER BY PositionID ASC");
|
||||
DatabaseConnector.AssociateItemToThisConnector(dbQuery);
|
||||
if (!DatabaseConnector.IsConnected)
|
||||
OpenConnection();
|
||||
var sqlDataReader = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
var dbDataReader = dbQuery.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
|
||||
if (sqlDataReader.HasRows)
|
||||
dataTable.Load(sqlDataReader);
|
||||
sqlDataReader.Close();
|
||||
if (dbDataReader.HasRows)
|
||||
dataTable.Load(dbDataReader);
|
||||
dbDataReader.Close();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public void Save(DataTable dataTable)
|
||||
{
|
||||
if (SqlUserIsReadOnly())
|
||||
if (DbUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SqlDatabaseConnector.IsConnected)
|
||||
if (!DatabaseConnector.IsConnected)
|
||||
OpenConnection();
|
||||
using (var sqlBulkCopy = new SqlBulkCopy(SqlDatabaseConnector.SqlConnection))
|
||||
if (DatabaseConnector.GetType() == typeof(MSSqlDatabaseConnector))
|
||||
{
|
||||
foreach (DataColumn col in dataTable.Columns)
|
||||
sqlBulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
sqlBulkCopy.DestinationTableName = "dbo.tblCons";
|
||||
sqlBulkCopy.WriteToServer(dataTable);
|
||||
using (var sqlBulkCopy = new SqlBulkCopy((SqlConnection)DatabaseConnector.DbConnection()))
|
||||
{
|
||||
foreach (DataColumn col in dataTable.Columns)
|
||||
sqlBulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||
sqlBulkCopy.DestinationTableName = "dbo.tblCons";
|
||||
sqlBulkCopy.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
}
|
||||
else if (DatabaseConnector.GetType() == typeof(MySqlDatabaseConnector))
|
||||
{
|
||||
var dbConnection = (MySqlConnection) DatabaseConnector.DbConnection();
|
||||
using (MySqlTransaction transaction = dbConnection.BeginTransaction(System.Data.IsolationLevel.Serializable))
|
||||
{
|
||||
using (MySqlCommand sqlCommand = new MySqlCommand())
|
||||
{
|
||||
sqlCommand.Connection = dbConnection;
|
||||
sqlCommand.Transaction = transaction;
|
||||
sqlCommand.CommandText = "SELECT * FROM tblCons";
|
||||
using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCommand))
|
||||
{
|
||||
dataAdapter.UpdateBatchSize = 1000;
|
||||
using (MySqlCommandBuilder cb = new MySqlCommandBuilder(dataAdapter))
|
||||
{
|
||||
dataAdapter.Update(dataTable);
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenConnection()
|
||||
{
|
||||
SqlDatabaseConnector.Connect();
|
||||
DatabaseConnector.Connect();
|
||||
}
|
||||
|
||||
public void CloseConnection()
|
||||
{
|
||||
SqlDatabaseConnector.Disconnect();
|
||||
DatabaseConnector.Disconnect();
|
||||
}
|
||||
|
||||
private bool SqlUserIsReadOnly()
|
||||
private bool DbUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@
|
||||
CredentialsRejected,
|
||||
UnknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,19 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
/// <summary>
|
||||
/// A helper class for testing database connectivity
|
||||
/// </summary>
|
||||
public class SqlDatabaseConnectionTester
|
||||
public class DatabaseConnectionTester
|
||||
{
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string server, string database, string username, string password)
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string type,
|
||||
string server,
|
||||
string database,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
using (var sqlConnector = new SqlDatabaseConnector(server, database, username, password))
|
||||
using (var dbConnector = DatabaseConnectorFactory.DatabaseConnector(type, server, database, username, password))
|
||||
{
|
||||
try
|
||||
{
|
||||
await sqlConnector.ConnectAsync();
|
||||
await dbConnector.ConnectAsync();
|
||||
return ConnectionTestResult.ConnectionSucceded;
|
||||
}
|
||||
catch (SqlException sqlException)
|
||||
@@ -35,4 +39,4 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,28 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class DatabaseConnectorFactory
|
||||
{
|
||||
public static SqlDatabaseConnector SqlDatabaseConnectorFromSettings()
|
||||
public static IDatabaseConnector DatabaseConnectorFromSettings()
|
||||
{
|
||||
var sqlType = mRemoteNG.Settings.Default.SQLServerType;
|
||||
var sqlHost = mRemoteNG.Settings.Default.SQLHost;
|
||||
var sqlCatalog = mRemoteNG.Settings.Default.SQLDatabaseName;
|
||||
var sqlUsername = mRemoteNG.Settings.Default.SQLUser;
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var sqlPassword = cryptographyProvider.Decrypt(mRemoteNG.Settings.Default.SQLPass, Runtime.EncryptionKey);
|
||||
return new SqlDatabaseConnector(sqlHost, sqlCatalog, sqlUsername, sqlPassword);
|
||||
|
||||
return DatabaseConnector(sqlType, sqlHost, sqlCatalog, sqlUsername, sqlPassword);
|
||||
}
|
||||
|
||||
public static IDatabaseConnector DatabaseConnector(string type, string server, string database, string username, string password)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "mysql":
|
||||
return new MySqlDatabaseConnector(server, database, username, password);
|
||||
case "mssql":
|
||||
default:
|
||||
return new MSSqlDatabaseConnector(server, database, username, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public interface IDatabaseConnector : IDisposable
|
||||
{
|
||||
DbConnection DbConnection();
|
||||
DbCommand DbCommand(string dbCommand);
|
||||
bool IsConnected { get; }
|
||||
void Connect();
|
||||
Task ConnectAsync();
|
||||
void Disconnect();
|
||||
void AssociateItemToThisConnector(SqlCommand sqlCommand);
|
||||
void AssociateItemToThisConnector(DbCommand dbCommand);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class MSSqlDatabaseConnector : IDatabaseConnector
|
||||
{
|
||||
private DbConnection _dbConnection { get; set; } = default(SqlConnection);
|
||||
private string _dbConnectionString = "";
|
||||
private readonly string _dbHost;
|
||||
private readonly string _dbCatalog;
|
||||
private readonly string _dbUsername;
|
||||
private readonly string _dbPassword;
|
||||
|
||||
public DbConnection DbConnection()
|
||||
{
|
||||
return _dbConnection;
|
||||
}
|
||||
|
||||
public DbCommand DbCommand(string dbCommand)
|
||||
{
|
||||
return new SqlCommand(dbCommand, (SqlConnection) _dbConnection);
|
||||
}
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return (_dbConnection.State == ConnectionState.Open); }
|
||||
}
|
||||
|
||||
public MSSqlDatabaseConnector(string sqlServer, string catalog, string username, string password)
|
||||
{
|
||||
_dbHost = sqlServer;
|
||||
_dbCatalog = catalog;
|
||||
_dbUsername = username;
|
||||
_dbPassword = password;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
BuildSqlConnectionString();
|
||||
_dbConnection = new SqlConnection(_dbConnectionString);
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionString()
|
||||
{
|
||||
if (_dbUsername != "")
|
||||
BuildDbConnectionStringWithCustomCredentials();
|
||||
else
|
||||
BuildDbConnectionStringWithDefaultCredentials();
|
||||
}
|
||||
|
||||
private void BuildDbConnectionStringWithCustomCredentials()
|
||||
{
|
||||
_dbConnectionString = $"Data Source={_dbHost};Initial Catalog={_dbCatalog};User Id={_dbUsername};Password={_dbPassword}";
|
||||
}
|
||||
|
||||
private void BuildDbConnectionStringWithDefaultCredentials()
|
||||
{
|
||||
_dbConnectionString = $"Data Source={_dbHost};Initial Catalog={_dbCatalog};Integrated Security=True";
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
_dbConnection.Open();
|
||||
}
|
||||
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
await _dbConnection.OpenAsync();
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
_dbConnection.Close();
|
||||
}
|
||||
|
||||
public void AssociateItemToThisConnector(DbCommand dbCommand)
|
||||
{
|
||||
dbCommand.Connection = (SqlConnection) _dbConnection;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToFreeManagedObjects) return;
|
||||
_dbConnection.Close();
|
||||
_dbConnection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class MySqlDatabaseConnector : IDatabaseConnector
|
||||
{
|
||||
private DbConnection _dbConnection { get; set; } = default(MySqlConnection);
|
||||
private string _dbConnectionString = "";
|
||||
private readonly string _dbHost;
|
||||
private readonly string _dbPort;
|
||||
private readonly string _dbName;
|
||||
private readonly string _dbUsername;
|
||||
private readonly string _dbPassword;
|
||||
|
||||
public DbConnection DbConnection()
|
||||
{
|
||||
return _dbConnection;
|
||||
}
|
||||
|
||||
public DbCommand DbCommand(string dbCommand)
|
||||
{
|
||||
return new MySqlCommand(dbCommand, (MySqlConnection) _dbConnection);
|
||||
}
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return (_dbConnection.State == ConnectionState.Open); }
|
||||
}
|
||||
|
||||
public MySqlDatabaseConnector(string host, string database, string username, string password)
|
||||
{
|
||||
string[] hostParts = host.Split(new char[]{':'}, 2);
|
||||
_dbHost = hostParts[0];
|
||||
_dbPort = (hostParts.Length == 2)?hostParts[1]:"3306";
|
||||
_dbName = database;
|
||||
_dbUsername = username;
|
||||
_dbPassword = password;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
BuildSqlConnectionString();
|
||||
_dbConnection = new MySqlConnection(_dbConnectionString);
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionString()
|
||||
{
|
||||
_dbConnectionString = $"server={_dbHost};user={_dbUsername};database={_dbName};port={_dbPort};password={_dbPassword}";
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
_dbConnection.Open();
|
||||
}
|
||||
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
await _dbConnection.OpenAsync();
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
_dbConnection.Close();
|
||||
}
|
||||
|
||||
public void AssociateItemToThisConnector(DbCommand dbCommand)
|
||||
{
|
||||
dbCommand.Connection = (MySqlConnection) _dbConnection;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
private void Dispose(bool itIsSafeToFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToFreeManagedObjects) return;
|
||||
_dbConnection.Close();
|
||||
_dbConnection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class SqlDatabaseConnector : IDatabaseConnector
|
||||
{
|
||||
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
|
||||
private string _sqlConnectionString = "";
|
||||
private readonly string _sqlHost;
|
||||
private readonly string _sqlCatalog;
|
||||
private readonly string _sqlUsername;
|
||||
private readonly string _sqlPassword;
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return (SqlConnection.State == ConnectionState.Open); }
|
||||
}
|
||||
|
||||
public SqlDatabaseConnector(string sqlServer, string catalog, string username, string password)
|
||||
{
|
||||
_sqlHost = sqlServer;
|
||||
_sqlCatalog = catalog;
|
||||
_sqlUsername = username;
|
||||
_sqlPassword = password;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
BuildSqlConnectionString();
|
||||
SqlConnection = new SqlConnection(_sqlConnectionString);
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionString()
|
||||
{
|
||||
if (_sqlUsername != "")
|
||||
BuildSqlConnectionStringWithCustomCredentials();
|
||||
else
|
||||
BuildSqlConnectionStringWithDefaultCredentials();
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionStringWithCustomCredentials()
|
||||
{
|
||||
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionStringWithDefaultCredentials()
|
||||
{
|
||||
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};Integrated Security=True";
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
SqlConnection.Open();
|
||||
}
|
||||
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
await SqlConnection.OpenAsync();
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
SqlConnection.Close();
|
||||
}
|
||||
|
||||
public void AssociateItemToThisConnector(SqlCommand sqlCommand)
|
||||
{
|
||||
sqlCommand.Connection = SqlConnection;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
private void Dispose(bool itIsSafeToFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToFreeManagedObjects) return;
|
||||
SqlConnection.Close();
|
||||
SqlConnection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,29 +7,29 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string ldapPath, ContainerInfo destinationContainer)
|
||||
{
|
||||
Import(ldapPath, destinationContainer, false);
|
||||
}
|
||||
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
if (importedRootNode == null) return;
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,17 @@ namespace mRemoteNG.Config.Import
|
||||
}
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {filePath}");
|
||||
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new CsvConnectionsDeserializerMremotengFormat();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(filePath)};
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,28 +10,29 @@ using mRemoteNG.Messages;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {fileName}");
|
||||
if (!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {fileName}");
|
||||
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(fileName)};
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,18 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
|
||||
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
var connectionTreeModel = deserializer.Deserialize(hosts);
|
||||
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
@@ -27,5 +27,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlContent = dataProvider.Load();
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var content = dataProvider.Load();
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace mRemoteNG.Config.Import
|
||||
var connectionTreeModel = deserializer.Deserialize(content);
|
||||
|
||||
var importedConnection = connectionTreeModel.RootNodes.First().Children.First();
|
||||
|
||||
|
||||
if (importedConnection == null) return;
|
||||
importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
|
||||
destinationContainer.AddChild(importedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user