tests(integration): add more test cases (2).

This commit is contained in:
Alexandre Pujol 2024-10-21 23:36:51 +01:00
parent f14fef10c2
commit 21dcda26bb
Failed to generate hash of commit
13 changed files with 440 additions and 0 deletions

29
tests/bats/fc-cache.bats Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

16
tests/bats/fc-list.bats Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

52
tests/bats/flatpak.bats Normal file
View file

@ -0,0 +1,52 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

33
tests/bats/gpgconf.bats Normal file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

23
tests/bats/groups.bats Normal file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

41
tests/bats/ip.bats Normal file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

52
tests/bats/snap.bats Normal file
View file

@ -0,0 +1,52 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

View file

@ -0,0 +1,25 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

59
tests/bats/uname.bats Normal file
View file

@ -0,0 +1,59 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

35
tests/bats/uptime.bats Normal file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

23
tests/bats/users.bats Normal file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

23
tests/bats/uuidgen.bats Normal file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}

29
tests/bats/who.bats Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# 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
}