#include <cynara_test_admin.h>
+#include <memory.h>
#include <tests_common.h>
#include <fstream>
+#include <string>
+#include <sstream>
namespace
{
<< " operation: " << operation << ","
<< " extra: " << formatCstr(extra));
}
+
+void CynaraTestAdmin::adminCheck(const char *startBucket, int recursive,
+ const char *client, const char *user, const char *privilege,
+ int expectedCheckResult, const char *expectedCheckResultExtra,
+ int expectedResult)
+{
+ int checkResult;
+ char *checkResultExtra = nullptr;
+
+ int ret = cynara_admin_check(m_admin,
+ startBucket, recursive,
+ client, user, privilege,
+ &checkResult, &checkResultExtra);
+ CStringPtr extra(checkResultExtra);
+
+ auto dump = [&]() -> std::string
+ {
+ std::stringstream s;
+ s << " functionReturn: " << ret << ","
+ << " functionExpectedReturn: " << expectedResult << ",";
+
+ s << " startBucket: " << formatCstr(startBucket) << ","
+ << " recursive: " << recursive << ","
+ << " client: " << formatCstr(client) << ","
+ << " user: " << formatCstr(user) << ","
+ << " privilege: " << formatCstr(privilege) << ",";
+
+ s << " checkResult: " << checkResult << ","
+ << " expectedCheckResult: " << expectedCheckResult << ","
+ << " checkResultExtra: " << formatCstr(checkResultExtra) << ","
+ << " expectedCheckResultExtra: " << formatCstr(expectedCheckResultExtra);
+ return s.str();
+ };
+
+ RUNNER_ASSERT_MSG(ret == expectedResult,
+ "cynara_admin_check returned wrong value: "
+ << ret << " != " << expectedResult << "."
+ << dump());
+
+ RUNNER_ASSERT_MSG(checkResult == expectedCheckResult,
+ "cynara_admin_check returned wrong check result: "
+ << checkResult << " != " << expectedCheckResult << "."
+ << dump());
+
+ RUNNER_ASSERT_MSG(formatCstr(checkResultExtra) == formatCstr(expectedCheckResultExtra),
+ "cynara_admin_check returned wrong check result extra: "
+ << formatCstr(checkResultExtra) << " != "
+ << formatCstr(expectedCheckResultExtra) << "."
+ << dump());
+}
+
int expectedResult = CYNARA_ADMIN_API_SUCCESS);
void setBucket(const char *bucket, int operation, const char *extra,
int expectedResult = CYNARA_ADMIN_API_SUCCESS);
+ void adminCheck(const char *startBucket, int recursive,
+ const char *client, const char *user, const char *privilege,
+ int expectedCheckResult, const char *expectedCheckResultExtra,
+ int expectedResult = CYNARA_ADMIN_API_SUCCESS);
+
private:
struct cynara_admin *m_admin;
};