#include "dbus-hash.h"
#include "dbus-credentials.h"
#include "dbus-internals.h"
-#include "dbus-authorization.h"
/**
* @defgroup DBusAuthScript code for running unit test scripts for DBusAuth
dbus_bool_t retval;
int line_no;
DBusAuth *auth;
- DBusAuthorization *authorization;
DBusString from_auth;
DBusAuthState state;
DBusString context;
retval = FALSE;
auth = NULL;
- authorization = NULL;
_dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00");
_dbus_string_init_const (&context, "org_freedesktop_test");
goto out;
}
+ /* test ref/unref */
+ _dbus_auth_ref (auth);
+ _dbus_auth_unref (auth);
+
creds = _dbus_credentials_new_from_current_process ();
if (creds == NULL)
{
_dbus_warn ("no memory for credentials\n");
+ _dbus_auth_unref (auth);
+ auth = NULL;
goto out;
}
if (!_dbus_auth_set_credentials (auth, creds))
{
_dbus_warn ("no memory for setting credentials\n");
+ _dbus_auth_unref (auth);
+ auth = NULL;
_dbus_credentials_unref (creds);
goto out;
}
_dbus_credentials_unref (creds);
}
- else if (_dbus_string_starts_with_c_str (&line, "SERVER") ||
- _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS"))
+ else if (_dbus_string_starts_with_c_str (&line,
+ "SERVER"))
{
DBusCredentials *creds;
goto out;
}
- /* empty authorization, it will use default rules */
- authorization = _dbus_authorization_new ();
- if (authorization == NULL)
- {
- _dbus_warn ("no memory to create DBusAuthorization\n");
- goto out;
- }
- /* if we are testing an anonymous server, we need to enable
- * anonymous authorization, or the mech will REJECT */
- if (_dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS"))
- _dbus_authorization_set_allow_anonymous (authorization, TRUE);
-
- auth = _dbus_auth_server_new (&guid, authorization);
+ auth = _dbus_auth_server_new (&guid);
if (auth == NULL)
{
_dbus_warn ("no memory to create DBusAuth\n");
goto out;
}
+ /* test ref/unref */
+ _dbus_auth_ref (auth);
+ _dbus_auth_unref (auth);
+
creds = _dbus_credentials_new_from_current_process ();
if (creds == NULL)
{
_dbus_warn ("no memory for credentials\n");
+ _dbus_auth_unref (auth);
+ auth = NULL;
goto out;
}
if (!_dbus_auth_set_credentials (auth, creds))
{
_dbus_warn ("no memory for setting credentials\n");
+ _dbus_auth_unref (auth);
+ auth = NULL;
_dbus_credentials_unref (creds);
goto out;
}
out:
if (auth)
- _dbus_auth_free (auth);
- if (authorization)
- _dbus_authorization_free (authorization);
+ _dbus_auth_unref (auth);
_dbus_string_free (&file);
_dbus_string_free (&line);