Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[unit] Added test for OemRaw access control. JB#49309
  • Loading branch information
monich committed May 15, 2020
1 parent 1053577 commit 9b2b712
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ofono/unit/test-dbus-access.c
Expand Up @@ -34,6 +34,12 @@ static enum ofono_dbus_access deny_method_access(const char *sender,
return OFONO_DBUS_ACCESS_DENY;
}

static enum ofono_dbus_access broken_method_access(const char *sender,
enum ofono_dbus_access_intf intf, int method, const char *arg)
{
return (enum ofono_dbus_access)(-1);
}

struct ofono_dbus_access_plugin access_inval;
struct ofono_dbus_access_plugin access_dontcare = {
.name = "DontCare",
Expand All @@ -51,6 +57,12 @@ struct ofono_dbus_access_plugin access_deny = {
.method_access = deny_method_access
};

struct ofono_dbus_access_plugin access_broken = {
.name = "Broken",
.priority = OFONO_DBUS_ACCESS_PRIORITY_LOW,
.method_access = broken_method_access
};

/*==========================================================================*
* Tests
*==========================================================================*/
Expand Down Expand Up @@ -107,6 +119,9 @@ static const struct test_method_name_data method_name_tests[] = {
},{
OFONO_DBUS_ACCESS_INTF_STK,
OFONO_DBUS_ACCESS_STK_METHOD_COUNT
},{
OFONO_DBUS_ACCESS_INTF_OEMRAW,
OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT
}
};

Expand Down Expand Up @@ -156,6 +171,13 @@ static void test_register()
ofono_dbus_access_plugin_unregister(&access_deny);
ofono_dbus_access_plugin_unregister(&access_dontcare);

/* And here too */
g_assert(!ofono_dbus_access_plugin_register(&access_broken));
g_assert(!ofono_dbus_access_plugin_register(&access_deny));
g_assert(!__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
ofono_dbus_access_plugin_unregister(&access_deny);
ofono_dbus_access_plugin_unregister(&access_dontcare);

/* DontCare will allow everything */
g_assert(!ofono_dbus_access_plugin_register(&access_dontcare));
g_assert(__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
Expand Down

0 comments on commit 9b2b712

Please sign in to comment.