test(BRIDGE-136): Download Bridge

This commit is contained in:
Gjorgji Slamkov
2025-08-15 09:25:10 +02:00
committed by Gordana Zafirova
parent cf9b35163a
commit fd709b0d08
21 changed files with 697 additions and 130 deletions

View File

@ -0,0 +1,45 @@
# Download the Bridge installer, and install it
# Set variables with Bridge's download link and the download path
# to be used later on
$bridgeDownloadURL = $env:BRIDGE_DOWNLOAD_URL
$bridgeDownloadPath = "$env:CI_PROJECT_DIR/tests/e2e/ui_tests/windows_os/InstallerScripts/Bridge-Installer.exe"
# Write the download link of Bridge to use it if manual re-tests are needed
Write-Output $bridgeDownloadURL
# Download the Bridge-Installer.exe file
Invoke-WebRequest -Uri $bridgeDownloadURL -OutFile $bridgeDownloadPath
if (Test-Path -Path $bridgeDownloadPath) {
Write-Output "Bridge Installer downloaded."
$file = Get-Item $bridgeDownloadPath | Select-Object Name, Length
$size = $file.Length
$sizeMB = "{0:N2}" -f ($size / 1MB)
Write-Output "File size in MB: $sizeMB"
} else {
Write-Output "Bridge installer NOT DOWNLOADED"
}
# Install the downloaded Bridge-Installer.exe file
# The installer is passive, meaning no user interaction is needed
# If the user does not have admin rights, it will still show the UAC prompt
# where a user needs to click on "Yes",
# but this will be not needed since the image in the pipeline will be an
# Admin account
# Argument list for passive install
# $argList = "/passive INSTALLSHORTCUT=yes INSTALLDESKTOPSHORTCUT=yes"
# Install Bridge
$process = Start-Process -Wait -ArgumentList "/passive INSTALLSHORTCUT=yes INSTALLDESKTOPSHORTCUT=yes" -PassThru -FilePath $bridgeDownloadPath
# Check exit code of the installation process to confirm installation
if ($process.ExitCode -eq "0") {
Write-Output "Bridge installed successfully"
} else {
Write-Error "Bridge not installed successfully!"
Write-Error "Installer Exit Code: $($process.ExitCode)"
}
# Delete the installer after installation to clean up the space
Remove-Item -Path $bridgeDownloadPath

View File

@ -0,0 +1,156 @@
<#
PowerShell script for uninstalling Bridge
And removing all other files (vault, cache, updates, etc)
#>
# Define variables with path to Bridge files (vault, cache, startup entry etc)
$RoamProtonmail = "$env:APPDATA\protonmail"
$RoamProtonAG = "$env:APPDATA\Proton AG"
$LocalProtonmail = "$env:LOCALAPPDATA\protonmail"
$LocalProtonAG = "$env:LOCALAPPDATA\Proton AG"
$StartUpProtonBridge = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\Proton Mail Bridge.lnk"
function Uninstall-PMBridge {
# Uninstalling REBRANDED version of Bridge
# Find the UninstallSTring in the registry (64bit & 32bit)
# Use the UninstallString with `msiexec.exe` to uninstall Bridge
$registry64 = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_ -match "Proton Mail Bridge" } | Select-Object UninstallString
if ($registry64) {
$registry64 = $registry64 | Select-Object -Last 1
$registry64 = $registry64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$registry64 = $registry64.Trim()
Start-Process "msiexec.exe" -arg "/X $registry64 /passive" -Wait
}
$registry32 = Get-ChildItem "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_ -match "Proton Mail Bridge" } | Select-Object UninstallString
if ($registry32) {
$registry32 = $registry32 | Select-Object -Last 1
$registry32 = $registry32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$registry32 = $registry32.Trim()
Start-Process "msiexec.exe" -arg "/X $registry32 /passive" -Wait
}
# Uninstalling PRE-REBRANDED version of Bridge
# Find the UninstallSTring in the registry (64bit & 32bit)
# Use the UninstallString with `msiexec.exe` to uninstall Bridge
$preRebrandRegistry64 = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_ -match "ProtonMail Bridge" } | Select-Object UninstallString
if ($preRebrandRegistry64) {
$preRebrandRegistry64 = $preRebrandRegistry64 | Select-Object -Last 1
$preRebrandRegistry64 = $preRebrandRegistry64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$preRebrandRegistry64 = $preRebrandRegistry64.Trim()
Start-Process "msiexec.exe" -arg "/X $preRebrandRegistry64 /passive" -Wait
}
$preRebrandRegistry32 = Get-ChildItem "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_ -match "ProtonMail Bridge" } | Select-Object UninstallString
if ($preRebrandRegistry32) {
$preRebrandRegistry32 = $preRebrandRegistry32 | Select-Object -Last 1
$preRebrandRegistry32 = $preRebrandRegistry32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$preRebrandRegistry32 = $preRebrandRegistry32.Trim()
Start-Process "msiexec.exe" -arg "/X $preRebrandRegistry32 /passive" -Wait
}
}
function Stop-PMBridge {
# Stop the `bridge` process to completely quit Bridge
$bridge = Get-Process "bridge" -ErrorAction SilentlyContinue
if ($bridge){
$bridge | Stop-Process -Force
}
}
function Remove-PMBridgeResources {
# Delete all the Bridge resource folders
# They should be deleted with uninstalling Bridge
# But to just make sure do this again
Remove-Item $RoamProtonmail -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $RoamProtonAG -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $LocalProtonmail -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $LocalProtonAG -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $StartUpProtonBridge -Force -Recurse -ErrorAction SilentlyContinue
}
function Find-PMBridgeResources {
# Search and check if the Bridge resource folders
# Are deleted
# Write to Output the result
$FolderExists = $false
if ( Test-Path -Path $RoamProtonmail ){
Write-Host "`r`n'$RoamProtonmail' is not deleted!" -ForegroundColor Red
$FolderExists = $true
}
if ( Test-Path -Path $RoamProtonAG ) {
Write-Host "`r`n'$RoamProtonAG' is not deleted!" -ForegroundColor Red
$FolderExists = $true
}
if ( Test-Path -Path $LocalProtonmail ) {
Write-Host "`r`n'$LocalProtonmail' is not deleted!" -ForegroundColor Red
$FolderExists = $true
}
if ( Test-Path -Path $LocalProtonAG ) {
Write-Host "`r`n'$LocalProtonAG' is not deleted!" -ForegroundColor Red
$FolderExists = $true
}
if ( Test-Path -Path $StartUpProtonBridge ) {
Write-Host "`r`n'$StartUpProtonBridge' is not deleted!" -ForegroundColor Red
$FolderExists = $true
}
if ( $FolderExists ) {
Write-Host "`r`nSome directories were not deleted properly!`r`n" -ForegroundColor Red
}
else {
Write-Host "`r`nAll Bridge resource folders deleted!`r`n" -ForegroundColor Green
}
}
function Remove-PMBridgeCredentials {
# Delete the entries in the credential manager
$CredentialsData = @((cmdkey /listall | Where-Object{$_ -like "*LegacyGeneric:target=protonmail*"}).replace("Target: ",""))
for($i =0; $i -le ($CredentialsData.Count -1); $i++){
[string]$DeleteData = $CredentialsData[$i].trim()
cmdkey /delete:$DeleteData
}
}
function Invoke-BridgeFunctions {
Stop-PMBridge
Uninstall-PMBridge
Remove-PMBridgeResources
Find-PMBridgeResources
Remove-PMBridgeCredentials
}
Invoke-BridgeFunctions

View File

@ -0,0 +1,34 @@
<#
PowerShell script for removing Bridge credentials from
Microsoft Credentials manager
#>
$Bridge = Get-Process "bridge" -ErrorAction SilentlyContinue
$CredentialsData = @((cmdkey /listall | Where-Object{$_ -like "*LegacyGeneric:target=protonmail*"}).replace("Target: ",""))
function Remove-BridgeCredentials {
# Delete the entries in the credential manager
for($i=0; $i -le ($CredentialsData.Count -1); $i++){
[string]$DeleteData = $CredentialsData[$i].trim()
cmdkey /delete:$DeleteData
}
}
function Stop-PMBridge {
# Stop the `bridge` process to completely quit Bridge
if ($Bridge){
$Bridge | Stop-Process -Force
}
}
function Invoke-Functions{
Stop-PMBridge
Remove-BridgeCredentials
}
Invoke-Functions