test: bats-detect tests for "cscli setup" (#2057)
This commit is contained in:
parent
5aca11af70
commit
06ddd01c70
63 changed files with 2718 additions and 0 deletions
tests
ansible
debug_tools.ymlrequirements.ymlrun_wizard_tests.yml
vagrant/wizard
centos-8
debian-bullseye
debian-buster
fedora-36
ubuntu-22.04-jammy
ubuntu-22.10-kinetic
bats-detect
WARNING.mdapache2-deb.batsapache2-rpm.batsasterisk-deb.batsasterisk-rpm.batscaddy-deb.batscaddy-rpm.batsdovecot-deb.batsdovecot-rpm.batsemby-deb.batsemby-rpm.batsendlessh-deb.batsendlessh-rpm.batsgitea.batshaproxy-deb.batshaproxy-rpm.batslemonldap-deb.batslemonldap-rpm.bats
lib
litespeed.batsmariadb-deb.batsmariadb-rpm.batsmysql-deb.batsmysql-rpm.batsnginx-deb.batsnginx-rpm.batsodoo-deb.batsodoo-rpm.batsombi-deb.batsopenresty-deb.batsopenresty-rpm.batspgsql-deb.batspgsql-rpm.batspostfix-deb.batspostfix-rpm.batsproftpd-deb.batsproftpd-rpm.batsproxmox-deb.batspureftpd-deb.batspureftpd-rpm.batssmb-deb.batssmb-rpm.batssshd-deb.batssshd-rpm.batssuricata-deb.batssuricata-rpm.batstestdata
vsftpd-deb.batsvsftpd-rpm.bats
16
tests/ansible/debug_tools.yml
Normal file
16
tests/ansible/debug_tools.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
# vim: set ft=yaml.ansible:
|
||||
---
|
||||
|
||||
- name: "Install debug tools"
|
||||
hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: "Install debug tools"
|
||||
ansible.builtin.apt:
|
||||
pkg:
|
||||
- kitty
|
||||
- neovim
|
||||
- zsh
|
||||
- zsh-autosuggestions
|
||||
- zsh-syntax-highlighting
|
||||
- zsh-theme-powerlevel9k
|
|
@ -6,6 +6,9 @@ roles:
|
|||
- src: https://github.com/crowdsecurity/ansible-role-postgresql
|
||||
version: crowdsec
|
||||
name: geerlingguy.postgresql
|
||||
# these should be included as dependencies of crowdsecurity.testing, but sometime are not
|
||||
- src: geerlingguy.repo-epel
|
||||
- src: gantsign.golang
|
||||
|
||||
collections:
|
||||
- name: https://github.com/crowdsecurity/ansible-collection-crowdsecurity.testing.git
|
||||
|
|
15
tests/ansible/run_wizard_tests.yml
Normal file
15
tests/ansible/run_wizard_tests.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
# vim: set ft=yaml.ansible:
|
||||
---
|
||||
|
||||
- name: "Run setup/wizard tests"
|
||||
hosts: all
|
||||
tasks:
|
||||
# - name: "Build release package"
|
||||
# become: false
|
||||
# ansible.builtin.command:
|
||||
# cmd: "make clean release"
|
||||
- name: "Run BATS: service detection tests"
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
chdir: "/home/{{ ansible_user }}"
|
||||
cmd: "./crowdsec/tests/run-tests crowdsec/tests/bats-detect"
|
38
tests/ansible/vagrant/wizard/centos-8/Vagrantfile
vendored
Normal file
38
tests/ansible/vagrant/wizard/centos-8/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'centos/stream8'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
5
tests/ansible/vagrant/wizard/centos-8/bootstrap
Executable file
5
tests/ansible/vagrant/wizard/centos-8/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
unset IFS
|
||||
set -euf
|
||||
|
||||
sudo dnf -y update
|
43
tests/ansible/vagrant/wizard/debian-bullseye/Vagrantfile
vendored
Normal file
43
tests/ansible/vagrant/wizard/debian-bullseye/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'debian/bullseye64'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../debug_tools.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
5
tests/ansible/vagrant/wizard/debian-bullseye/bootstrap
Executable file
5
tests/ansible/vagrant/wizard/debian-bullseye/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
unset IFS
|
||||
set -euf
|
||||
|
||||
sudo apt install -y aptitude
|
43
tests/ansible/vagrant/wizard/debian-buster/Vagrantfile
vendored
Normal file
43
tests/ansible/vagrant/wizard/debian-buster/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'debian/buster64'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../debug_tools.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
5
tests/ansible/vagrant/wizard/debian-buster/bootstrap
Executable file
5
tests/ansible/vagrant/wizard/debian-buster/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
unset IFS
|
||||
set -euf
|
||||
|
||||
sudo apt install -y aptitude
|
38
tests/ansible/vagrant/wizard/fedora-36/Vagrantfile
vendored
Normal file
38
tests/ansible/vagrant/wizard/fedora-36/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'fedora/36-cloud-base'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
5
tests/ansible/vagrant/wizard/fedora-36/bootstrap
Executable file
5
tests/ansible/vagrant/wizard/fedora-36/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
unset IFS
|
||||
set -euf
|
||||
|
||||
sudo dnf -y update
|
43
tests/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile
vendored
Normal file
43
tests/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'generic/ubuntu2204'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../debug_tools.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
5
tests/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap
Executable file
5
tests/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
unset IFS
|
||||
set -euf
|
||||
|
||||
sudo apt install -y aptitude
|
43
tests/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile
vendored
Normal file
43
tests/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = 'generic/ubuntu2210'
|
||||
config.vm.define 'wizard'
|
||||
|
||||
config.vm.provision 'shell', path: 'bootstrap'
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 4
|
||||
libvirt.memory = 4096
|
||||
end
|
||||
|
||||
config.vm.synced_folder '.', '/vagrant', disabled: true
|
||||
|
||||
# install the dependencies for functional tests
|
||||
|
||||
config.vm.provision 'ansible' do |provdep|
|
||||
provdep.config_file = '../../../ansible.cfg'
|
||||
provdep.playbook = '../../../provision_dependencies.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |provtest|
|
||||
provtest.config_file = '../../../ansible.cfg'
|
||||
provtest.playbook = '../../../provision_test_suite.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../prepare_tests.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../debug_tools.yml'
|
||||
end
|
||||
|
||||
config.vm.provision 'ansible' do |preptest|
|
||||
preptest.config_file = '../../../ansible.cfg'
|
||||
preptest.playbook = '../../../run_wizard_tests.yml'
|
||||
end
|
||||
|
||||
end
|
8
tests/bats-detect/WARNING.md
Normal file
8
tests/bats-detect/WARNING.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
Running the tests in this directory WILL change the system configuration in
|
||||
unpredictable ways, remove packages and data (with a peculiar appetite for
|
||||
databases) and possibly bring the system to an unusable state.
|
||||
|
||||
They are meant to be run, as root, on temporary VMs. They are only intended to
|
||||
ease the development of configurations for "cscli setup detect".
|
||||
|
49
tests/bats-detect/apache2-deb.bats
Normal file
49
tests/bats-detect/apache2-deb.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove apache2
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "apache2: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'apache2-systemd-deb'
|
||||
refute_line 'apache2-systemd-rpm'
|
||||
}
|
||||
|
||||
@test "apache2: install" {
|
||||
run -0 deb-install apache2
|
||||
run -0 sudo systemctl enable apache2.service
|
||||
}
|
||||
|
||||
@test "apache2: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'apache2-systemd-deb'
|
||||
refute_line 'apache2-systemd-rpm'
|
||||
}
|
||||
|
||||
@test "apache2: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/apache2-rpm.bats
Normal file
49
tests/bats-detect/apache2-rpm.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove httpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "apache2: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'apache2-systemd-rpm'
|
||||
refute_line 'apache2-systemd-deb'
|
||||
}
|
||||
|
||||
@test "apache2: install" {
|
||||
run -0 rpm-install httpd
|
||||
run -0 sudo systemctl enable httpd.service
|
||||
}
|
||||
|
||||
@test "apache2: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'apache2-systemd-rpm'
|
||||
refute_line 'apache2-systemd-deb'
|
||||
}
|
||||
|
||||
@test "apache2: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/asterisk-deb.bats
Normal file
47
tests/bats-detect/asterisk-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove asterisk
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "asterisk: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'asterisk-systemd'
|
||||
}
|
||||
|
||||
@test "asterisk: install" {
|
||||
run -0 deb-install asterisk
|
||||
run -0 sudo systemctl enable asterisk.service
|
||||
}
|
||||
|
||||
@test "asterisk: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'asterisk-systemd'
|
||||
}
|
||||
|
||||
@test "asterisk: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
50
tests/bats-detect/asterisk-rpm.bats
Normal file
50
tests/bats-detect/asterisk-rpm.bats
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove asterisk
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
if ! dnf list | grep -q asterisk; then
|
||||
skip 'asterisk package not available'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "asterisk: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'asterisk-systemd'
|
||||
}
|
||||
|
||||
@test "asterisk: install" {
|
||||
run -0 rpm-install asterisk
|
||||
run -0 sudo systemctl enable asterisk.service
|
||||
}
|
||||
|
||||
@test "asterisk: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'asterisk-systemd'
|
||||
}
|
||||
|
||||
@test "asterisk: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
53
tests/bats-detect/caddy-deb.bats
Normal file
53
tests/bats-detect/caddy-deb.bats
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove caddy
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "caddy: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'caddy-systemd'
|
||||
}
|
||||
|
||||
@test "caddy: install" {
|
||||
run -0 deb-install debian-keyring debian-archive-keyring apt-transport-https
|
||||
run -0 curl -1sSLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key'
|
||||
run -0 sudo gpg --yes --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg < <(output)
|
||||
run -0 curl -1sSLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt'
|
||||
run -0 sudo tee /etc/apt/sources.list.d/caddy-stable.list < <(output)
|
||||
run -0 deb-update
|
||||
run -0 deb-install caddy
|
||||
run -0 sudo systemctl enable caddy.service
|
||||
}
|
||||
|
||||
@test "caddy: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'caddy-systemd'
|
||||
}
|
||||
|
||||
@test "caddy: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/caddy-rpm.bats
Normal file
49
tests/bats-detect/caddy-rpm.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove caddy
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "caddy: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'caddy-systemd'
|
||||
}
|
||||
|
||||
@test "caddy: install" {
|
||||
run -0 rpm-install 'dnf-command(copr)'
|
||||
run -0 sudo dnf -q -y copr enable @caddy/caddy
|
||||
run -0 rpm-install caddy
|
||||
run -0 sudo systemctl enable caddy.service
|
||||
}
|
||||
|
||||
@test "caddy: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'caddy-systemd'
|
||||
}
|
||||
|
||||
@test "caddy: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/dovecot-deb.bats
Normal file
47
tests/bats-detect/dovecot-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove dovecot-core
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "dovecot: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'dovecot-systemd'
|
||||
}
|
||||
|
||||
@test "dovecot: install" {
|
||||
run -0 deb-install dovecot-core
|
||||
run -0 sudo systemctl enable dovecot.service
|
||||
}
|
||||
|
||||
@test "dovecot: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'dovecot-systemd'
|
||||
}
|
||||
|
||||
@test "dovecot: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/dovecot-rpm.bats
Normal file
47
tests/bats-detect/dovecot-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove dovecot
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "dovecot: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'dovecot-systemd'
|
||||
}
|
||||
|
||||
@test "dovecot: install" {
|
||||
run -0 rpm-install dovecot
|
||||
run -0 sudo systemctl enable dovecot.service
|
||||
}
|
||||
|
||||
@test "dovecot: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'dovecot-systemd'
|
||||
}
|
||||
|
||||
@test "dovecot: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
52
tests/bats-detect/emby-deb.bats
Normal file
52
tests/bats-detect/emby-deb.bats
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove emby-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "emby: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'emby-systemd'
|
||||
}
|
||||
|
||||
@test "emby: install" {
|
||||
# https://emby.media/linux-server.html
|
||||
version=4.7.6.0
|
||||
filename="emby-server-deb_${version}_amd64.deb"
|
||||
# don't download twice
|
||||
run -0 curl -1sSLf "https://github.com/MediaBrowser/Emby.Releases/releases/download/${version}/${filename}" -o "${CACHEDIR}/${filename}"
|
||||
run -0 sudo dpkg --install "${CACHEDIR}/${filename}"
|
||||
run -0 sudo systemctl enable emby-server.service
|
||||
}
|
||||
|
||||
@test "emby: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'emby-systemd'
|
||||
}
|
||||
|
||||
@test "emby: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
52
tests/bats-detect/emby-rpm.bats
Normal file
52
tests/bats-detect/emby-rpm.bats
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove emby-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "emby: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'emby-systemd'
|
||||
}
|
||||
|
||||
@test "emby: install" {
|
||||
# https://emby.media/linux-server.html
|
||||
version=4.7.6.0
|
||||
filename="emby-server-rpm_${version}_x86_64.rpm"
|
||||
# don't download twice
|
||||
run -0 curl -1sSLf "https://github.com/MediaBrowser/Emby.Releases/releases/download/${version}/${filename}" -o "${CACHEDIR}/${filename}"
|
||||
run -0 rpm-install "${CACHEDIR}/${filename}"
|
||||
run -0 sudo systemctl enable emby-server.service
|
||||
}
|
||||
|
||||
@test "emby: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'emby-systemd'
|
||||
}
|
||||
|
||||
@test "emby: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
48
tests/bats-detect/endlessh-deb.bats
Normal file
48
tests/bats-detect/endlessh-deb.bats
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove endlessh
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "endlessh: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'endlessh-systemd'
|
||||
}
|
||||
|
||||
@test "endlessh: install" {
|
||||
# https://github.com/skeeto/endlessh
|
||||
run -0 deb-install endlessh
|
||||
run -0 sudo systemctl enable endlessh.service
|
||||
}
|
||||
|
||||
@test "endlessh: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'endlessh-systemd'
|
||||
}
|
||||
|
||||
@test "endlessh: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
48
tests/bats-detect/endlessh-rpm.bats
Normal file
48
tests/bats-detect/endlessh-rpm.bats
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove endlessh
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "endlessh: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'endlessh-systemd'
|
||||
}
|
||||
|
||||
@test "endlessh: install" {
|
||||
# https://github.com/skeeto/endlessh
|
||||
run -0 rpm-install endlessh
|
||||
run -0 sudo systemctl enable endlessh.service
|
||||
}
|
||||
|
||||
@test "endlessh: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'endlessh-systemd'
|
||||
}
|
||||
|
||||
@test "endlessh: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
46
tests/bats-detect/gitea.bats
Normal file
46
tests/bats-detect/gitea.bats
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
}
|
||||
|
||||
setup() {
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
skip 'WIP'
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "gitea: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'gitea-systemd'
|
||||
}
|
||||
|
||||
@test "gitea: install" {
|
||||
# https://docs.gitea.io/en-us/install-from-binary/#download
|
||||
version=1.16.9
|
||||
# don't download twice
|
||||
run -0 wget -nc --directory-prefix "$CACHEDIR" "https://dl.gitea.io/gitea/${version}/gitea-${version}-linux-amd64"
|
||||
}
|
||||
|
||||
@test "gitea: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'gitea-systemd'
|
||||
}
|
||||
|
||||
@test "gitea: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/haproxy-deb.bats
Normal file
47
tests/bats-detect/haproxy-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove haproxy
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "haproxy: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'haproxy-systemd'
|
||||
}
|
||||
|
||||
@test "haproxy: install" {
|
||||
run -0 deb-install haproxy
|
||||
run -0 sudo systemctl enable haproxy.service
|
||||
}
|
||||
|
||||
@test "haproxy: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'haproxy-systemd'
|
||||
}
|
||||
|
||||
@test "haproxy: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/haproxy-rpm.bats
Normal file
47
tests/bats-detect/haproxy-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove haproxy
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "haproxy: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'haproxy-systemd'
|
||||
}
|
||||
|
||||
@test "haproxy: install" {
|
||||
run -0 rpm-install haproxy
|
||||
run -0 sudo systemctl enable haproxy.service
|
||||
}
|
||||
|
||||
@test "haproxy: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'haproxy-systemd'
|
||||
}
|
||||
|
||||
@test "haproxy: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/lemonldap-deb.bats
Normal file
47
tests/bats-detect/lemonldap-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove lemonldap-ng
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "lemonldap: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'lemonldap-ng-systemd'
|
||||
}
|
||||
|
||||
@test "lemonldap: install" {
|
||||
run -0 deb-install lemonldap-ng
|
||||
run -0 sudo systemctl enable lemonldap-ng-fastcgi-server.service
|
||||
}
|
||||
|
||||
@test "lemonldap: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'lemonldap-ng-systemd'
|
||||
}
|
||||
|
||||
@test "lemonldap: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
50
tests/bats-detect/lemonldap-rpm.bats
Normal file
50
tests/bats-detect/lemonldap-rpm.bats
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove lemonldap-ng
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
skip 'WIP'
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "lemonldap: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'lemonldap-ng-systemd'
|
||||
}
|
||||
|
||||
@test "lemonldap: install" {
|
||||
run -0 rpm-install 'dnf-command(copr)'
|
||||
run -0 sudo dnf -q -y copr enable xavierb/lemonldap-ng
|
||||
run -0 rpm-install lemonldap-ng
|
||||
run -0 sudo systemctl enable lemonldap-ng-fastcgi-server.service
|
||||
}
|
||||
|
||||
@test "lemonldap: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'lemonldap-ng-systemd'
|
||||
}
|
||||
|
||||
@test "lemonldap: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
57
tests/bats-detect/lib/setup_file_detect.sh
Executable file
57
tests/bats-detect/lib/setup_file_detect.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
TESTDATA="${BATS_TEST_DIRNAME}/testdata"
|
||||
export TESTDATA
|
||||
|
||||
CACHEDIR="${TESTDATA}/.cache"
|
||||
export CACHEDIR
|
||||
|
||||
mkdir -p "${CACHEDIR}"
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
export DEBIAN_FRONTEND
|
||||
|
||||
# avoid warnings in stderr, especially from perl modules
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
deb-install() {
|
||||
# use aptitude to reliably purge dependencies too
|
||||
sudo aptitude install "$@" -yq >/dev/null
|
||||
# this does not work well enough
|
||||
# sudo apt-get -qq -y -o Dpkg:Use-Pty=0 install "$@" >/dev/null
|
||||
# sudo apt-mark auto "$@"
|
||||
}
|
||||
export -f deb-install
|
||||
|
||||
deb-update() {
|
||||
sudo apt-get -qq -y -o Dpkg:Use-Pty=0 update
|
||||
}
|
||||
export -f deb-update
|
||||
|
||||
deb-remove() {
|
||||
for pkg in "$@"; do
|
||||
if dpkg -s "${pkg}" >/dev/null 2>&1; then
|
||||
# use aptitude to reliably purge dependencies too
|
||||
sudo aptitude purge "${pkg}" -yq >/dev/null
|
||||
# this does not work well enough
|
||||
# sudo apt-get -qq -y purge --auto-remove "${pkg}" >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
export -f deb-remove
|
||||
|
||||
rpm-install() {
|
||||
sudo dnf -q -y install "$@"
|
||||
}
|
||||
export -f rpm-install
|
||||
|
||||
rpm-remove() {
|
||||
# don't fail if dnf does not exist (teardown is called on deb distros too)
|
||||
if command -v dnf >/dev/null; then
|
||||
sudo dnf -q -y remove "$@" >/dev/null
|
||||
fi
|
||||
}
|
||||
export -f rpm-remove
|
||||
|
||||
export CROWDSEC_FEATURE_CSCLI_SETUP="true"
|
47
tests/bats-detect/litespeed.bats
Normal file
47
tests/bats-detect/litespeed.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove openlitespeed
|
||||
}
|
||||
|
||||
setup() {
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
skip 'WIP'
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "openlitespeed: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'litespeed-systemd'
|
||||
}
|
||||
|
||||
@test "openlitespeed: install" {
|
||||
run -0 sudo "${TESTDATA}/enable_lst_debian_repo.sh"
|
||||
run -0 deb-update
|
||||
run -0 deb-install openlitespeed
|
||||
# run -0 sudo systemctl enable XXX TODO
|
||||
}
|
||||
|
||||
@test "litespeed: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'litespeed-systemd'
|
||||
}
|
||||
|
||||
@test "litespeed: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/mariadb-deb.bats
Normal file
47
tests/bats-detect/mariadb-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove mariadb-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "mariadb: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'mariadb-systemd'
|
||||
}
|
||||
|
||||
@test "mariadb: install" {
|
||||
run -0 deb-install mariadb-server
|
||||
run -0 sudo systemctl enable mariadb.service
|
||||
}
|
||||
|
||||
@test "mariadb: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'mariadb-systemd'
|
||||
}
|
||||
|
||||
@test "mariadb: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/mariadb-rpm.bats
Normal file
47
tests/bats-detect/mariadb-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove mariadb-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "mariadb: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'mariadb-systemd'
|
||||
}
|
||||
|
||||
@test "mariadb: install" {
|
||||
run -0 rpm-install mariadb-server
|
||||
run -0 sudo systemctl enable mariadb.service
|
||||
}
|
||||
|
||||
@test "mariadb: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'mariadb-systemd'
|
||||
}
|
||||
|
||||
@test "mariadb: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
64
tests/bats-detect/mysql-deb.bats
Normal file
64
tests/bats-detect/mysql-deb.bats
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
# debian: mysql-community-server
|
||||
# ubuntu: mysql-server
|
||||
deb-remove mysql-server mysql-community-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
if apt-cache search --names-only "^mysql-server$"; then
|
||||
skip "mysql-server package not available"
|
||||
fi
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "mysql: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'mysql-systemd'
|
||||
}
|
||||
|
||||
@test "mysql: install" {
|
||||
# ubuntu comes with mysql, debian does not
|
||||
if apt-cache search --names-only "^mysql-server$"; then
|
||||
# package not available, install the repo
|
||||
filename="mysql-apt-config_0.8.23-1_all.deb"
|
||||
run -0 curl -1sSLf "https://dev.mysql.com/get/${filename}" -o "${CACHEDIR}/${filename}"
|
||||
# XXX md5 c2b410031867dc7c966ca5b1aa0c72aa
|
||||
run -0 sudo dpkg --install "${CACHEDIR}/${filename}"
|
||||
run -0 deb-update
|
||||
# XXX this hangs
|
||||
run -0 deb-install mysql-community-server
|
||||
else
|
||||
run -0 deb-install mysql-server
|
||||
fi
|
||||
run -0 sudo systemctl enable mysql.service
|
||||
}
|
||||
|
||||
@test "mysql: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'mysql-systemd'
|
||||
}
|
||||
|
||||
@test "mysql: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
48
tests/bats-detect/mysql-rpm.bats
Normal file
48
tests/bats-detect/mysql-rpm.bats
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove mysql-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
skip 'WIP'
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "mysql: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'mysql-systemd'
|
||||
}
|
||||
|
||||
@test "mysql: install" {
|
||||
run -0 rpm-install mysql-server
|
||||
run -0 sudo systemctl enable mysql.service
|
||||
}
|
||||
|
||||
@test "mysql: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'mysql-systemd'
|
||||
}
|
||||
|
||||
@test "mysql: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/nginx-deb.bats
Normal file
47
tests/bats-detect/nginx-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove nginx
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "nginx: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'nginx-systemd'
|
||||
}
|
||||
|
||||
@test "nginx: install" {
|
||||
run -0 deb-install nginx
|
||||
run -0 sudo systemctl enable nginx.service
|
||||
}
|
||||
|
||||
@test "nginx: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'nginx-systemd'
|
||||
}
|
||||
|
||||
@test "nginx: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/nginx-rpm.bats
Normal file
47
tests/bats-detect/nginx-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove nginx
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "nginx: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'nginx-systemd'
|
||||
}
|
||||
|
||||
@test "nginx: install" {
|
||||
run -0 rpm-install nginx
|
||||
run -0 sudo systemctl enable nginx.service
|
||||
}
|
||||
|
||||
@test "nginx: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'nginx-systemd'
|
||||
}
|
||||
|
||||
@test "nginx: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
52
tests/bats-detect/odoo-deb.bats
Normal file
52
tests/bats-detect/odoo-deb.bats
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove odoo
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "odoo: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'odoo-systemd'
|
||||
}
|
||||
|
||||
@test "odoo: install" {
|
||||
run -0 deb-install debian-keyring debian-archive-keyring apt-transport-https
|
||||
run -0 curl -1sSLf https://nightly.odoo.com/odoo.key
|
||||
run -0 sudo gpg --yes --dearmor -o /usr/share/keyrings/odoo-keyring.gpg < <(output)
|
||||
run -0 sudo tee <<< "deb [signed-by=/usr/share/keyrings/odoo-keyring.gpg] https://nightly.odoo.com/15.0/nightly/deb/ ./" /etc/apt/sources.list.d/odoo.list >/dev/null
|
||||
run -0 deb-update
|
||||
run -0 deb-install odoo
|
||||
# run -0 sudo systemctl enable caddy.service
|
||||
}
|
||||
|
||||
@test "odoo: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'odoo-systemd'
|
||||
}
|
||||
|
||||
@test "odoo: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/odoo-rpm.bats
Normal file
49
tests/bats-detect/odoo-rpm.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove odoo
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
skip 'WIP (https://bytemeta.vip/repo/odoo/odoo/issues/95168)'
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "odoo: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'odoo-systemd'
|
||||
}
|
||||
|
||||
@test "odoo: install" {
|
||||
run -0 sudo dnf config-manager --add-repo=https://nightly.odoo.com/15.0/nightly/rpm/odoo.repo
|
||||
run -0 rpm-install odoo
|
||||
run -0 sudo systemctl enable odoo
|
||||
}
|
||||
|
||||
@test "odoo: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'odoo-systemd'
|
||||
}
|
||||
|
||||
@test "odoo: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
52
tests/bats-detect/ombi-deb.bats
Normal file
52
tests/bats-detect/ombi-deb.bats
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove ombi
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "ombi: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'ombi-systemd'
|
||||
}
|
||||
|
||||
@test "ombi: install" {
|
||||
run -0 deb-install debian-keyring debian-archive-keyring apt-transport-https
|
||||
run -0 curl -1sSLf https://apt.ombi.app/pub.key
|
||||
run -0 sudo gpg --yes --dearmor -o /usr/share/keyrings/ombi-keyring.gpg < <(output)
|
||||
run -0 sudo tee <<< "deb [signed-by=/usr/share/keyrings/ombi-keyring.gpg] https://apt.ombi.app/develop jessie main" /etc/apt/sources.list.d/ombi.list >/dev/null
|
||||
run -0 deb-update
|
||||
run -0 deb-install ombi
|
||||
run -0 sudo systemctl enable ombi.service
|
||||
}
|
||||
|
||||
@test "ombi: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'ombi-systemd'
|
||||
}
|
||||
|
||||
@test "ombi: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
57
tests/bats-detect/openresty-deb.bats
Normal file
57
tests/bats-detect/openresty-deb.bats
Normal file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove openresty
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "openresty: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'openresty-systemd'
|
||||
}
|
||||
|
||||
@test "openresty: install" {
|
||||
run -0 deb-install debian-keyring debian-archive-keyring apt-transport-https
|
||||
run -0 curl -1sSLf 'https://openresty.org/package/pubkey.gpg'
|
||||
if [[ "$(lsb_release -is)" == "Ubuntu" ]]; then
|
||||
run -0 sudo gpg --yes --dearmor -o /usr/share/keyrings/openresty.gpg < <(output)
|
||||
run -0 sudo tee <<< "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" /etc/apt/sources.list.d/openresty.list
|
||||
else
|
||||
run -0 sudo apt-key add - < <(output)
|
||||
run -0 sudo tee <<< "deb http://openresty.org/package/debian $(lsb_release -sc) openresty" /etc/apt/sources.list.d/openresty.list
|
||||
fi
|
||||
run -0 deb-update
|
||||
run -0 deb-install openresty
|
||||
run -0 sudo systemctl enable openresty.service
|
||||
}
|
||||
|
||||
@test "openresty: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'openresty-systemd'
|
||||
}
|
||||
|
||||
@test "openresty: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
54
tests/bats-detect/openresty-rpm.bats
Normal file
54
tests/bats-detect/openresty-rpm.bats
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove openresty
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "openresty: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'openresty-systemd'
|
||||
}
|
||||
|
||||
@test "openresty: install" {
|
||||
run -0 rpm-install redhat-lsb-core
|
||||
if [[ "$(lsb_release -is)" == "Fedora" ]]; then
|
||||
run -0 sudo curl -1sSLf "https://openresty.org/package/fedora/openresty.repo" -o "/etc/yum.repos.d/openresty.repo"
|
||||
elif [[ "$(lsb_release -is)" == "CentOS" ]]; then
|
||||
run -0 sudo curl -1sSLf "https://openresty.org/package/centos/openresty.repo" -o "/etc/yum.repos.d/openresty.repo"
|
||||
fi
|
||||
run -0 sudo dnf check-update
|
||||
run -0 rpm-install openresty
|
||||
run -0 sudo systemctl enable openresty.service
|
||||
}
|
||||
|
||||
@test "openresty: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'openresty-systemd'
|
||||
}
|
||||
|
||||
@test "openresty: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
61
tests/bats-detect/pgsql-deb.bats
Normal file
61
tests/bats-detect/pgsql-deb.bats
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
cleanup() {
|
||||
command -v dpkg >/dev/null || return 0
|
||||
# sudo systemctl stop postgresql.service || :
|
||||
# remove the DB to avoid a prompt from postrm
|
||||
if [[ -d /var/lib/postgresql ]]; then
|
||||
# shellcheck disable=SC2045
|
||||
for cluster in $(ls /var/lib/postgresql 2>/dev/null); do
|
||||
sudo pg_dropcluster --stop "${cluster}" main
|
||||
done
|
||||
fi
|
||||
deb-remove postgresql $(dpkg -l | grep postgres | awk '{print $2}')
|
||||
}
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
cleanup
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
cleanup
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "pgsql: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'pgsql-systemd-deb'
|
||||
}
|
||||
|
||||
@test "pgsql: install" {
|
||||
run -0 deb-install postgresql
|
||||
run -0 sudo systemctl enable postgresql.service
|
||||
}
|
||||
|
||||
@test "pgsql: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'pgsql-systemd-deb'
|
||||
}
|
||||
|
||||
@test "pgsql: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
51
tests/bats-detect/pgsql-rpm.bats
Normal file
51
tests/bats-detect/pgsql-rpm.bats
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove postgresql-server
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "pgsql: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'pgsql-systemd-rpm'
|
||||
}
|
||||
|
||||
@test "pgsql: install" {
|
||||
run -0 rpm-install postgresql-server
|
||||
# for centos 8, we need to create the cluster
|
||||
if ! sudo bash -c 'stat /var/lib/pgsql/data/*'; then
|
||||
sudo /usr/bin/postgresql-setup --initdb
|
||||
fi
|
||||
run -0 sudo systemctl enable postgresql.service
|
||||
}
|
||||
|
||||
@test "pgsql: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'pgsql-systemd-rpm'
|
||||
}
|
||||
|
||||
@test "pgsql: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/postfix-deb.bats
Normal file
49
tests/bats-detect/postfix-deb.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove postfix
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "postfix: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'postfix-systemd'
|
||||
}
|
||||
|
||||
@test "postfix: install" {
|
||||
run -0 sudo debconf-set-selections <<< "postfix postfix/mailname string hostname.example.com"
|
||||
run -0 sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
|
||||
run -0 deb-install postfix
|
||||
run -0 sudo systemctl enable postfix.service
|
||||
}
|
||||
|
||||
@test "postfix: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'postfix-systemd'
|
||||
}
|
||||
|
||||
@test "postfix: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/postfix-rpm.bats
Normal file
47
tests/bats-detect/postfix-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove postfix
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "postfix: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'postfix-systemd'
|
||||
}
|
||||
|
||||
@test "postfix: install" {
|
||||
run -0 rpm-install postfix
|
||||
run -0 sudo systemctl enable postfix.service
|
||||
}
|
||||
|
||||
@test "postfix: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'postfix-systemd'
|
||||
}
|
||||
|
||||
@test "postfix: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/proftpd-deb.bats
Normal file
47
tests/bats-detect/proftpd-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove proftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "proftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'proftpd-systemd'
|
||||
}
|
||||
|
||||
@test "proftpd: install" {
|
||||
run -0 deb-install proftpd
|
||||
run -0 sudo systemctl enable proftpd.service
|
||||
}
|
||||
|
||||
@test "proftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'proftpd-systemd'
|
||||
}
|
||||
|
||||
@test "proftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/proftpd-rpm.bats
Normal file
47
tests/bats-detect/proftpd-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove proftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "proftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'proftpd-systemd'
|
||||
}
|
||||
|
||||
@test "proftpd: install" {
|
||||
run -0 rpm-install proftpd
|
||||
run -0 sudo systemctl enable proftpd.service
|
||||
}
|
||||
|
||||
@test "proftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'proftpd-systemd'
|
||||
}
|
||||
|
||||
@test "proftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
62
tests/bats-detect/proxmox-deb.bats
Normal file
62
tests/bats-detect/proxmox-deb.bats
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove proxmox-ve
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
|
||||
. /etc/os-release
|
||||
case "$VERSION_CODENAME" in
|
||||
bullseye | buster | jessie | squeeze | stretch | wheezy)
|
||||
skip "the installation does not work"
|
||||
;;
|
||||
*)
|
||||
skip "unsupported distribution"
|
||||
;;
|
||||
esac
|
||||
export VERSION_CODENAME
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "proxmox: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'proxmox-systemd'
|
||||
}
|
||||
|
||||
@test "proxmox: install" {
|
||||
run -0 deb-install debian-keyring debian-archive-keyring apt-transport-https
|
||||
run -0 sudo curl -1sSLf http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -o /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
|
||||
run -0 sudo tee <<<"deb http://download.proxmox.com/debian/pve ${VERSION_CODENAME} pve-no-subscription" /etc/apt/sources.list.d/proxmox.list >/dev/null
|
||||
run -0 deb-update
|
||||
run -0 deb-install proxmox-ve
|
||||
run -0 sudo systemctl enable proxmox.service
|
||||
}
|
||||
|
||||
@test "proxmox: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'proxmox-systemd'
|
||||
}
|
||||
|
||||
@test "proxmox: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/pureftpd-deb.bats
Normal file
47
tests/bats-detect/pureftpd-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove pure-ftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "pureftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'pureftpd-systemd'
|
||||
}
|
||||
|
||||
@test "pureftpd: install" {
|
||||
run -0 deb-install pure-ftpd
|
||||
run -0 sudo systemctl enable pure-ftpd.service
|
||||
}
|
||||
|
||||
@test "pureftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'pureftpd-systemd'
|
||||
}
|
||||
|
||||
@test "pureftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/pureftpd-rpm.bats
Normal file
47
tests/bats-detect/pureftpd-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove pure-ftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "pureftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'pureftpd-systemd'
|
||||
}
|
||||
|
||||
@test "pureftpd: install" {
|
||||
run -0 rpm-install pure-ftpd
|
||||
run -0 sudo systemctl enable pure-ftpd.service
|
||||
}
|
||||
|
||||
@test "pureftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'pureftpd-systemd'
|
||||
}
|
||||
|
||||
@test "pureftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
50
tests/bats-detect/smb-deb.bats
Normal file
50
tests/bats-detect/smb-deb.bats
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove samba
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "smb: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'smb-systemd'
|
||||
}
|
||||
|
||||
@test "smb: install" {
|
||||
run -0 sudo debconf-set-selections <<< "samba-common samba-common/workgroup string WORKGROUP"
|
||||
run -0 sudo debconf-set-selections <<< "samba-common samba-common/dhcp boolean true"
|
||||
run -0 sudo debconf-set-selections <<< "samba-common samba-common/do_debconf boolean true"
|
||||
run -0 deb-install samba
|
||||
run -0 sudo systemctl enable smbd.service
|
||||
}
|
||||
|
||||
@test "smb: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'smb-systemd'
|
||||
}
|
||||
|
||||
@test "smb: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/smb-rpm.bats
Normal file
47
tests/bats-detect/smb-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove samba
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "smb: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'smb-systemd'
|
||||
}
|
||||
|
||||
@test "smb: install" {
|
||||
run -0 rpm-install samba
|
||||
run -0 sudo systemctl enable smb.service
|
||||
}
|
||||
|
||||
@test "smb: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'smb-systemd'
|
||||
}
|
||||
|
||||
@test "smb: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/sshd-deb.bats
Normal file
49
tests/bats-detect/sshd-deb.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
# don't remove ssh here, we assume it's needed
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "sshd: detect unit (fail)" {
|
||||
run -0 sudo systemctl mask ssh.service
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'sshd-systemd'
|
||||
}
|
||||
|
||||
@test "sshd: install" {
|
||||
# run -0 deb-install openssh-server
|
||||
run -0 sudo systemctl unmask ssh.service
|
||||
run -0 sudo systemctl enable ssh.service
|
||||
}
|
||||
|
||||
@test "sshd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'sshd-systemd'
|
||||
}
|
||||
|
||||
@test "sshd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
49
tests/bats-detect/sshd-rpm.bats
Normal file
49
tests/bats-detect/sshd-rpm.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
# don't remove ssh here, we assume it's needed
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "sshd: detect unit (fail)" {
|
||||
run -0 sudo systemctl mask sshd.service
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'sshd-systemd'
|
||||
}
|
||||
|
||||
@test "sshd: install" {
|
||||
# run -0 rpm-install openssh-server
|
||||
run -0 sudo systemctl unmask sshd.service
|
||||
run -0 sudo systemctl enable sshd.service
|
||||
}
|
||||
|
||||
@test "sshd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'sshd-systemd'
|
||||
}
|
||||
|
||||
@test "sshd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/suricata-deb.bats
Normal file
47
tests/bats-detect/suricata-deb.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
deb-remove suricata
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "suricata: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'suricata-systemd'
|
||||
}
|
||||
|
||||
@test "suricata: install" {
|
||||
run -0 deb-install suricata
|
||||
run -0 sudo systemctl enable suricata.service
|
||||
}
|
||||
|
||||
@test "suricata: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'suricata-systemd'
|
||||
}
|
||||
|
||||
@test "suricata: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/suricata-rpm.bats
Normal file
47
tests/bats-detect/suricata-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove suricata
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "suricata: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'suricata-systemd'
|
||||
}
|
||||
|
||||
@test "suricata: install" {
|
||||
run -0 rpm-install suricata
|
||||
run -0 sudo systemctl enable suricata.service
|
||||
}
|
||||
|
||||
@test "suricata: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'suricata-systemd'
|
||||
}
|
||||
|
||||
@test "suricata: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
65
tests/bats-detect/testdata/enable_lst_debian_repo.sh
vendored
Executable file
65
tests/bats-detect/testdata/enable_lst_debian_repo.sh
vendored
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
if [ -r /etc/os-release ]; then
|
||||
|
||||
echo " detecting OS type : "
|
||||
|
||||
. /etc/os-release
|
||||
|
||||
if [ $ID == "debian" ]; then
|
||||
echo "detected OS: $ID - $VERSION_ID"
|
||||
echo " now enable the LiteSpeed Debian Repo "
|
||||
if [ $VERSION_ID == "11" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ bullseye main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ bullseye main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ $VERSION_ID == "10" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ buster main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ buster main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ $VERSION_ID == "9" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ stretch main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ stretch main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ $VERSION_ID == "8" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ jessie main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ jessie main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
fi
|
||||
elif [ $ID == "ubuntu" ]; then
|
||||
echo "detected OS: $ID - $VERSION_ID"
|
||||
echo " now enable the LiteSpeed Debian Repo "
|
||||
if [ `echo "$VERSION_ID" | cut -b-2 ` == "14" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ trusty main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ trusty main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ `echo "$VERSION_ID" | cut -b-2 ` == "12" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ precise main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ precise main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ `echo "$VERSION_ID" | cut -b-2 ` == "16" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ xenial main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ xenial main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ `echo "$VERSION_ID" | cut -b-2 ` == "18" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ bionic main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ bionic main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ `echo "$VERSION_ID" | cut -b-2 ` == "20" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ focal main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ focal main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
elif [ `echo "$VERSION_ID" | cut -b-2 ` == "22" ]; then
|
||||
echo "deb http://rpms.litespeedtech.com/debian/ focal main" > /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
echo "#deb http://rpms.litespeedtech.com/edge/debian/ focal main" >> /etc/apt/sources.list.d/lst_debian_repo.list
|
||||
fi
|
||||
else
|
||||
echo " This distribution is not currently supported by LST repo "
|
||||
echo " If you really have the needs please contact LiteSpeed for support "
|
||||
fi
|
||||
else
|
||||
echo " The /etc/os-release file doesn't exist "
|
||||
echo " This script couldn't determine which distribution of the repo should be enabled "
|
||||
echo " Please consult LiteSpeed Customer Support for further assistance "
|
||||
fi
|
||||
|
||||
echo " register LiteSpeed GPG key "
|
||||
wget -O /etc/apt/trusted.gpg.d/lst_debian_repo.gpg http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
|
||||
wget -O /etc/apt/trusted.gpg.d/lst_repo.gpg http://rpms.litespeedtech.com/debian/lst_repo.gpg
|
||||
|
||||
echo " update the repo "
|
||||
apt-get update
|
||||
|
||||
echo " All done, congratulations and enjoy ! "
|
48
tests/bats-detect/vsftpd-deb.bats
Normal file
48
tests/bats-detect/vsftpd-deb.bats
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
sudo systemctl stop vsftpd.service 2>/dev/null || :
|
||||
deb-remove vsftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dpkg >/dev/null; then
|
||||
skip 'not a debian-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "vsftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'vsftpd-systemd'
|
||||
}
|
||||
|
||||
@test "vsftpd: install" {
|
||||
run -0 deb-install vsftpd
|
||||
run -0 sudo systemctl enable vsftpd.service
|
||||
}
|
||||
|
||||
@test "vsftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'vsftpd-systemd'
|
||||
}
|
||||
|
||||
@test "vsftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
47
tests/bats-detect/vsftpd-rpm.bats
Normal file
47
tests/bats-detect/vsftpd-rpm.bats
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bats
|
||||
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
||||
|
||||
set -u
|
||||
|
||||
setup_file() {
|
||||
load "../lib/setup_file.sh"
|
||||
load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
load "../lib/teardown_file.sh"
|
||||
rpm-remove vsftpd
|
||||
}
|
||||
|
||||
setup() {
|
||||
if ! command -v dnf >/dev/null; then
|
||||
skip 'not a redhat-like system'
|
||||
fi
|
||||
load "../lib/setup.sh"
|
||||
load "../lib/bats-file/load.bash"
|
||||
./instance-data load
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
@test "vsftpd: detect unit (fail)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
refute_line 'vsftpd-systemd'
|
||||
}
|
||||
|
||||
@test "vsftpd: install" {
|
||||
run -0 rpm-install vsftpd
|
||||
run -0 sudo systemctl enable vsftpd.service
|
||||
}
|
||||
|
||||
@test "vsftpd: detect unit (succeed)" {
|
||||
run -0 cscli setup detect
|
||||
run -0 jq -r '.setup | .[].detected_service' <(output)
|
||||
assert_line 'vsftpd-systemd'
|
||||
}
|
||||
|
||||
@test "vsftpd: install detected collection" {
|
||||
run -0 cscli setup detect
|
||||
run -0 cscli setup install-hub <(output)
|
||||
}
|
Loading…
Add table
Reference in a new issue