mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-23 14:52:31 +00:00
Added support scripts for acceptance testing
This commit is contained in:
parent
e0c6e3e575
commit
6b7448cb13
BIN
.ci/setup/certs/oem_certs.zip
Normal file
BIN
.ci/setup/certs/oem_certs.zip
Normal file
Binary file not shown.
59
scripts/install_hat.ps1
Normal file
59
scripts/install_hat.ps1
Normal file
@ -0,0 +1,59 @@
|
||||
#Requires -RunAsAdministrator
|
||||
# Powershell script to install the HIRS Acceptance Test on Windows
|
||||
|
||||
# Check For Docker Services
|
||||
$Service = Get-Service -Name Docker
|
||||
if ($Service.Status -ne 'Running') {
|
||||
Write-Host "Docker is either NOT running or NOT installed."
|
||||
Write-Host "Please start or install Docker Desktop. See https://docs.docker.com/desktop/install/windows-install/";
|
||||
Write-Host "Exiting without removing the HAT. Hit Any Key to exit"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
exit;
|
||||
} else {
|
||||
Write-Host "Docker is running, continuing installation..."
|
||||
}
|
||||
|
||||
# Check for previos install
|
||||
if (Test-Path -Path hirs) {
|
||||
Write-Host "The hirs folder exists under the current directory, aborting install."
|
||||
Write-Host "Exiting without removing the HAT. Hit Any Key to exit"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
exit
|
||||
}
|
||||
|
||||
# Make Firwall Rules for ACA to operate
|
||||
Write-Host "Adding Firewall rules"
|
||||
netsh advfirewall firewall add rule name="ACA HTTPS" dir=in action=allow protocol=TCP localport=8443
|
||||
netsh advfirewall firewall add rule name="ACA HTTPS" dir=out action=allow protocol=TCP localport=8443
|
||||
|
||||
# Make folder for necessary files
|
||||
mkdir hirs | out-null
|
||||
Push-Location .\hirs\ | out-null
|
||||
|
||||
# Download necessary files
|
||||
Write-Host "Reteiving Configuration Files"
|
||||
wget https://raw.githubusercontent.com/nsacyber/HIRS/v3_issue_645/.ci/docker/compose-acceptance-test.yml -o compose-acceptance-test.yml
|
||||
Write-Host "Retreiving Trust Stores"
|
||||
wget https://raw.githubusercontent.com/nsacyber/HIRS/v3_issue_645/.ci/setup/oem_certs.zip
|
||||
#Copy-Item -Path ..\projects\github\HIRS\.ci\setup\certs\oem_certs.zip -Destination .
|
||||
wget https://raw.githubusercontent.com/nsacyber/HIRS/v3_issue_645/scripts/start_hat.ps1
|
||||
#Copy-Item -Path ..\projects\github\HIRS\scripts\start_hat.ps1 -Destination .
|
||||
wget https://raw.githubusercontent.com/nsacyber/HIRS/v3_issue_645/scripts/remove_hat.ps1
|
||||
#Copy-Item -Path ..\projects\github\HIRS\scripts\remove_hat.ps1 -Destination .
|
||||
Expand-Archive -Path oem_certs.zip
|
||||
Write-Host "Downloading images (This can take a while)"
|
||||
docker pull ghcr.io/nsacyber/hirs/aca:latest
|
||||
docker pull ghcr.io/nsacyber/hirs/hat:alpha6
|
||||
Write-Host "Creating shortcut for starting the Acceptance Test (HAT start)"
|
||||
|
||||
# Create a shortcut to the start_hat.ps1 script
|
||||
$WshShell = New-Object -comObject WScript.Shell
|
||||
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\start_hat.lnk")
|
||||
$Shortcut.Targetpath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||
$Shortcut.Arguments = "-ExecutionPolicy bypass $Home\hirs\start_hat.ps1"
|
||||
$Shortcut.Save()
|
||||
|
||||
# Done
|
||||
Write-Host "HIRS Acceptance Test Installation complete."
|
||||
Write-Host "Use the Desktop Shortcut to start the ACA and hat servers."
|
||||
Pop-Location | out-null
|
47
scripts/remove_hat.ps1
Normal file
47
scripts/remove_hat.ps1
Normal file
@ -0,0 +1,47 @@
|
||||
#Requires -RunAsAdministrator
|
||||
# Powershell script to install the HIRS Acceptance Test on Windows
|
||||
|
||||
$Service = Get-Service -Name Docker
|
||||
if ($Service.Status -ne 'Running') {
|
||||
Write-Host "Docker is either NOT running or NOT installed."
|
||||
Write-Host "Please start Docker Desktop."
|
||||
Write-Host "Exiting without removing the HAT. Hit Any Key to exit"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
Exit;
|
||||
} else {
|
||||
Write-Host "Docker is running, continuing HAT removal..."
|
||||
}
|
||||
|
||||
# remove Firewall Rules
|
||||
Write-Host "Removing HAT FW Rule ACA HTTPS"
|
||||
netsh advfirewall firewall delete rule name="ACA HTTPS"
|
||||
|
||||
# remove HAT Docker containers and images
|
||||
$IsAcaRunning = docker container inspect -f '{{.State.Running}}' aca 2>&1 | out-null
|
||||
$IsHatRunning = docker container inspect -f '{{.State.Running}}' hat 2>&1 | out-null
|
||||
|
||||
if ($IsHatRunning -eq $TRUE) {
|
||||
Write-Host "Shutting down the HAT container"
|
||||
docker stop hat
|
||||
}
|
||||
|
||||
if ($IsAcaRunning -eq $TRUE) {
|
||||
Write-Host "Shutting down the ACA container"
|
||||
docker stop aca
|
||||
}
|
||||
|
||||
Write-Host "Removing HAT images"
|
||||
|
||||
#docker image rm ghcr.io/nsacyber/hirs/aca:latest
|
||||
#docker image rm ghcr.io/nsacyber/hirs/hat:alpha6
|
||||
|
||||
Write-Host "Removing local HAT folder and files"
|
||||
cd ..
|
||||
if (Test-Path -LiteralPath hirs) {
|
||||
Remove-Item -LiteralPath hirs -Recurse
|
||||
}
|
||||
|
||||
Write-Host "Removing HAT Deskstop Shortcut"
|
||||
Remove-Item "$Home\Desktop\start_hat.lnk" -Force
|
||||
|
||||
Write-Host "HAT has been removed from the system"
|
36
scripts/start_hat.ps1
Normal file
36
scripts/start_hat.ps1
Normal file
@ -0,0 +1,36 @@
|
||||
# Script to start the docker continers used for the HIRS Acceptance Test
|
||||
|
||||
$DockerProc = Get-process "*docker desktop*"
|
||||
if ($DockerProc.Count -eq 0 ) {
|
||||
Write-Host "Docker Service is not started, please start Docker desktop."
|
||||
Write-Host "Exiting without starting Acceptance Test. Hit Any Key to exit"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
exit
|
||||
}
|
||||
|
||||
$IsAcaRunning = docker container inspect -f '{{.State.Running}}' aca 2>&1 | out-null
|
||||
$IsHatRunning = docker container inspect -f '{{.State.Running}}' hat 2>&1 | out-null
|
||||
|
||||
if ($IsHatRunning -eq $TRUE) {
|
||||
Write-Host "HAT container is already running"
|
||||
}
|
||||
|
||||
if ($IsAcaRunning -eq $TRUE) {
|
||||
Write-Host "ACA container is already running"
|
||||
}
|
||||
|
||||
if ( ($IsHatRunning -eq $TRUE) -and ($IsAcaRunning -eq $TRUE) ) {
|
||||
Write-Host "ACA and Hat container are already started, exiting"
|
||||
Write-Host "Hit any key to exit"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
exit
|
||||
} else {
|
||||
Write-Host "Starting ACA and HAT containers..."
|
||||
docker compose -f $Home\hirs\compose-acceptance-test.yml up
|
||||
}
|
||||
|
||||
Write-Host "HIRS Acceptance Test Servers Have been started."
|
||||
Write-Host "You can check container status in the Docker Desktop."
|
||||
Write-Host "Use the following URL in your Browser to view the ACA Portal: https://172.16.1.75:8443"
|
||||
Write-Host "Hit Any Key to continue"
|
||||
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
Loading…
Reference in New Issue
Block a user