|
| 1 | +import os |
| 2 | + |
1 | 3 | import pytest |
2 | 4 |
|
3 | 5 |
|
4 | | -@pytest.mark.lg_feature("apk") |
5 | | -def test_apk_procd_installed(ssh_command): |
6 | | - assert "procd" in "\n".join(ssh_command.run_check("apk list")) |
| 6 | +@pytest.mark.skipif( |
| 7 | + os.getenv("LG_FEATURE_APK") is None, reason="LG_FEATURE_APK not defined" |
| 8 | +) |
| 9 | +class TestApk: |
| 10 | + def test_apk_procd_installed(self, ssh_command): |
| 11 | + assert "procd" in "\n".join(ssh_command.run_check("apk list")) |
| 12 | + |
| 13 | + @pytest.mark.skipif( |
| 14 | + os.getenv("LG_TEST_ONLINE") is None, reason="LG_TEST_ONLINE not defined" |
| 15 | + ) |
| 16 | + def test_apk_add_ucert(self, ssh_command): |
| 17 | + try: |
| 18 | + ssh_command.run_check("apk add ucert") |
| 19 | + assert "ucert" in "\n".join(ssh_command.run_check("apk list | grep ucert")) |
| 20 | + finally: |
| 21 | + ssh_command.run("apk del ucert") |
7 | 22 |
|
| 23 | + def test_apk_audit(self, ssh_command, check): |
| 24 | + changes = ssh_command.run_check("apk audit") |
| 25 | + expected_changes = [ |
| 26 | + "A etc/urandom.seed", |
| 27 | + "A etc/board.json", |
| 28 | + "A etc/apk/arch", |
| 29 | + "A etc/apk/repositories.d/customfeeds.list", |
| 30 | + "A etc/apk/repositories.d/distfeeds.list", |
| 31 | + "A etc/apk/world", |
| 32 | + "U etc/config/dhcp", |
| 33 | + "A etc/config/network", |
| 34 | + "A etc/config/system", |
| 35 | + "A etc/dropbear/dropbear_rsa_host_key", |
| 36 | + "A etc/dropbear/dropbear_ed25519_host_key", |
| 37 | + "U etc/group", |
| 38 | + "U etc/passwd", |
| 39 | + "A etc/rc.d/K10gpio_switch", |
| 40 | + "A etc/rc.d/K50dropbear", |
| 41 | + "A etc/rc.d/K85odhcpd", |
| 42 | + "A etc/rc.d/K89log", |
| 43 | + "A etc/rc.d/K90boot", |
| 44 | + "A etc/rc.d/K90network", |
| 45 | + "A etc/rc.d/K90sysfixtime", |
| 46 | + "A etc/rc.d/K90umount", |
| 47 | + "A etc/rc.d/S00sysfixtime", |
| 48 | + "A etc/rc.d/S00urngd", |
| 49 | + "A etc/rc.d/S10boot", |
| 50 | + "A etc/rc.d/S10system", |
| 51 | + "A etc/rc.d/S11sysctl", |
| 52 | + "A etc/rc.d/S12log", |
| 53 | + "A etc/rc.d/S19dnsmasq", |
| 54 | + "A etc/rc.d/S19dropbear", |
| 55 | + "A etc/rc.d/S19firewall", |
| 56 | + "A etc/rc.d/S20network", |
| 57 | + "A etc/rc.d/S25packet_steering", |
| 58 | + "A etc/rc.d/S35odhcpd", |
| 59 | + "A etc/rc.d/S50cron", |
| 60 | + "A etc/rc.d/S94gpio_switch", |
| 61 | + "A etc/rc.d/S95done", |
| 62 | + "A etc/rc.d/S96led", |
| 63 | + "A etc/rc.d/S98sysntpd", |
| 64 | + "A etc/rc.d/S99urandom_seed", |
| 65 | + "U etc/shadow", |
| 66 | + ] |
8 | 67 |
|
9 | | -@pytest.mark.lg_feature(["online", "apk"]) |
10 | | -def test_apk_add_ucert(ssh_command): |
11 | | - try: |
12 | | - ssh_command.run_check("apk add ucert") |
13 | | - assert "ucert" in "\n".join(ssh_command.run_check("apk list | grep ucert")) |
14 | | - finally: |
15 | | - ssh_command.run("apk del ucert") |
| 68 | + for expected in expected_changes: |
| 69 | + with check: |
| 70 | + assert expected in changes, ( |
| 71 | + f"Expected change '{expected}' not found in audit output" |
| 72 | + ) |
0 commit comments