Add wrap for cynara_admin_list_erase in Admin class 48/33048/2
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 2 Jan 2015 13:02:16 +0000 (14:02 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 2 Jan 2015 14:40:01 +0000 (15:40 +0100)
Add method erasePolicies executing cynara_admin_erase
and checking if received result match expected.

Change-Id: I21f9dfa542fe931e56b4e09ec00712ab539d48ef

tests/cynara-tests/common/cynara_test_admin.cpp
tests/cynara-tests/common/cynara_test_admin.h

index 40f00095289c5be57b3691b564e3dacc5f32a4fb..f49e887b2c9790c6f1febadf145f152a10834462 100644 (file)
@@ -313,4 +313,33 @@ void Admin::listPolicies(const char *startBucket,
                          << dump());
 }
 
+void Admin::erasePolicies(const char *startBucket, int recursive,
+                          const char *client, const char *user, const char *privilege,
+                          int expectedResult)
+{
+    int ret = cynara_admin_erase(m_admin,
+                                 startBucket, recursive,
+                                 client, user, privilege);
+
+    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);
+
+        return s.str();
+    };
+
+    RUNNER_ASSERT_MSG(ret == expectedResult,
+                         "cynara_admin_erase returned wrong value: "
+                             << ret << " != " << expectedResult << "."
+                             << dump());
+}
+
 } // namespace CynaraTestAdmin
index 26d910c4131f783ad3fc9ca84f48016adf66204e..1b64bf0fe799d0a55c170c69e2c0d440feb4b9fa 100644 (file)
@@ -82,6 +82,9 @@ public:
                       const char *client, const char *user, const char *privilege,
                       CynaraPoliciesContainer &expectedPolicyList,
                       int expectedResult = CYNARA_API_SUCCESS);
+    void erasePolicies(const char *startBucket, int recursive,
+                       const char *client, const char *user, const char *privilege,
+                       int expectedResult = CYNARA_API_SUCCESS);
 
 private:
     struct cynara_admin *m_admin;