Remove duplicated code 21/116321/1
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 23 Feb 2017 16:04:26 +0000 (17:04 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 23 Feb 2017 16:17:26 +0000 (17:17 +0100)
Change-Id: Id4512340f874a84181af3703866f7a16a3f06bce

src/security-manager-tests/test_cases_app_defined_privilege.cpp

index c17e6e6..4af31a4 100644 (file)
@@ -20,7 +20,7 @@
 #include <sys/un.h>
 #include <unistd.h>
 
-#include <cynara-client.h>
+#include <cynara_test_client.h>
 #include <dpl/test/test_runner.h>
 #include <sm_api.h>
 #include <sm_commons.h>
 #include <app_install_helper.h>
 #include <scoped_installer.h>
 
-namespace CynaraClient {
-class Client
-{
-public:
-    Client();
-    virtual ~Client();
-
-    void check(const std::string &client, const std::string &session,
-               const std::string &user, const std::string &privilege,
-               int expectedResult = CYNARA_API_ACCESS_ALLOWED);
-
-private:
-    struct cynara *m_cynara;
-};
-
-Client::Client()
-    : m_cynara(nullptr)
-{
-    int ret = cynara_initialize(&m_cynara, nullptr);
-    RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
-                         "cynara_initialize failed. ret: " << ret);
-    RUNNER_ASSERT_MSG(m_cynara != nullptr, "cynara struct was not initialized");
-}
-
-Client::~Client()
-{
-    cynara_finish(m_cynara);
-}
-
-void Client::check(const std::string &client, const std::string &session,
-                   const std::string &user, const std::string &privilege,
-                   int expectedResult)
-{
-    int ret = cynara_check(m_cynara, client.c_str(), session.c_str(), user.c_str(), privilege.c_str());
-    RUNNER_ASSERT_MSG(ret == expectedResult,
-                         "cynara_check returned wrong value: "
-                             << ret << " != " << expectedResult << "."
-                             << " client: " << formatCstr(client.c_str()) << ","
-                             << " session: " << formatCstr(session.c_str()) << ","
-                             << " user: " << formatCstr(user.c_str()) << ","
-                             << " privilege: " << formatCstr(privilege.c_str()));
-}
-
-} //namespace CynaraClient
-
 RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_APP_DEFINED_PRIVILEGE)
 
 using namespace SecurityManagerTest;
-using namespace CynaraClient;
 
 RUNNER_CHILD_TEST(app_defined_01_global_install_untrusted)
 {
@@ -100,7 +54,7 @@ RUNNER_CHILD_TEST(app_defined_01_global_install_untrusted)
     ScopedInstaller req1(provider);
     ScopedInstaller req2(consumer);
 
-    Client cynara;
+    CynaraTestClient::Client cynara;
     cynara.check(consumerLabel, session, ownerId, privilege, CYNARA_API_ACCESS_ALLOWED);
 
     // uninstall provider
@@ -129,7 +83,7 @@ RUNNER_CHILD_TEST(app_defined_02_global_install_licensed)
     ScopedInstaller req1(provider);
     ScopedInstaller req2(consumer);
 
-    Client cynara;
+    CynaraTestClient::Client cynara;
     cynara.check(consumerLabel, session, ownerId, privilege, CYNARA_API_ACCESS_ALLOWED);
 
     // uninstall provider
@@ -167,7 +121,7 @@ RUNNER_CHILD_TEST(app_defined_03_database_update)
     ScopedInstaller req2(providerB);
     ScopedInstaller req3(consumer);
 
-    Client cynara;
+    CynaraTestClient::Client cynara;
     cynara.check(consumerLabel, session, ownerId, privilegeA, CYNARA_API_ACCESS_ALLOWED);
     cynara.check(consumerLabel, session, ownerId, privilegeB, CYNARA_API_ACCESS_ALLOWED);