RUNNER_TEST_GROUP_INIT(cynara_creds_gdbus)
-RUNNER_TEST_SMACK(tccgd01_gdbus_credentials_client_pid) {
- gdbusTestTemplate([] (GDBusConnectionPtr conn, pid_t pid, const std::string &requestedName,
- const ProcessCredentials &) {
+void testGdbusClientPid(cynara_client_creds method = CLIENT_METHOD_PID) {
+ gdbusTestTemplate([method] (GDBusConnectionPtr conn, pid_t pid,
+ const std::string &requestedName,
+ const ProcessCredentials &) {
GStringPtr clientPidStr(CynaraHelperCredentials::gdbusGetClient(std::move(conn),
- requestedName.c_str(), CLIENT_METHOD_PID));
+ requestedName.c_str(), method));
pid_t clientPid = std::stoi(clientPidStr.get());
RUNNER_ASSERT_MSG(pid == clientPid, "PIDs don't match ret = " << clientPid
<< "; expected = " << pid);
}, "tccgd01");
}
-RUNNER_TEST_SMACK(tccgd02_gdbus_credentials_client_smack) {
- gdbusTestTemplate([] (GDBusConnectionPtr conn, pid_t, const std::string &requestedName,
- const ProcessCredentials &peerCredentials) {
+void testGdbusClientSmack(cynara_client_creds method = CLIENT_METHOD_SMACK) {
+ gdbusTestTemplate([method] (GDBusConnectionPtr conn, pid_t,
+ const std::string &requestedName,
+ const ProcessCredentials &peerCredentials) {
GStringPtr label(CynaraHelperCredentials::gdbusGetClient(std::move(conn),
- requestedName.c_str(), CLIENT_METHOD_SMACK));
+ requestedName.c_str(), method));
RUNNER_ASSERT_MSG(peerCredentials.label() == label.get(),
"Labels don't match ret = " << label.get()
<< "; expected = " << peerCredentials.label());
}, "tccgd02");
}
-RUNNER_TEST_SMACK(tccgd03_gdbus_credentials_user_uid) {
- gdbusTestTemplate([] (GDBusConnectionPtr conn, pid_t, const std::string &requestedName,
- const ProcessCredentials &peerCredentials) {
+RUNNER_MULTIPROCESS_TEST(tccgd01_gdbus_credentials_client_pid)
+{
+ testGdbusClientPid();
+}
+
+RUNNER_MULTIPROCESS_TEST_SMACK(tccgd02_gdbus_credentials_client_smack)
+{
+ testGdbusClientSmack();
+}
+
+RUNNER_MULTIPROCESS_TEST_SMACK(tccgd03_gdbus_credentials_client_default)
+{
+ auto method = getClientDefaultMethod();
+ switch(method) {
+ case CLIENT_METHOD_SMACK:
+ testGdbusClientSmack(CLIENT_METHOD_DEFAULT);
+ break;
+ case CLIENT_METHOD_PID:
+ testGdbusClientPid(CLIENT_METHOD_DEFAULT);
+ break;
+ default:
+ RUNNER_FAIL_MSG("cynara_creds_get_default_client_method returned unexpected value "
+ << method);
+ }
+}
+
+void testGdbusUserUid(cynara_user_creds method = USER_METHOD_UID) {
+ gdbusTestTemplate([method] (GDBusConnectionPtr conn, pid_t,
+ const std::string &requestedName,
+ const ProcessCredentials &peerCredentials) {
GStringPtr uidStr(CynaraHelperCredentials::gdbusGetUser(std::move(conn),
- requestedName.c_str(), USER_METHOD_UID));
+ requestedName.c_str(), method));
uid_t uid = std::stoul(uidStr.get());
RUNNER_ASSERT_MSG(peerCredentials.uid() == uid, "UIDs don't match ret = " << uid
<< "; expected = "<< peerCredentials.uid());
- }, "tccgd03");
+ }, "tccgd04");
+}
+
+void testGdbusUserGid(cynara_user_creds method = USER_METHOD_GID) {
+ // Getting gid for gdbus connection is not yet implemented in cynara helpers
+ gdbusTestTemplate([method] (GDBusConnectionPtr conn, pid_t,
+ const std::string &requestedName,
+ const ProcessCredentials &) {
+ GStringPtr gidStr(CynaraHelperCredentials::gdbusGetUser(std::move(conn),
+ requestedName.c_str(), method, CYNARA_API_METHOD_NOT_SUPPORTED));
+ }, "tccgd04");
+}
+
+RUNNER_MULTIPROCESS_TEST(tccgd04_gdbus_credentials_user_uid)
+{
+ testGdbusUserUid();
}
-RUNNER_TEST_SMACK(tccgd04_gdbus_credentials_pid) {
+RUNNER_MULTIPROCESS_TEST(tccgd05_gdbus_credentials_user_gid)
+{
+ testGdbusUserGid();
+}
+
+RUNNER_MULTIPROCESS_TEST(tccgd06_gdbus_credentials_user_default) {
+ auto method = getUserDefaultMethod();
+ switch(method) {
+ case USER_METHOD_UID:
+ testGdbusUserUid(USER_METHOD_DEFAULT);
+ break;
+ case USER_METHOD_GID:
+ testGdbusUserGid(USER_METHOD_DEFAULT);
+ break;
+ default:
+ RUNNER_FAIL_MSG("cynara_creds_get_default_user_method returned unexpected value "
+ << method);
+ }
+}
+
+RUNNER_MULTIPROCESS_TEST(tccgd06_gdbus_credentials_pid) {
gdbusTestTemplate([] (GDBusConnectionPtr conn, pid_t expectedPid,
const std::string &requestedName, const ProcessCredentials &) {
auto helperPid = CynaraHelperCredentials::gdbusGetPid(std::move(conn),
requestedName.c_str());
RUNNER_ASSERT_MSG(helperPid == expectedPid, "PIDs don't match ret = " << helperPid
<< "; expected = " << expectedPid);
- }, "tccgd04");
+ }, "tccgd06");
}
RUNNER_TEST_GROUP_INIT(cynara_creds_self)