-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: tests fixes for sru validation #15093
Changes from all commits
d9c9940
3ea339d
ce93ec0
7cc28a4
52b459d
39a3d52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -41,30 +41,41 @@ environment: | |||||
SNAPD_NO_MEMORY_LIMIT: 1 | ||||||
|
||||||
prepare: | | ||||||
tests.session prepare -u test | ||||||
if not tests.info is-reexec-in-use && os.query is-ubuntu 22.04; then | ||||||
tests.exec skip-test "Ubuntu 22.04 AppArmor parser doesn't support prompting" && exit 0 | ||||||
fi | ||||||
|
||||||
tests.session prepare -u test | ||||||
tests.session -u test exec sh -c 'mkdir -p "/home/test/integration-tests"' | ||||||
snap install prompting-client | ||||||
|
||||||
restore: | | ||||||
tests.exec is-skipped && exit 0 | ||||||
|
||||||
snap set system experimental.apparmor-prompting=false | ||||||
tests.session -u test exec sh -c 'rm -rf "/home/test/integration-tests"' | ||||||
tests.session restore -u test | ||||||
|
||||||
debug: | | ||||||
tests.exec is-skipped && exit 0 | ||||||
|
||||||
TEST_UID="$(id -u test)" | ||||||
echo "outstanding prompts:" | ||||||
snap debug api "/v2/interfaces/requests/prompts?user-id=$TEST_UID" || true | ||||||
echo "rules:" | ||||||
snap debug api "/v2/interfaces/requests/rules?user-id=$TEST_UID" || true | ||||||
|
||||||
execute: | | ||||||
# Just to make sure the previous check didn't exit | ||||||
tests.exec is-skipped && exit 0 | ||||||
|
||||||
echo "Precondition check that snapd is active" | ||||||
systemctl is-active snapd.service snapd.socket | ||||||
|
||||||
echo "Enable prompting via snap client where possible" | ||||||
# Prompting is unsupported everywhere but the Ubuntu non-core systems with | ||||||
# kernels which support apparmor prompting | ||||||
if ! os.query is-ubuntu || os.query is-core || [ ! -f /sys/kernel/security/apparmor/features/policy/permstable32 ] || NOMATCH 'prompt' < /sys/kernel/security/apparmor/features/policy/permstable32 ; then | ||||||
if ! os.query is-ubuntu || os.query is-core || ! grep 'prompt' /sys/kernel/security/apparmor/features/policy/permstable32; then | ||||||
not snap set system experimental.apparmor-prompting=true >& err.out | ||||||
if os.query is-core ; then | ||||||
MATCH "cannot enable prompting feature as it is not supported on Ubuntu Core systems" < err.out | ||||||
|
@@ -74,7 +85,7 @@ execute: | | |||||
|
||||||
exit 0 | ||||||
fi | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
SNAPD_PID="$(systemctl show --property MainPID snapd.service | cut -f2 -d=)" | ||||||
|
||||||
echo "Enable AppArmor prompting experimental feature" | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,10 +18,16 @@ environment: | |||||||||
PYTHONIOENCODING: utf-8 | ||||||||||
|
||||||||||
prepare: | | ||||||||||
if not tests.info is-reexec-in-use && os.query is-ubuntu 22.04; then | ||||||||||
tests.exec skip-test "Ubuntu 22.04 kernel doesn't support prompting" && exit 0 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
But I would rather do this on line 67 instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only other remaining blocker: #15093 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
fi | ||||||||||
|
||||||||||
# prerequisite for having a prompts handler service | ||||||||||
snap set system experimental.user-daemons=true | ||||||||||
|
||||||||||
debug: | | ||||||||||
tests.exec is-skipped && exit 0 | ||||||||||
|
||||||||||
echo "Check kernel version" | ||||||||||
uname -a | ||||||||||
echo "Check kernel notification socket presence" | ||||||||||
|
@@ -34,6 +40,8 @@ debug: | | |||||||||
snap debug api /v2/system-info | ||||||||||
|
||||||||||
execute: | | ||||||||||
tests.exec is-skipped && exit 0 | ||||||||||
|
||||||||||
"$TESTSTOOLS"/snaps-state install-local api-client | ||||||||||
echo "The snap-interfaces-requests-control plug on the api-client snap is initially disconnected" | ||||||||||
snap connections api-client | MATCH "snap-interfaces-requests-control +api-client:snap-interfaces-requests-control +- +-" | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,9 +108,13 @@ prepare: | | |
# Later on, restart snapd and ensure that nfs/cifs workaround is gone. | ||
# This cleanup handler is registered before we mount the cifs file system. | ||
if [ "$(snap debug confinement)" = strict ]; then | ||
# We are testing on Ubuntu where we know that reexec is active and we | ||
# use an internal apparmor userspace stack. | ||
tests.cleanup defer test ! -e /var/lib/snapd/apparmor/snap-confine.internal/nfs-support | ||
if tests.info is-reexec-in-use; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks! |
||
# We are testing on Ubuntu where we know that reexec is active and we | ||
# use an internal apparmor userspace stack. | ||
tests.cleanup defer test ! -e /var/lib/snapd/apparmor/snap-confine.internal/nfs-support | ||
else | ||
tests.cleanup defer test ! -e /var/lib/snapd/apparmor/snap-confine/nfs-support | ||
fi | ||
fi | ||
tests.cleanup defer systemctl restart snapd.service | ||
tests.cleanup defer systemctl reset-failed snapd.service snapd.socket | ||
|
@@ -140,7 +144,11 @@ prepare: | | |
systemctl reset-failed snapd.service snapd.socket | ||
systemctl restart snapd.service | ||
if [ "$(snap debug confinement)" = strict ]; then | ||
MATCH 'network inet,' < /var/lib/snapd/apparmor/snap-confine.internal/nfs-support | ||
if tests.info is-reexec-in-use; then | ||
MATCH 'network inet,' < /var/lib/snapd/apparmor/snap-confine.internal/nfs-support | ||
else | ||
MATCH 'network inet,' < /var/lib/snapd/apparmor/snap-confine/nfs-support | ||
fi | ||
MATCH 'network inet,' < /var/lib/snapd/apparmor/profiles/snap.test-snapd-sh.with-home-plug | ||
fi | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below,
becomes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, all the checks to validate that apparmor prompting works in the supported systems and it doesn't in the unsupported will me moved to a new test with just one variant to avoid rechecks.
I'll push a following pr once this is merged.