Skip to content

Commit

Permalink
tests: cleanup the basic structure of integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
roddhjav committed Nov 19, 2024
1 parent 206bc34 commit 5c70c50
Show file tree
Hide file tree
Showing 45 changed files with 49 additions and 501 deletions.
8 changes: 0 additions & 8 deletions tests/bats/aa-enforce.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 10,18 @@ setup_file() {
skip
}

# bats test_tags=aa-enforce
@test "aa-enforce: Disable profile" {
sudo aa-disable pass
aa_check
}

# bats test_tags=aa-enforce
@test "aa-enforce: Enforce a profile" {
sudo aa-enforce pass
aa_check
}

# bats test_tags=aa-enforce
@test "aa-enforce: Complain a profile" {
sudo aa-complain pass
aa_check
}

# bats test_tags=aa-enforce
@test "aa-enforce: Audit a profile" {
sudo aa-audit pass
aa_check
}
14 changes: 0 additions & 14 deletions tests/bats/aa-status.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 5,22 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=aa-status
@test "aa-status: Check status" {
sudo aa-status
aa_check
}

# bats test_tags=aa-status
@test "aa-status: Display the number of loaded policies" {
sudo aa-status --profiled
aa_check
}

# bats test_tags=aa-status
@test "aa-status: Display the number of loaded enforicing policies" {
sudo aa-status --enforced
aa_check
}

# bats test_tags=aa-status
@test "aa-status: Display the number of loaded non-enforcing policies" {
sudo aa-status --complaining
aa_check
}

# bats test_tags=aa-status
@test "aa-status: Display the number of loaded enforcing policies that kill tasks" {
sudo aa-status --kill
aa_check
}
8 changes: 0 additions & 8 deletions tests/bats/blkid.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 5,10 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=blkid
@test "blkid: List all partitions" {
sudo blkid
aa_check
}

# bats test_tags=blkid
@test "blkid: List all partitions in a table, including current mountpoints" {
sudo blkid -o list
aa_check
}
9 changes: 0 additions & 9 deletions tests/bats/chsh.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 5,15 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=chsh
@test "chsh: [l]ist available shells" {
chsh --list-shells || true
aa_check
}

# bats test_tags=chsh
@test "chsh: Set a specific login [s]hell for the current user" {
echo "$PASSWORD" | chsh --shell /usr/bin/bash
aa_check
}

# bats test_tags=chsh
@test "chsh: Set a login [s]hell for a specific user" {
sudo chsh --shell /usr/bin/sh root
aa_check
}
12 changes: 11 additions & 1 deletion tests/bats/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 105,18 @@ aa_check() {
now=$(date %s)
duration=$((now - _START 1))
logs=$(aa-log --raw --systemd --since "-${duration}s")
aa_start
if [[ -n "$logs" ]]; then
fail "profile $PROGRAM raised logs: $logs"
fi
aa_start
}

# Bats setup and teardown hooks

setup_file() {
aa_setup
}

teardown() {
aa_check
}
10 changes: 0 additions & 10 deletions tests/bats/cpuid.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 5,14 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=cpuid
@test "cpuid: Display information for all CPUs" {
cpuid
aa_check
}

# bats test_tags=cpuid
@test "cpuid: Display information only for the current CPU" {
cpuid -1
aa_check
}

# bats test_tags=cpuid
@test "cpuid: Display raw hex information with no decoding" {
cpuid -r
aa_check
}
14 changes: 0 additions & 14 deletions tests/bats/df.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 5,22 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=df
@test "df: Display all filesystems and their disk usage" {
df
aa_check
}

# bats test_tags=df
@test "df: Display all filesystems and their disk usage in human-readable form" {
df -h
aa_check
}

# bats test_tags=df
@test "df: Display the filesystem and its disk usage containing the given file or directory" {
df apparmor.d/
aa_check
}

# bats test_tags=df
@test "df: Include statistics on the number of free inodes" {
df --inodes
aa_check
}

# bats test_tags=df
@test "df: Display filesystem types" {
df --print-type
aa_check
}
12 changes: 0 additions & 12 deletions tests/bats/dfc.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 5,18 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=dfc
@test "dfc: Display filesystems and their disk usage in human-readable form with colors and graphs" {
dfc
aa_check
}

# bats test_tags=dfc
@test "dfc: Display all filesystems including pseudo, duplicate and inaccessible filesystems" {
dfc -a
aa_check
}

# bats test_tags=dfc
@test "dfc: Display filesystems without color" {
dfc -c never
aa_check
}

# bats test_tags=dfc
@test "dfc: Display filesystems containing "ext" in the filesystem type" {
dfc -t ext
aa_check
}
11 changes: 0 additions & 11 deletions tests/bats/fc-cache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 5,14 @@

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
}

6 changes: 0 additions & 6 deletions tests/bats/fc-list.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 5,6 @@

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
}
18 changes: 0 additions & 18 deletions tests/bats/flatpak.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 5,30 @@

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
}
14 changes: 0 additions & 14 deletions tests/bats/gpgconf.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 5,30 @@

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 || true
gpgconf --list-options dirmngr
aa_check
}

# bats test_tags=gpgconf
@test "gpgconf: List programs and test whether they are runnable" {
gpgconf --check-programs || true
aa_check
}

# bats test_tags=gpgconf
@test "gpgconf: Reload a component" {
gpgconf --reload gpg
gpgconf --reload gpgsm
gpgconf --reload gpg-agent
gpgconf --reload scdaemon || true
gpgconf --reload dirmngr
aa_check
}
12 changes: 0 additions & 12 deletions tests/bats/groupadd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 5,20 @@

load common

setup_file() {
aa_setup
}

# bats test_tags=groupadd
@test "groupadd: Create a new group" {
sudo groupadd user2
aa_check
}

# bats test_tags=groupadd
@test "groupadd: Create a new system group" {
sudo groupadd --system system2
aa_check
}

# bats test_tags=groupadd
@test "groupadd: Create a new group with the specific groupid" {
sudo groupadd --gid 3000 user3
aa_check
}

# bats test_tags=groupadd
@test "groupdel: Delete newly created group" {
sudo groupdel user2
sudo groupdel system2
sudo groupdel user3
aa_check
}
Loading

0 comments on commit 5c70c50

Please sign in to comment.