libeos-parental-controls: Add support for flatpak refs

As well as handling paths on the file system, we should allow flatpak
refs to be explicitly handled in the app filter.

Both refs and paths can be stored safely in the same app filter GStrv
because paths are always absolute and refs always start with ‘app/’ or
‘runtime/’.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://phabricator.endlessm.com/T24020
This commit is contained in:
Philip Withnall 2018-10-12 17:59:04 +13:00
parent da8884e7db
commit c19b6a777f
4 changed files with 103 additions and 16 deletions

View file

@ -102,6 +102,9 @@ test_app_filter_builder_non_empty (BuilderFixture *fixture,
epc_app_filter_builder_blacklist_path (fixture->builder, "/bin/true");
epc_app_filter_builder_blacklist_path (fixture->builder, "/usr/bin/gnome-software");
epc_app_filter_builder_blacklist_flatpak_ref (fixture->builder,
"app/org.doom.Doom/x86_64/master");
epc_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol",
EPC_APP_FILTER_OARS_VALUE_MILD);
epc_app_filter_builder_set_oars_value (fixture->builder, "language-humor",
@ -113,6 +116,11 @@ test_app_filter_builder_non_empty (BuilderFixture *fixture,
g_assert_false (epc_app_filter_is_path_allowed (filter,
"/usr/bin/gnome-software"));
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
"app/org.gnome.Ponies/x86_64/master"));
g_assert_false (epc_app_filter_is_flatpak_ref_allowed (filter,
"app/org.doom.Doom/x86_64/master"));
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
EPC_APP_FILTER_OARS_VALUE_MILD);
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==,
@ -134,6 +142,11 @@ test_app_filter_builder_empty (BuilderFixture *fixture,
g_assert_true (epc_app_filter_is_path_allowed (filter,
"/usr/bin/gnome-software"));
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
"app/org.gnome.Ponies/x86_64/master"));
g_assert_true (epc_app_filter_is_flatpak_ref_allowed (filter,
"app/org.doom.Doom/x86_64/master"));
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "drugs-alcohol"), ==,
EPC_APP_FILTER_OARS_VALUE_UNKNOWN);
g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==,