tree-wide: Replace usages of whitelist/blacklist
Replace usages of the terms whitelist and blacklist with the more inclusive and more precise terms allowlist and blocklist, which are actually also more consistent with parts of the codebase, e.g. mct_app_filter_is_content_type_allowed(). The only API break here is in libmalcontent/app-filter.h but the relevant API is not used anywhere else in Endless OS beyond this repo, nor to my knowledge in any other distribution. Also, per the README, this project's API is not stable, so now is a good time to make this change.
This commit is contained in:
parent
c6fd3c0ad3
commit
15e8a74b21
9 changed files with 135 additions and 135 deletions
|
@ -31,9 +31,9 @@ G_BEGIN_DECLS
|
|||
|
||||
/**
|
||||
* MctAppFilterListType:
|
||||
* @MCT_APP_FILTER_LIST_BLACKLIST: Any program in the list is not allowed to
|
||||
* @MCT_APP_FILTER_LIST_BLOCKLIST: Any program in the list is not allowed to
|
||||
* be run.
|
||||
* @MCT_APP_FILTER_LIST_WHITELIST: Any program not in the list is not allowed
|
||||
* @MCT_APP_FILTER_LIST_ALLOWLIST: Any program not in the list is not allowed
|
||||
* to be run.
|
||||
*
|
||||
* Different semantics for interpreting an application list.
|
||||
|
@ -42,8 +42,8 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
MCT_APP_FILTER_LIST_BLACKLIST,
|
||||
MCT_APP_FILTER_LIST_WHITELIST,
|
||||
MCT_APP_FILTER_LIST_BLOCKLIST,
|
||||
MCT_APP_FILTER_LIST_ALLOWLIST,
|
||||
} MctAppFilterListType;
|
||||
|
||||
struct _MctAppFilter
|
||||
|
|
|
@ -164,9 +164,9 @@ mct_app_filter_is_enabled (MctAppFilter *filter)
|
|||
/* Check all fields against their default values. Ignore
|
||||
* `allow_system_installation` since it’s false by default, so the default
|
||||
* value is already the most restrictive. */
|
||||
return ((filter->app_list_type == MCT_APP_FILTER_LIST_BLACKLIST &&
|
||||
return ((filter->app_list_type == MCT_APP_FILTER_LIST_BLOCKLIST &&
|
||||
filter->app_list[0] != NULL) ||
|
||||
filter->app_list_type == MCT_APP_FILTER_LIST_WHITELIST ||
|
||||
filter->app_list_type == MCT_APP_FILTER_LIST_ALLOWLIST ||
|
||||
!oars_ratings_all_intense_or_unknown ||
|
||||
!filter->allow_user_installation);
|
||||
}
|
||||
|
@ -202,9 +202,9 @@ mct_app_filter_is_path_allowed (MctAppFilter *filter,
|
|||
|
||||
switch (filter->app_list_type)
|
||||
{
|
||||
case MCT_APP_FILTER_LIST_BLACKLIST:
|
||||
case MCT_APP_FILTER_LIST_BLOCKLIST:
|
||||
return !path_in_list;
|
||||
case MCT_APP_FILTER_LIST_WHITELIST:
|
||||
case MCT_APP_FILTER_LIST_ALLOWLIST:
|
||||
return path_in_list;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -265,9 +265,9 @@ mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
|
|||
|
||||
switch (filter->app_list_type)
|
||||
{
|
||||
case MCT_APP_FILTER_LIST_BLACKLIST:
|
||||
case MCT_APP_FILTER_LIST_BLOCKLIST:
|
||||
return !ref_in_list;
|
||||
case MCT_APP_FILTER_LIST_WHITELIST:
|
||||
case MCT_APP_FILTER_LIST_ALLOWLIST:
|
||||
return ref_in_list;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -281,7 +281,7 @@ mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
|
|||
*
|
||||
* Check whether the flatpak app with the given @app_id is allowed to be run
|
||||
* according to this app filter. This is a globbing match, matching @app_id
|
||||
* against potentially multiple entries in the blacklist, as the blacklist
|
||||
* against potentially multiple entries in the blocklist, as the blocklist
|
||||
* contains flatpak refs (for example, `app/org.gnome.Builder/x86_64/master`)
|
||||
* which contain architecture and branch information. App IDs (for example,
|
||||
* `org.gnome.Builder`) do not contain architecture or branch information.
|
||||
|
@ -315,9 +315,9 @@ mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter,
|
|||
|
||||
switch (filter->app_list_type)
|
||||
{
|
||||
case MCT_APP_FILTER_LIST_BLACKLIST:
|
||||
case MCT_APP_FILTER_LIST_BLOCKLIST:
|
||||
return !id_in_list;
|
||||
case MCT_APP_FILTER_LIST_WHITELIST:
|
||||
case MCT_APP_FILTER_LIST_ALLOWLIST:
|
||||
return id_in_list;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -431,8 +431,8 @@ is_valid_content_type (const gchar *content_type)
|
|||
* according to this app filter.
|
||||
*
|
||||
* Note that this method doesn’t match content subtypes. For example, if
|
||||
* `application/xml` is added to the blacklist but `application/xspf+xml` is not,
|
||||
* a check for whether `application/xspf+xml` is blacklisted would return false.
|
||||
* `application/xml` is added to the blocklist but `application/xspf+xml` is not,
|
||||
* a check for whether `application/xspf+xml` is blocklisted would return false.
|
||||
*
|
||||
* Returns: %TRUE if the user this @filter corresponds to is allowed to run
|
||||
* programs handling @content_type according to the @filter policy;
|
||||
|
@ -453,9 +453,9 @@ mct_app_filter_is_content_type_allowed (MctAppFilter *filter,
|
|||
|
||||
switch (filter->app_list_type)
|
||||
{
|
||||
case MCT_APP_FILTER_LIST_BLACKLIST:
|
||||
case MCT_APP_FILTER_LIST_BLOCKLIST:
|
||||
return !ref_in_list;
|
||||
case MCT_APP_FILTER_LIST_WHITELIST:
|
||||
case MCT_APP_FILTER_LIST_ALLOWLIST:
|
||||
return ref_in_list;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -606,7 +606,7 @@ _mct_app_filter_build_app_filter_variant (MctAppFilter *filter)
|
|||
g_return_val_if_fail (filter->ref_count >= 1, NULL);
|
||||
|
||||
g_variant_builder_add (&builder, "b",
|
||||
(filter->app_list_type == MCT_APP_FILTER_LIST_WHITELIST));
|
||||
(filter->app_list_type == MCT_APP_FILTER_LIST_ALLOWLIST));
|
||||
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
|
||||
|
||||
for (gsize i = 0; filter->app_list[i] != NULL; i++)
|
||||
|
@ -675,7 +675,7 @@ mct_app_filter_deserialize (GVariant *variant,
|
|||
uid_t user_id,
|
||||
GError **error)
|
||||
{
|
||||
gboolean is_whitelist;
|
||||
gboolean is_allowlist;
|
||||
g_auto(GStrv) app_list = NULL;
|
||||
const gchar *content_rating_kind;
|
||||
g_autoptr(GVariant) oars_variant = NULL;
|
||||
|
@ -700,10 +700,10 @@ mct_app_filter_deserialize (GVariant *variant,
|
|||
* kept in sync with those in the `com.endlessm.ParentalControls.AppFilter`
|
||||
* D-Bus interface. */
|
||||
if (!g_variant_lookup (variant, "AppFilter", "(b^as)",
|
||||
&is_whitelist, &app_list))
|
||||
&is_allowlist, &app_list))
|
||||
{
|
||||
/* Default value. */
|
||||
is_whitelist = FALSE;
|
||||
is_allowlist = FALSE;
|
||||
app_list = g_new0 (gchar *, 1);
|
||||
}
|
||||
|
||||
|
@ -747,7 +747,7 @@ mct_app_filter_deserialize (GVariant *variant,
|
|||
app_filter->user_id = user_id;
|
||||
app_filter->app_list = g_steal_pointer (&app_list);
|
||||
app_filter->app_list_type =
|
||||
is_whitelist ? MCT_APP_FILTER_LIST_WHITELIST : MCT_APP_FILTER_LIST_BLACKLIST;
|
||||
is_allowlist ? MCT_APP_FILTER_LIST_ALLOWLIST : MCT_APP_FILTER_LIST_BLOCKLIST;
|
||||
app_filter->oars_ratings = g_steal_pointer (&oars_variant);
|
||||
app_filter->allow_user_installation = allow_user_installation;
|
||||
app_filter->allow_system_installation = allow_system_installation;
|
||||
|
@ -762,7 +762,7 @@ mct_app_filter_deserialize (GVariant *variant,
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
GPtrArray *blacklist; /* (nullable) (owned) (element-type utf8) */
|
||||
GPtrArray *blocklist; /* (nullable) (owned) (element-type utf8) */
|
||||
GHashTable *oars; /* (nullable) (owned) (element-type utf8 MctAppFilterOarsValue) */
|
||||
gboolean allow_user_installation;
|
||||
gboolean allow_system_installation;
|
||||
|
@ -800,7 +800,7 @@ mct_app_filter_builder_init (MctAppFilterBuilder *builder)
|
|||
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
|
||||
|
||||
g_return_if_fail (_builder != NULL);
|
||||
g_return_if_fail (_builder->blacklist == NULL);
|
||||
g_return_if_fail (_builder->blocklist == NULL);
|
||||
g_return_if_fail (_builder->oars == NULL);
|
||||
|
||||
memcpy (builder, &local_builder, sizeof (local_builder));
|
||||
|
@ -826,7 +826,7 @@ mct_app_filter_builder_clear (MctAppFilterBuilder *builder)
|
|||
|
||||
g_return_if_fail (_builder != NULL);
|
||||
|
||||
g_clear_pointer (&_builder->blacklist, g_ptr_array_unref);
|
||||
g_clear_pointer (&_builder->blocklist, g_ptr_array_unref);
|
||||
g_clear_pointer (&_builder->oars, g_hash_table_unref);
|
||||
}
|
||||
|
||||
|
@ -876,8 +876,8 @@ mct_app_filter_builder_copy (MctAppFilterBuilder *builder)
|
|||
_copy = (MctAppFilterBuilderReal *) copy;
|
||||
|
||||
mct_app_filter_builder_clear (copy);
|
||||
if (_builder->blacklist != NULL)
|
||||
_copy->blacklist = g_ptr_array_ref (_builder->blacklist);
|
||||
if (_builder->blocklist != NULL)
|
||||
_copy->blocklist = g_ptr_array_ref (_builder->blocklist);
|
||||
if (_builder->oars != NULL)
|
||||
_copy->oars = g_hash_table_ref (_builder->oars);
|
||||
_copy->allow_user_installation = _builder->allow_user_installation;
|
||||
|
@ -927,11 +927,11 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
|
|||
g_autoptr(GVariant) oars_variant = NULL;
|
||||
|
||||
g_return_val_if_fail (_builder != NULL, NULL);
|
||||
g_return_val_if_fail (_builder->blacklist != NULL, NULL);
|
||||
g_return_val_if_fail (_builder->blocklist != NULL, NULL);
|
||||
g_return_val_if_fail (_builder->oars != NULL, NULL);
|
||||
|
||||
/* Ensure the paths list is %NULL-terminated. */
|
||||
g_ptr_array_add (_builder->blacklist, NULL);
|
||||
g_ptr_array_add (_builder->blocklist, NULL);
|
||||
|
||||
/* Build the OARS variant. */
|
||||
g_hash_table_iter_init (&iter, _builder->oars);
|
||||
|
@ -962,8 +962,8 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
|
|||
app_filter = g_new0 (MctAppFilter, 1);
|
||||
app_filter->ref_count = 1;
|
||||
app_filter->user_id = -1;
|
||||
app_filter->app_list = (gchar **) g_ptr_array_free (g_steal_pointer (&_builder->blacklist), FALSE);
|
||||
app_filter->app_list_type = MCT_APP_FILTER_LIST_BLACKLIST;
|
||||
app_filter->app_list = (gchar **) g_ptr_array_free (g_steal_pointer (&_builder->blocklist), FALSE);
|
||||
app_filter->app_list_type = MCT_APP_FILTER_LIST_BLOCKLIST;
|
||||
app_filter->oars_ratings = g_steal_pointer (&oars_variant);
|
||||
app_filter->allow_user_installation = _builder->allow_user_installation;
|
||||
app_filter->allow_system_installation = _builder->allow_system_installation;
|
||||
|
@ -974,24 +974,24 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
|
|||
}
|
||||
|
||||
/**
|
||||
* mct_app_filter_builder_blacklist_path:
|
||||
* mct_app_filter_builder_blocklist_path:
|
||||
* @builder: an initialised #MctAppFilterBuilder
|
||||
* @path: (type filename): an absolute path to blacklist
|
||||
* @path: (type filename): an absolute path to blocklist
|
||||
*
|
||||
* Add @path to the blacklist of app paths in the filter under construction. It
|
||||
* Add @path to the blocklist of app paths in the filter under construction. It
|
||||
* will be canonicalised (without doing any I/O) before being added.
|
||||
* The canonicalised @path will not be added again if it’s already been added.
|
||||
*
|
||||
* Since: 0.2.0
|
||||
*/
|
||||
void
|
||||
mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
|
||||
mct_app_filter_builder_blocklist_path (MctAppFilterBuilder *builder,
|
||||
const gchar *path)
|
||||
{
|
||||
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
|
||||
|
||||
g_return_if_fail (_builder != NULL);
|
||||
g_return_if_fail (_builder->blacklist != NULL);
|
||||
g_return_if_fail (_builder->blocklist != NULL);
|
||||
g_return_if_fail (path != NULL);
|
||||
g_return_if_fail (g_path_is_absolute (path));
|
||||
|
||||
|
@ -1000,67 +1000,67 @@ mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
|
|||
NULL, NULL, NULL);
|
||||
g_return_if_fail (canonical_path_utf8 != NULL);
|
||||
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
|
||||
canonical_path_utf8, g_str_equal, NULL))
|
||||
g_ptr_array_add (_builder->blacklist, g_steal_pointer (&canonical_path_utf8));
|
||||
g_ptr_array_add (_builder->blocklist, g_steal_pointer (&canonical_path_utf8));
|
||||
}
|
||||
|
||||
/**
|
||||
* mct_app_filter_builder_blacklist_flatpak_ref:
|
||||
* mct_app_filter_builder_blocklist_flatpak_ref:
|
||||
* @builder: an initialised #MctAppFilterBuilder
|
||||
* @app_ref: a flatpak app ref to blacklist
|
||||
* @app_ref: a flatpak app ref to blocklist
|
||||
*
|
||||
* Add @app_ref to the blacklist of flatpak refs in the filter under
|
||||
* Add @app_ref to the blocklist of flatpak refs in the filter under
|
||||
* construction. The @app_ref will not be added again if it’s already been
|
||||
* added.
|
||||
*
|
||||
* Since: 0.2.0
|
||||
*/
|
||||
void
|
||||
mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
|
||||
mct_app_filter_builder_blocklist_flatpak_ref (MctAppFilterBuilder *builder,
|
||||
const gchar *app_ref)
|
||||
{
|
||||
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
|
||||
|
||||
g_return_if_fail (_builder != NULL);
|
||||
g_return_if_fail (_builder->blacklist != NULL);
|
||||
g_return_if_fail (_builder->blocklist != NULL);
|
||||
g_return_if_fail (app_ref != NULL);
|
||||
g_return_if_fail (is_valid_flatpak_ref (app_ref));
|
||||
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
|
||||
app_ref, g_str_equal, NULL))
|
||||
g_ptr_array_add (_builder->blacklist, g_strdup (app_ref));
|
||||
g_ptr_array_add (_builder->blocklist, g_strdup (app_ref));
|
||||
}
|
||||
|
||||
/**
|
||||
* mct_app_filter_builder_blacklist_content_type:
|
||||
* mct_app_filter_builder_blocklist_content_type:
|
||||
* @builder: an initialised #MctAppFilterBuilder
|
||||
* @content_type: a content type to blacklist
|
||||
* @content_type: a content type to blocklist
|
||||
*
|
||||
* Add @content_type to the blacklist of content types in the filter under
|
||||
* Add @content_type to the blocklist of content types in the filter under
|
||||
* construction. The @content_type will not be added again if it’s already been
|
||||
* added.
|
||||
*
|
||||
* Note that this method doesn’t handle content subtypes. For example, if
|
||||
* `application/xml` is added to the blacklist but `application/xspf+xml` is not,
|
||||
* a check for whether `application/xspf+xml` is blacklisted would return false.
|
||||
* `application/xml` is added to the blocklist but `application/xspf+xml` is not,
|
||||
* a check for whether `application/xspf+xml` is blocklisted would return false.
|
||||
*
|
||||
* Since: 0.4.0
|
||||
*/
|
||||
void
|
||||
mct_app_filter_builder_blacklist_content_type (MctAppFilterBuilder *builder,
|
||||
mct_app_filter_builder_blocklist_content_type (MctAppFilterBuilder *builder,
|
||||
const gchar *content_type)
|
||||
{
|
||||
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
|
||||
|
||||
g_return_if_fail (_builder != NULL);
|
||||
g_return_if_fail (_builder->blacklist != NULL);
|
||||
g_return_if_fail (_builder->blocklist != NULL);
|
||||
g_return_if_fail (content_type != NULL);
|
||||
g_return_if_fail (is_valid_content_type (content_type));
|
||||
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
|
||||
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
|
||||
content_type, g_str_equal, NULL))
|
||||
g_ptr_array_add (_builder->blacklist, g_strdup (content_type));
|
||||
g_ptr_array_add (_builder->blocklist, g_strdup (content_type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -165,11 +165,11 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilterBuilder, mct_app_filter_builder_free)
|
|||
|
||||
MctAppFilter *mct_app_filter_builder_end (MctAppFilterBuilder *builder);
|
||||
|
||||
void mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
|
||||
void mct_app_filter_builder_blocklist_path (MctAppFilterBuilder *builder,
|
||||
const gchar *path);
|
||||
void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
|
||||
void mct_app_filter_builder_blocklist_flatpak_ref (MctAppFilterBuilder *builder,
|
||||
const gchar *app_ref);
|
||||
void mct_app_filter_builder_blacklist_content_type (MctAppFilterBuilder *builder,
|
||||
void mct_app_filter_builder_blocklist_content_type (MctAppFilterBuilder *builder,
|
||||
const gchar *content_type);
|
||||
|
||||
void mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder,
|
||||
|
|
|
@ -275,13 +275,13 @@ test_app_filter_builder_non_empty (BuilderFixture *fixture,
|
|||
g_autoptr(MctAppFilter) filter = NULL;
|
||||
g_autofree const gchar **sections = NULL;
|
||||
|
||||
mct_app_filter_builder_blacklist_path (fixture->builder, "/bin/true");
|
||||
mct_app_filter_builder_blacklist_path (fixture->builder, "/usr/bin/gnome-software");
|
||||
mct_app_filter_builder_blocklist_path (fixture->builder, "/bin/true");
|
||||
mct_app_filter_builder_blocklist_path (fixture->builder, "/usr/bin/gnome-software");
|
||||
|
||||
mct_app_filter_builder_blacklist_flatpak_ref (fixture->builder,
|
||||
mct_app_filter_builder_blocklist_flatpak_ref (fixture->builder,
|
||||
"app/org.doom.Doom/x86_64/master");
|
||||
|
||||
mct_app_filter_builder_blacklist_content_type (fixture->builder,
|
||||
mct_app_filter_builder_blocklist_content_type (fixture->builder,
|
||||
"x-scheme-handler/http");
|
||||
|
||||
mct_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol",
|
||||
|
@ -380,8 +380,8 @@ test_app_filter_builder_copy_empty (void)
|
|||
builder_copy = mct_app_filter_builder_copy (builder);
|
||||
|
||||
mct_app_filter_builder_init (builder_copy);
|
||||
mct_app_filter_builder_blacklist_path (builder_copy, "/bin/true");
|
||||
mct_app_filter_builder_blacklist_content_type (builder_copy,
|
||||
mct_app_filter_builder_blocklist_path (builder_copy, "/bin/true");
|
||||
mct_app_filter_builder_blocklist_content_type (builder_copy,
|
||||
"x-scheme-handler/http");
|
||||
filter = mct_app_filter_builder_end (builder_copy);
|
||||
|
||||
|
@ -405,8 +405,8 @@ test_app_filter_builder_copy_full (void)
|
|||
g_autoptr(MctAppFilterBuilder) builder_copy = NULL;
|
||||
g_autoptr(MctAppFilter) filter = NULL;
|
||||
|
||||
mct_app_filter_builder_blacklist_path (builder, "/bin/true");
|
||||
mct_app_filter_builder_blacklist_content_type (builder,
|
||||
mct_app_filter_builder_blocklist_path (builder, "/bin/true");
|
||||
mct_app_filter_builder_blocklist_content_type (builder,
|
||||
"x-scheme-handler/http");
|
||||
mct_app_filter_builder_set_allow_user_installation (builder, FALSE);
|
||||
mct_app_filter_builder_set_allow_system_installation (builder, TRUE);
|
||||
|
@ -545,9 +545,9 @@ test_app_filter_appinfo (void)
|
|||
"MimeType=x-scheme-handler/http\n" },
|
||||
};
|
||||
|
||||
mct_app_filter_builder_blacklist_path (&builder, "/bin/false");
|
||||
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||
mct_app_filter_builder_blacklist_content_type (&builder, "x-scheme-handler/http");
|
||||
mct_app_filter_builder_blocklist_path (&builder, "/bin/false");
|
||||
mct_app_filter_builder_blocklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||
mct_app_filter_builder_blocklist_content_type (&builder, "x-scheme-handler/http");
|
||||
|
||||
filter = mct_app_filter_builder_end (&builder);
|
||||
|
||||
|
@ -751,13 +751,13 @@ test_app_filter_bus_get (BusFixture *fixture,
|
|||
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Chess"));
|
||||
}
|
||||
|
||||
/* Test that getting an #MctAppFilter containing a whitelist from the mock D-Bus
|
||||
* service works, and that the #MctAppFilter methods handle the whitelist
|
||||
/* Test that getting an #MctAppFilter containing a allowlist from the mock D-Bus
|
||||
* service works, and that the #MctAppFilter methods handle the allowlist
|
||||
* correctly.
|
||||
*
|
||||
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
|
||||
static void
|
||||
test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
||||
test_app_filter_bus_get_allowlist (BusFixture *fixture,
|
||||
gconstpointer test_data)
|
||||
{
|
||||
g_autoptr(MctAppFilter) app_filter = NULL;
|
||||
|
@ -769,8 +769,8 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
|||
"'AllowUserInstallation': <true>,"
|
||||
"'AllowSystemInstallation': <true>,"
|
||||
"'AppFilter': <(true, ["
|
||||
"'app/org.gnome.Whitelisted1/x86_64/stable',"
|
||||
"'app/org.gnome.Whitelisted2/x86_64/stable',"
|
||||
"'app/org.gnome.Allowlisted1/x86_64/stable',"
|
||||
"'app/org.gnome.Allowlisted2/x86_64/stable',"
|
||||
"'/usr/bin/true',"
|
||||
"'text/plain'"
|
||||
"])>,"
|
||||
|
@ -789,15 +789,15 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
|||
g_assert_no_error (local_error);
|
||||
g_assert_nonnull (app_filter);
|
||||
|
||||
/* Check the app filter properties. The returned filter is a whitelist,
|
||||
* whereas typically a blacklist is returned. */
|
||||
/* Check the app filter properties. The returned filter is a allowlist,
|
||||
* whereas typically a blocklist is returned. */
|
||||
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
|
||||
g_assert_true (mct_app_filter_is_enabled (app_filter));
|
||||
g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted1"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted2"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/stable"));
|
||||
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/unknown"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Allowlisted1"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Allowlisted2"));
|
||||
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Allowlisted1/x86_64/stable"));
|
||||
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Allowlisted1/x86_64/unknown"));
|
||||
g_assert_true (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/true"));
|
||||
g_assert_false (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/false"));
|
||||
g_assert_true (mct_app_filter_is_content_type_allowed (app_filter,
|
||||
|
@ -1300,10 +1300,10 @@ test_app_filter_bus_set (BusFixture *fixture,
|
|||
};
|
||||
|
||||
/* Build an app filter. */
|
||||
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/false");
|
||||
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned");
|
||||
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||
mct_app_filter_builder_blacklist_content_type (&builder, "x-scheme-handler/http");
|
||||
mct_app_filter_builder_blocklist_path (&builder, "/usr/bin/false");
|
||||
mct_app_filter_builder_blocklist_path (&builder, "/usr/bin/banned");
|
||||
mct_app_filter_builder_blocklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
|
||||
mct_app_filter_builder_blocklist_content_type (&builder, "x-scheme-handler/http");
|
||||
mct_app_filter_builder_set_oars_value (&builder, "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE);
|
||||
mct_app_filter_builder_set_allow_user_installation (&builder, TRUE);
|
||||
mct_app_filter_builder_set_allow_system_installation (&builder, TRUE);
|
||||
|
@ -1552,8 +1552,8 @@ main (int argc,
|
|||
bus_set_up, test_app_filter_bus_get, bus_tear_down);
|
||||
g_test_add ("/app-filter/bus/get/sync", BusFixture, GUINT_TO_POINTER (FALSE),
|
||||
bus_set_up, test_app_filter_bus_get, bus_tear_down);
|
||||
g_test_add ("/app-filter/bus/get/whitelist", BusFixture, NULL,
|
||||
bus_set_up, test_app_filter_bus_get_whitelist, bus_tear_down);
|
||||
g_test_add ("/app-filter/bus/get/allowlist", BusFixture, NULL,
|
||||
bus_set_up, test_app_filter_bus_get_allowlist, bus_tear_down);
|
||||
g_test_add ("/app-filter/bus/get/all-oars-values", BusFixture, NULL,
|
||||
bus_set_up, test_app_filter_bus_get_all_oars_values, bus_tear_down);
|
||||
g_test_add ("/app-filter/bus/get/defaults", BusFixture, NULL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue