From 0ab0d619bc5f201e086bd61cca0847832812901f Mon Sep 17 00:00:00 2001 From: Bartlomiej Grzelewski Date: Thu, 23 Feb 2017 17:04:26 +0100 Subject: [PATCH] Remove duplicated code Change-Id: Id4512340f874a84181af3703866f7a16a3f06bce --- .../test_cases_app_defined_privilege.cpp | 54 ++-------------------- 1 file changed, 4 insertions(+), 50 deletions(-) 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); -- 2.7.4