From: Bartlomiej Grzelewski Date: Thu, 23 Feb 2017 16:04:26 +0000 (+0100) Subject: Remove duplicated code X-Git-Tag: security-manager_5.5_testing~15^2~7^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F21%2F116321%2F1;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Remove duplicated code Change-Id: Id4512340f874a84181af3703866f7a16a3f06bce --- diff --git a/src/security-manager-tests/test_cases_app_defined_privilege.cpp b/src/security-manager-tests/test_cases_app_defined_privilege.cpp index c17e6e6..4af31a4 100644 --- a/src/security-manager-tests/test_cases_app_defined_privilege.cpp +++ b/src/security-manager-tests/test_cases_app_defined_privilege.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -30,55 +30,9 @@ #include #include -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);