diff --git a/tests/bats/fc-cache.bats b/tests/bats/fc-cache.bats new file mode 100644 index 000000000..7ad92d94c --- /dev/null +++ b/tests/bats/fc-cache.bats @@ -0,0 +1,29 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=fc-cache +@test "fc-cache: Generate font cache files" { + fc-cache + aa_check +} + +# bats test_tags=fc-cache +@test "fc-cache: Force a rebuild of all font cache files, without checking if cache is up-to-date" { + fc-cache -f + aa_check +} + +# bats test_tags=fc-cache +@test "fc-cache: Erase font cache files, then generate new font cache files" { + fc-cache -r + aa_check +} + diff --git a/tests/bats/fc-list.bats b/tests/bats/fc-list.bats new file mode 100644 index 000000000..b85b1037e --- /dev/null +++ b/tests/bats/fc-list.bats @@ -0,0 +1,16 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=fc-list +@test "fc-list: Return a list of installed fonts in your system" { + fc-list + aa_check +} diff --git a/tests/bats/flatpak.bats b/tests/bats/flatpak.bats new file mode 100644 index 000000000..23647c932 --- /dev/null +++ b/tests/bats/flatpak.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=flatpak +@test "flatpak: List installed applications, ignoring runtimes" { + flatpak list --app + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Install an application from a remote source" { + flatpak install --noninteractive org.vim.Vim + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Show information about an installed application" { + flatpak info org.vim.Vim + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Run an installed application" { + flatpak run org.vim.Vim + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Update all installed applications and runtimes" { + flatpak update --noninteractive + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Remove an installed application" { + flatpak remove --noninteractive org.vim.Vim + aa_check +} + +# bats test_tags=flatpak +@test "flatpak: Remove all unused applications" { + flatpak remove --unused + aa_check +} diff --git a/tests/bats/gpgconf.bats b/tests/bats/gpgconf.bats new file mode 100644 index 000000000..871a8f1ec --- /dev/null +++ b/tests/bats/gpgconf.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=gpgconf +@test "gpgconf: List all components" { + gpgconf --list-components + aa_check +} + +# bats test_tags=gpgconf +@test "gpgconf: List the directories used by gpgconf" { + gpgconf --list-dirs + aa_check +} + +# bats test_tags=gpgconf +@test "gpgconf: List all options of a component" { + gpgconf --list-options gpg + gpgconf --list-options gpgsm + gpgconf --list-options gpg-agent + gpgconf --list-options scdaemon + gpgconf --list-options dirmngr + aa_check +} + diff --git a/tests/bats/groups.bats b/tests/bats/groups.bats new file mode 100644 index 000000000..829e2393f --- /dev/null +++ b/tests/bats/groups.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=groups +@test "groups: Print group memberships for the current user" { + groups + aa_check +} + +# bats test_tags=groups +@test "groups: Print group memberships for a list of users" { + groups root + aa_check +} + diff --git a/tests/bats/ip.bats b/tests/bats/ip.bats new file mode 100644 index 000000000..980495d2d --- /dev/null +++ b/tests/bats/ip.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=ip +@test "ip: List interfaces with detailed info" { + ip address + aa_check +} + +# bats test_tags=ip +@test "ip: List interfaces with brief network layer info" { + ip -brief address + aa_check +} + +# bats test_tags=ip +@test "ip: List interfaces with brief link layer info" { + ip -brief link + aa_check +} + +# bats test_tags=ip +@test "ip: Display the routing table" { + ip route + aa_check +} + +# bats test_tags=ip +@test "ip: Show neighbors (ARP table)" { + ip neighbour + aa_check +} + diff --git a/tests/bats/snap.bats b/tests/bats/snap.bats new file mode 100644 index 000000000..ef6a292da --- /dev/null +++ b/tests/bats/snap.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=snap +@test "snap: Search for a package" { + snap find vim + aa_check +} + +# bats test_tags=snap +@test "snap: Install a package" { + sudo snap install nano-strict + aa_check +} + +# bats test_tags=snap +@test "snap: Update a package to another channel (track, risk, or branch)" { + sudo snap refresh nano-strict --channel=edge + aa_check +} + +# bats test_tags=snap +@test "snap: Update all packages" { + sudo snap refresh + aa_check +} + +# bats test_tags=snap +@test "snap: Display basic information about installed snap software" { + sudo snap list + aa_check +} + +# bats test_tags=snap +@test "snap: Check for recent snap changes in the system" { + sudo snap changes + aa_check +} + +# bats test_tags=snap +@test "snap: Uninstall a package" { + sudo snap remove nano-strict + aa_check +} diff --git a/tests/bats/systemd-detect-virt.bats b/tests/bats/systemd-detect-virt.bats new file mode 100644 index 000000000..0ea5fae35 --- /dev/null +++ b/tests/bats/systemd-detect-virt.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +# bats test_tags=systemd-detect-virt +@test "systemd-detect-virt: List detectable virtualization technologies" { + systemd-detect-virt --list +} + +# bats test_tags=systemd-detect-virt +@test "systemd-detect-virt: Detect virtualization, print the result and return a zero status code when running in a VM or a container, and a non-zero code otherwise" { + systemd-detect-virt +} + +# bats test_tags=systemd-detect-virt +@test "systemd-detect-virt: Silently check without printing anything" { + systemd-detect-virt --quiet +} + +# bats test_tags=systemd-detect-virt +@test "systemd-detect-virt: Only detect hardware virtualization" { + systemd-detect-virt --vm +} + diff --git a/tests/bats/uname.bats b/tests/bats/uname.bats new file mode 100644 index 000000000..683cef111 --- /dev/null +++ b/tests/bats/uname.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=uname +@test "uname: Print all information" { + uname --all + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current kernel name" { + uname --kernel-name + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current network node host name" { + uname --nodename + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current kernel release" { + uname --kernel-release + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current kernel version" { + uname --kernel-version + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current machine hardware name" { + uname --machine + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current processor type" { + uname --processor + aa_check +} + +# bats test_tags=uname +@test "uname: Print the current operating system name" { + uname --operating-system + aa_check +} + diff --git a/tests/bats/uptime.bats b/tests/bats/uptime.bats new file mode 100644 index 000000000..846342f47 --- /dev/null +++ b/tests/bats/uptime.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=uptime +@test "uptime: Print current time, uptime, number of logged-in users and other information" { + uptime + aa_check +} + +# bats test_tags=uptime +@test "uptime: Show only the amount of time the system has been booted for" { + uptime --pretty + aa_check +} + +# bats test_tags=uptime +@test "uptime: Print the date and time the system booted up at" { + uptime --since + aa_check +} + +# bats test_tags=uptime +@test "uptime: Display version" { + uptime --version + aa_check +} + diff --git a/tests/bats/users.bats b/tests/bats/users.bats new file mode 100644 index 000000000..097870abf --- /dev/null +++ b/tests/bats/users.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=users +@test "users: Print logged in usernames" { + users + aa_check +} + +# bats test_tags=users +@test "users: Print logged in usernames according to a given file" { + users /var/log/wmtp + aa_check +} + diff --git a/tests/bats/uuidgen.bats b/tests/bats/uuidgen.bats new file mode 100644 index 000000000..8caa41862 --- /dev/null +++ b/tests/bats/uuidgen.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=uuidgen +@test "uuidgen: Create a random UUIDv4" { + uuidgen --random + aa_check +} + +# bats test_tags=uuidgen +@test "uuidgen: Create a UUIDv1 based on the current time" { + uuidgen --time + aa_check +} + diff --git a/tests/bats/who.bats b/tests/bats/who.bats new file mode 100644 index 000000000..f8aaf5a17 --- /dev/null +++ b/tests/bats/who.bats @@ -0,0 +1,29 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +setup_file() { + aa_setup +} + +# bats test_tags=who +@test "who: Display the username, line, and time of all currently logged-in sessions" { + who + aa_check +} + +# bats test_tags=who +@test "who: Display all available information" { + who -a + aa_check +} + +# bats test_tags=who +@test "who: Display all available information with table headers" { + who -a -H + aa_check +} +