mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix NSIS Installer tests
This commit is contained in:
parent
60a1959f2a
commit
19c8910ef2
76 changed files with 3199 additions and 1 deletions
|
@ -38,7 +38,7 @@ function Write-Result($result, $ForegroundColor="Green") {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Variables
|
||||
# Script Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$PROJECT_DIR = $(git rev-parse --show-toplevel)
|
||||
|
|
3
pkg/windows/nsis/clean.cmd
Normal file
3
pkg/windows/nsis/clean.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\clean.ps1" %*
|
78
pkg/windows/nsis/clean.ps1
Normal file
78
pkg/windows/nsis/clean.ps1
Normal file
|
@ -0,0 +1,78 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Clean the NSIS build directory
|
||||
|
||||
.DESCRIPTION
|
||||
This script Cleans, Installs Dependencies, Builds Python, Installs Salt,
|
||||
and builds the NullSoft Installer. It depends on the following Scripts
|
||||
and are called in this order:
|
||||
|
||||
- clean_env.ps1
|
||||
- install_nsis.ps1
|
||||
- build_python.ps1
|
||||
- install_salt.ps1
|
||||
- build_pkg.ps1
|
||||
|
||||
.EXAMPLE
|
||||
build.ps1
|
||||
|
||||
.EXAMPLE
|
||||
build.ps1 -Version 3005 -PythonVersion 3.8.13
|
||||
|
||||
#>
|
||||
|
||||
# Script Preferences
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Functions
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function Write-Result($result, $ForegroundColor="Green") {
|
||||
$position = 80 - $result.Length - [System.Console]::CursorLeft
|
||||
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Start the Script
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Clean NSIS Build Environment" -ForegroundColor Cyan
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Make sure we're not in a virtual environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
# I've tried deactivating from the script, but it doesn't work
|
||||
Write-Host "Please deactive the virtual environment"
|
||||
exit
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove venv directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Removing venv directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\venv" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Result "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Completed
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Clean NSIS Build Environment Completed" -ForegroundColor Cyan
|
||||
Write-Host $("=" * 80)
|
3
pkg/windows/nsis/test.cmd
Normal file
3
pkg/windows/nsis/test.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\tests\test.ps1" %*
|
8
pkg/windows/nsis/tests/_files/minion
Normal file
8
pkg/windows/nsis/tests/_files/minion
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Default config from test suite line 1/6
|
||||
#master: salt
|
||||
# Default config from test suite line 2/6
|
||||
#id:
|
||||
# Default config from test suite line 3/6
|
||||
# Default config from test suite line 4/6
|
||||
# Default config from test suite line 5/6
|
||||
# Default config from test suite line 6/6
|
3
pkg/windows/nsis/tests/clean.cmd
Normal file
3
pkg/windows/nsis/tests/clean.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\clean.ps1" %*
|
83
pkg/windows/nsis/tests/clean.ps1
Normal file
83
pkg/windows/nsis/tests/clean.ps1
Normal file
|
@ -0,0 +1,83 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Clean the NSIS Tests directory
|
||||
|
||||
.DESCRIPTION
|
||||
This script removes the venv directory and the test-setup.exe
|
||||
|
||||
.EXAMPLE
|
||||
clean.ps1
|
||||
|
||||
.EXAMPLE
|
||||
clean.ps1
|
||||
|
||||
#>
|
||||
|
||||
# Script Preferences
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Functions
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function Write-Result($result, $ForegroundColor="Green") {
|
||||
$position = 80 - $result.Length - [System.Console]::CursorLeft
|
||||
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Start the Script
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Clean NSIS Test Environment" -ForegroundColor Cyan
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Make sure we're not in a virtual environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
# I've tried deactivating from the script, but it doesn't work
|
||||
Write-Host "Please deactive the virtual environment"
|
||||
exit
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove venv directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Removing venv directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\venv" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Result "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove test-setup.exe
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\test-setup.exe" ) {
|
||||
Write-Host "Removing test-setup.exe: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\test-setup.exe" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\test-setup.exe" ) {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Result "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Completed
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Clean NSIS Test Environment Completed" -ForegroundColor Cyan
|
||||
Write-Host $("=" * 80)
|
35
pkg/windows/nsis/tests/config_tests/test_custom_full_path.py
Normal file
35
pkg/windows/nsis/tests/config_tests/test_custom_full_path.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
full_path_conf = rf"{pytest.REPO_DIR}\custom_conf"
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/custom-config={full_path_conf}"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
41
pkg/windows/nsis/tests/config_tests/test_custom_master.py
Normal file
41
pkg/windows/nsis/tests/config_tests/test_custom_master.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
41
pkg/windows/nsis/tests/config_tests/test_custom_minion.py
Normal file
41
pkg/windows/nsis/tests/config_tests/test_custom_minion.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
33
pkg/windows/nsis/tests/config_tests/test_custom_rel_path.py
Normal file
33
pkg/windows/nsis/tests/config_tests/test_custom_rel_path.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
29
pkg/windows/nsis/tests/config_tests/test_default.py
Normal file
29
pkg/windows/nsis/tests/config_tests/test_default.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
37
pkg/windows/nsis/tests/config_tests/test_default_master.py
Normal file
37
pkg/windows/nsis/tests/config_tests/test_default_master.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
37
pkg/windows/nsis/tests/config_tests/test_default_minion.py
Normal file
37
pkg/windows/nsis/tests/config_tests/test_default_minion.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with only minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
32
pkg/windows/nsis/tests/config_tests/test_existing.py
Normal file
32
pkg/windows/nsis/tests/config_tests/test_existing.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the existing config, unchanged
|
||||
expected = pytest.EXISTING_CONTENT
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
36
pkg/windows/nsis/tests/config_tests/test_existing_custom.py
Normal file
36
pkg/windows/nsis/tests/config_tests/test_existing_custom.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,44 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,44 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,43 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
33
pkg/windows/nsis/tests/config_tests/test_existing_default.py
Normal file
33
pkg/windows/nsis/tests/config_tests/test_existing_default.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with just the minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,38 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return "C:\\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return "C:\\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return "C:\\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return "C:\\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,34 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return "C:\\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return r"C:\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return r"C:\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return r"C:\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/minion-name=cli_minion"])
|
||||
yield {"inst_dir": inst_dir}
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with just the minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return r"C:\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}"])
|
||||
yield
|
||||
pytest.helpers.clean_env(inst_dir)
|
||||
|
||||
|
||||
def test_binaries_present(install, inst_dir):
|
||||
assert os.path.exists(rf"{inst_dir}\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the existing config, unchanged
|
||||
expected = pytest.EXISTING_CONTENT
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,40 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def inst_dir():
|
||||
return r"C:\custom_location"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install(inst_dir):
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old install
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/move-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
# Apparently we don't move the binaries even if they pass install-dir
|
||||
# TODO: Decide if this is expected behavior
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the existing config in the new location, unchanged
|
||||
expected = pytest.OLD_CONTENT
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
36
pkg/windows/nsis/tests/config_tests/test_old_install.py
Normal file
36
pkg/windows/nsis/tests/config_tests/test_old_install.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the old existing config, unchanged
|
||||
expected = pytest.OLD_CONTENT
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with only minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
36
pkg/windows/nsis/tests/config_tests/test_old_install_move.py
Normal file
36
pkg/windows/nsis/tests/config_tests/test_old_install_move.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/move-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the old existing config in the new location, unchanged
|
||||
expected = pytest.OLD_CONTENT
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,40 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/move-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config in the new location, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/move-config", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config in the new location with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/move-config", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config in the new location with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,48 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/move-config", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config in the new location with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/move-config", "/default-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config in the new location, unchanged
|
||||
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/move-config", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config in the new location with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/move-config", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config in the new location with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create old config
|
||||
pytest.helpers.old_install()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config", "/move-config", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_ssm_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
|
||||
|
||||
|
||||
def test_binaries_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
|
||||
|
||||
|
||||
def test_config_present_old_location(install):
|
||||
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default config in the new location with only minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
181
pkg/windows/nsis/tests/conftest.py
Normal file
181
pkg/windows/nsis/tests/conftest.py
Normal file
|
@ -0,0 +1,181 @@
|
|||
import os
|
||||
import psutil
|
||||
import pytest
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import winreg
|
||||
|
||||
pytest_plugins = ["helpers_namespace"]
|
||||
|
||||
# \n characters are converted to os.linesep
|
||||
existing_content = [
|
||||
"# Existing config from test suite line 1/6\n",
|
||||
"master: existing_master\n",
|
||||
"# Existing config from test suite line 2/6\n",
|
||||
"id: existing_minion\n",
|
||||
"# Existing config from test suite line 3/6\n",
|
||||
"# Existing config from test suite line 4/6\n",
|
||||
"# Existing config from test suite line 5/6\n",
|
||||
"# Existing config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
# \n characters are converted to os.linesep
|
||||
custom_content = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
# \n characters are converted to os.linesep
|
||||
old_content = [
|
||||
"# Old config from test suite line 1/6\n",
|
||||
"master: old_master\n",
|
||||
"# Old config from test suite line 2/6\n",
|
||||
"id: old_minion\n",
|
||||
"# Old config from test suite line 3/6\n",
|
||||
"# Old config from test suite line 4/6\n",
|
||||
"# Old config from test suite line 5/6\n",
|
||||
"# Old config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
INST_DIR = r"C:\Program Files\Salt Project\Salt"
|
||||
DATA_DIR = r"C:\ProgramData\Salt Project\Salt"
|
||||
SYSTEM_DRIVE = os.environ.get("SystemDrive")
|
||||
OLD_DIR = f"{SYSTEM_DRIVE}\\salt"
|
||||
|
||||
|
||||
def reg_key_exists(hive=winreg.HKEY_LOCAL_MACHINE, key=None):
|
||||
try:
|
||||
with winreg.OpenKey(hive, key, 0, winreg.KEY_READ):
|
||||
exists = True
|
||||
except:
|
||||
exists = False
|
||||
|
||||
return exists
|
||||
|
||||
|
||||
def delete_key(hive=winreg.HKEY_LOCAL_MACHINE, key=None):
|
||||
if reg_key_exists(hive=hive, key=key):
|
||||
parent, _, base = key.rpartition("\\")
|
||||
with winreg.OpenKey(hive, parent, 0, winreg.KEY_ALL_ACCESS) as reg:
|
||||
winreg.DeleteKey(reg, base)
|
||||
|
||||
|
||||
def pytest_configure():
|
||||
pytest.DATA_DIR = DATA_DIR
|
||||
pytest.INST_DIR = INST_DIR
|
||||
pytest.REPO_DIR = REPO_DIR
|
||||
pytest.INST_BIN = INST_BIN
|
||||
pytest.OLD_DIR = OLD_DIR
|
||||
pytest.EXISTING_CONTENT = existing_content
|
||||
pytest.CUSTOM_CONTENT = custom_content
|
||||
pytest.OLD_CONTENT = old_content
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def clean_env(inst_dir=INST_DIR):
|
||||
# Run uninstaller
|
||||
for uninst_bin in [f"{inst_dir}\\uninst.exe", f"{OLD_DIR}\\uninst.exe"]:
|
||||
if os.path.exists(uninst_bin):
|
||||
run_command([uninst_bin, "/S", "/delete-root-dir", "/delete-install-dir"])
|
||||
# This is needed to avoid a race condition where the uninstall is completing
|
||||
start_time = time.time()
|
||||
while "Un_A.exe" in (p.name() for p in psutil.process_iter()):
|
||||
# Sometimes the Uninstall binary hangs... we'll kill it after 10 seconds
|
||||
if (time.time() - start_time) > 10:
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == "Un_A.exe":
|
||||
proc.kill()
|
||||
time.sleep(.1)
|
||||
|
||||
# This is needed to avoid a race condition where the installer isn't closed
|
||||
start_time = time.time()
|
||||
while os.path.basename(INST_BIN) in (p.name() for p in psutil.process_iter()):
|
||||
if (time.time() - start_time) > 10:
|
||||
# If it's not dead after 10 seconds, kill it
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == os.path.basename(INST_BIN):
|
||||
proc.kill()
|
||||
time.sleep(.1)
|
||||
|
||||
# Remove root_dir
|
||||
if os.path.exists(DATA_DIR):
|
||||
shutil.rmtree(DATA_DIR)
|
||||
# Remove install dir
|
||||
if os.path.exists(inst_dir):
|
||||
shutil.rmtree(inst_dir)
|
||||
# Remove old salt dir (C:\salt)
|
||||
if os.path.exists(OLD_DIR):
|
||||
shutil.rmtree(OLD_DIR)
|
||||
# Remove custom config
|
||||
if os.path.exists(rf"{REPO_DIR}\custom_conf"):
|
||||
os.remove(rf"{REPO_DIR}\custom_conf")
|
||||
# Remove registry entries
|
||||
delete_key(key="SOFTWARE\\Salt Project\\Salt")
|
||||
delete_key(key="SOFTWARE\\Salt Project")
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def existing_config():
|
||||
# Create an existing config
|
||||
if not os.path.exists(f"{DATA_DIR}\\conf"):
|
||||
os.makedirs(f"{DATA_DIR}\\conf")
|
||||
with open(f"{DATA_DIR}\\conf\\minion", "w") as f:
|
||||
# \n characters are converted to os.linesep
|
||||
f.writelines(existing_content)
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def custom_config():
|
||||
if os.path.exists(rf"{REPO_DIR}\custom_conf"):
|
||||
os.remove(rf"{REPO_DIR}\custom_conf")
|
||||
# Create a custom config
|
||||
with open(rf"{REPO_DIR}\custom_conf", "w") as f:
|
||||
# \n characters are converted to os.linesep
|
||||
f.writelines(custom_content)
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def old_install():
|
||||
# Create old binaries, don't have to be valid exe's
|
||||
if not os.path.exists(f"{OLD_DIR}\\bin"):
|
||||
os.makedirs(f"{OLD_DIR}\\bin")
|
||||
with open(f"{OLD_DIR}\\bin\\python.exe", "w") as f:
|
||||
f.write("binary data")
|
||||
with open(f"{OLD_DIR}\\bin\\ssm.exe", "w") as f:
|
||||
f.write("binary data")
|
||||
|
||||
# Create an old config
|
||||
if not os.path.exists(f"{OLD_DIR}\\conf"):
|
||||
os.makedirs(f"{OLD_DIR}\\conf")
|
||||
with open(f"{OLD_DIR}\\conf\\minion", "w") as f:
|
||||
# \n characters are converted to os.linesep
|
||||
f.writelines(old_content)
|
||||
while not (os.path.exists(f"{OLD_DIR}\\bin\\python.exe")):
|
||||
time.sleep(.1)
|
||||
while not (os.path.exists(f"{OLD_DIR}\\bin\\ssm.exe")):
|
||||
time.sleep(.1)
|
||||
while not (os.path.exists(f"{OLD_DIR}\\conf\\minion")):
|
||||
time.sleep(.1)
|
||||
assert os.path.exists(f"{OLD_DIR}\\bin\\python.exe")
|
||||
assert os.path.exists(f"{OLD_DIR}\\bin\\ssm.exe")
|
||||
assert os.path.exists(f"{OLD_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def run_command(cmd):
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
return result.stdout.strip().replace("/", "\\")
|
||||
|
||||
|
||||
# These are at the bottom because they depend on some of the functions
|
||||
REPO_DIR = run_command(["git", "rev-parse", "--show-toplevel"])
|
||||
REPO_DIR = rf"{REPO_DIR}\pkg\windows\nsis\tests"
|
||||
os.chdir(REPO_DIR)
|
||||
INST_BIN = rf"{REPO_DIR}\test-setup.exe"
|
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
full_path_conf = f"{pytest.REPO_DIR}\\custom_conf"
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, f"/custom-config={full_path_conf}"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default, unchanged
|
||||
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default, unchanged
|
||||
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
30
pkg/windows/nsis/tests/manual_tests/test_manual_default.py
Normal file
30
pkg/windows/nsis/tests/manual_tests/test_manual_default.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default, unchanged
|
||||
with open(f"{pytest.REPO_DIR}\\tests\\_files\\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\bsm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
33
pkg/windows/nsis/tests/manual_tests/test_manual_existing.py
Normal file
33
pkg/windows/nsis/tests/manual_tests/test_manual_existing.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the existing config, unchanged
|
||||
expected = pytest.EXISTING_CONTENT
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default, unchanged
|
||||
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only master set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: custom_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with master and minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
# Create a custom config
|
||||
pytest.helpers.custom_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the custom config with only minion set
|
||||
expected = [
|
||||
"# Custom config from test suite line 1/6\n",
|
||||
"master: custom_master\n",
|
||||
"# Custom config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Custom config from test suite line 3/6\n",
|
||||
"# Custom config from test suite line 4/6\n",
|
||||
"# Custom config from test suite line 5/6\n",
|
||||
"# Custom config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/default-config"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default, unchanged
|
||||
with open(f"{pytest.REPO_DIR}\\tests\\_files\\minion") as f:
|
||||
expected = f.readlines()
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/default-config", "/master=cli_master"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with only master set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"#id:\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/default-config", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with just the minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"#master: salt\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def install():
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
# Create an existing config
|
||||
pytest.helpers.existing_config()
|
||||
|
||||
pytest.helpers.run_command([pytest.INST_BIN, "/default-config", "/master=cli_master", "/minion-name=cli_minion"])
|
||||
yield
|
||||
pytest.helpers.clean_env()
|
||||
|
||||
|
||||
def test_binaries_present(install):
|
||||
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
|
||||
|
||||
|
||||
def test_config_present(install):
|
||||
assert os.path.exists(f"{pytest.DATA_DIR}\\conf\\minion")
|
||||
|
||||
|
||||
def test_config_correct(install):
|
||||
# The config file should be the default with master and minion set
|
||||
expected = [
|
||||
"# Default config from test suite line 1/6\n",
|
||||
"master: cli_master\n",
|
||||
"# Default config from test suite line 2/6\n",
|
||||
"id: cli_minion\n",
|
||||
"# Default config from test suite line 3/6\n",
|
||||
"# Default config from test suite line 4/6\n",
|
||||
"# Default config from test suite line 5/6\n",
|
||||
"# Default config from test suite line 6/6\n"
|
||||
]
|
||||
|
||||
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:
|
||||
result = f.readlines()
|
||||
|
||||
assert result == expected
|
||||
|
3
pkg/windows/nsis/tests/setup.cmd
Normal file
3
pkg/windows/nsis/tests/setup.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\setup.ps1" %*
|
186
pkg/windows/nsis/tests/setup.ps1
Normal file
186
pkg/windows/nsis/tests/setup.ps1
Normal file
|
@ -0,0 +1,186 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Script that sets up the environment for testing
|
||||
|
||||
.DESCRIPTION
|
||||
This script creates the directory structure and files needed build a mock salt
|
||||
installer for testing
|
||||
|
||||
.EXAMPLE
|
||||
setup.ps1
|
||||
#>
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Preferences
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Functions
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function Write-Result($result, $ForegroundColor="Green") {
|
||||
$position = 80 - $result.Length - [System.Console]::CursorLeft
|
||||
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$PROJECT_DIR = $(git rev-parse --show-toplevel)
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
$WINDOWS_DIR = "$PROJECT_DIR\pkg\windows"
|
||||
$NSIS_DIR = "$WINDOWS_DIR\nsis"
|
||||
$BUILDENV_DIR = "$WINDOWS_DIR\buildenv"
|
||||
$PREREQS_DIR = "$WINDOWS_DIR\prereqs"
|
||||
$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Start
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Build Test Environment for NSIS Tests" -ForegroundColor Cyan
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Setup Directories
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$directories = "$PREREQS_DIR",
|
||||
"$BUILDENV_DIR",
|
||||
"$BUILDENV_DIR\configs"
|
||||
$directories | ForEach-Object {
|
||||
if ( ! (Test-Path -Path "$_") ) {
|
||||
Write-Host "Creating $_`: " -NoNewline
|
||||
New-Item -Path $_ -ItemType Directory | Out-Null
|
||||
if ( Test-Path -Path "$_" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create binaries
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$prereq_files = "vcredist_x86_2013.exe",
|
||||
"vcredist_x64_2013.exe",
|
||||
"ucrt_x86.zip",
|
||||
"ucrt_x64.zip"
|
||||
$prereq_files | ForEach-Object {
|
||||
Write-Host "Creating $_`: " -NoNewline
|
||||
Set-Content -Path "$PREREQS_DIR\$_" -Value "binary"
|
||||
if ( Test-Path -Path "$PREREQS_DIR\$_" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$binary_files = "ssm.exe",
|
||||
"python.exe"
|
||||
$binary_files | ForEach-Object {
|
||||
Write-Host "Creating $_`: " -NoNewline
|
||||
Set-Content -Path "$BUILDENV_DIR\$_" -Value "binary"
|
||||
if ( Test-Path -Path "$BUILDENV_DIR\$_" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copy Configs
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host "Copy minion config: " -NoNewline
|
||||
Copy-Item -Path "$NSIS_DIR\tests\_files\minion" `
|
||||
-Destination "$BUILDENV_DIR\configs\"
|
||||
if ( Test-Path -Path "$BUILDENV_DIR\configs\minion" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Build mock installer
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Building mock installer: " -NoNewline
|
||||
Start-Process -FilePath $NSIS_BIN `
|
||||
-ArgumentList "/DSaltVersion=test", `
|
||||
"/DPythonArchitecture=AMD64", `
|
||||
"$NSIS_DIR\installer\Salt-Minion-Setup.nsi" `
|
||||
-Wait -WindowStyle Hidden
|
||||
$installer = "$NSIS_DIR\installer\Salt-Minion-test-Py3-AMD64-Setup.exe"
|
||||
if ( Test-Path -Path "$installer" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Moving mock installer: " -NoNewline
|
||||
$test_installer = "$NSIS_DIR\tests\test-setup.exe"
|
||||
Move-Item -Path $installer -Destination "$test_installer" -Force
|
||||
if ( Test-Path -Path "$test_installer" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Setup pytest
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host "Setting up venv: " -NoNewline
|
||||
python.exe -m venv venv
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Activating venv: " -NoNewline
|
||||
.\venv\Scripts\activate
|
||||
if ( "$env:VIRTUAL_ENV" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$pip_modules = "pytest",
|
||||
"pytest-helpers-namespace",
|
||||
"psutil"
|
||||
$pip_modules | ForEach-Object {
|
||||
Write-Host "Installing $_`: " -NoNewline
|
||||
Start-Process -FilePath pip `
|
||||
-ArgumentList "install", "$_" `
|
||||
-Wait -WindowStyle Hidden
|
||||
if ($( pip show $_ ) -contains "Name: $_") {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Complete
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Build Test Environment for NSIS Tests Complete" -ForegroundColor Cyan
|
||||
Write-Host $("=" * 80)
|
3
pkg/windows/nsis/tests/test.cmd
Normal file
3
pkg/windows/nsis/tests/test.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\test.ps1" %*
|
59
pkg/windows/nsis/tests/test.ps1
Normal file
59
pkg/windows/nsis/tests/test.ps1
Normal file
|
@ -0,0 +1,59 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Script to run the tests
|
||||
|
||||
.DESCRIPTION
|
||||
This script activates the venv and launches pytest
|
||||
|
||||
.EXAMPLE
|
||||
test.ps1
|
||||
#>
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Preferences
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Functions
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function Write-Result($result, $ForegroundColor="Green") {
|
||||
$position = 80 - $result.Length - [System.Console]::CursorLeft
|
||||
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Start
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Run Tests" -ForegroundColor Cyan
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Activating venv
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host "Activating venv: " -NoNewline
|
||||
.\venv\Scripts\activate
|
||||
if ( "$env:VIRTUAL_ENV" ) {
|
||||
Write-Result "Success"
|
||||
} else {
|
||||
Write-Result "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Running pytest..."
|
||||
Write-Host ""
|
||||
pytest -vvv -- .\config_tests\
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Complete
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Run Tests" -ForegroundColor Cyan
|
||||
Write-Host $("=" * 80)
|
Loading…
Add table
Reference in a new issue