#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)
{
ScopedInstaller req1(provider);
ScopedInstaller req2(consumer);
- Client cynara;
+ CynaraTestClient::Client cynara;
cynara.check(consumerLabel, session, ownerId, privilege, CYNARA_API_ACCESS_ALLOWED);
// uninstall provider
ScopedInstaller req1(provider);
ScopedInstaller req2(consumer);
- Client cynara;
+ CynaraTestClient::Client cynara;
cynara.check(consumerLabel, session, ownerId, privilege, CYNARA_API_ACCESS_ALLOWED);
// uninstall provider
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);