diff --git a/tests/bats/aa-enforce.bats b/tests/bats/aa-enforce.bats new file mode 100644 index 00000000..913eedce --- /dev/null +++ b/tests/bats/aa-enforce.bats @@ -0,0 +1,34 @@ +#!/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=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 +} diff --git a/tests/bats/groupadd.bats b/tests/bats/groupadd.bats new file mode 100644 index 00000000..f5557959 --- /dev/null +++ b/tests/bats/groupadd.bats @@ -0,0 +1,36 @@ +#!/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=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 +} diff --git a/tests/bats/id.bats b/tests/bats/id.bats new file mode 100644 index 00000000..5a7b58c5 --- /dev/null +++ b/tests/bats/id.bats @@ -0,0 +1,45 @@ +#!/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=id +@test "id: Display current user's ID (UID), group ID (GID) and groups to which they belong" { + id + aa_check +} + +# bats test_tags=id +@test "id: Display the current user identity" { + id -un + aa_check +} + +# bats test_tags=id +@test "id: Display the current user identity as a number" { + id -u + aa_check +} + +# bats test_tags=id +@test "id: Display the current primary group identity" { + id -gn + aa_check +} + +# bats test_tags=id +@test "id: Display the current primary group identity as a number" { + id -g + aa_check +} + +# bats test_tags=id +@test "id: Display an arbitrary user ID (UID), group ID (GID) and groups to which they belong" { + id root +} diff --git a/tests/bats/pstree.bats b/tests/bats/pstree.bats new file mode 100644 index 00000000..e3ed5fa8 --- /dev/null +++ b/tests/bats/pstree.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=pstree +@test "pstree: Display a tree of processes" { + pstree + aa_check +} + +# bats test_tags=pstree +@test "pstree: Display a tree of processes with PIDs" { + pstree -p + aa_check +} + +# bats test_tags=pstree +@test "pstree: Display all process trees rooted at processes owned by specified user" { + pstree root + aa_check +} +