2023-08-17 04:56:14 +05:30
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def test_ssh_is_listening(host):
|
|
|
|
socket = host.socket(f"tcp://0.0.0.0:22")
|
|
|
|
assert socket.is_listening
|
|
|
|
|
|
|
|
|
|
|
|
def test_ufw_service_running_and_enabled(host):
|
|
|
|
service = host.service("ufw")
|
|
|
|
assert service.is_running
|
|
|
|
assert service.is_enabled
|
|
|
|
|
|
|
|
|
|
|
|
def test_ssh_service_running_and_enabled(host):
|
|
|
|
service = host.service("ssh")
|
|
|
|
assert service.is_running
|
|
|
|
assert service.is_enabled
|
|
|
|
|
|
|
|
|
|
|
|
def test_ssh_is_installed(host):
|
|
|
|
pkg = host.package("openssh-server")
|
|
|
|
assert pkg.is_installed
|
2023-08-17 05:05:02 +05:30
|
|
|
|
|
|
|
|
|
|
|
def test_pkgis_installed(host):
|
|
|
|
for pkg in [
|
|
|
|
"git",
|
|
|
|
"wget",
|
|
|
|
"curl",
|
|
|
|
"gpg",
|
|
|
|
"ca-certificates",
|
|
|
|
"zip",
|
|
|
|
"python3-pip",
|
|
|
|
"virtualenv",
|
|
|
|
"python3-setuptools",
|
|
|
|
"ufw",
|
|
|
|
]:
|
|
|
|
assert host.package(pkg).is_installed
|