+++ /dev/null
-SET(TESTS_PATH ${PROJECT_SOURCE_DIR}/test/)
-
-FIND_PACKAGE(Threads REQUIRED) # Required by gmock
-
-PKG_CHECK_MODULES(TESTS_DEP
- QUIET gmock
- cynara-agent
-)
-
-INCLUDE_DIRECTORIES(
- ${ASKUSER_PATH}/common
- ${gmock_INCLUDE_DIRS}
-)
-
-SET(TESTS_SOURCES
- ${TESTS_PATH}/main.cpp
- ${TESTS_PATH}/common/exception.cpp
- )
-
-ADD_DEFINITIONS(${TESTS_DEP_CFLAGS})
-
-ADD_EXECUTABLE(${TARGET_TESTS} ${TESTS_SOURCES})
-
-SET_TARGET_PROPERTIES(${TARGET_TESTS} PROPERTIES
- COMPILE_FLAGS
- -fpie
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_TESTS}
- ${TESTS_DEP_LIBRARIES}
- ${TARGET_ASKUSER_COMMON}
- ${gmock_LDFLAGS}
- ${gmock_LIBRARIES}
- -pie
-)
-
-INSTALL(TARGETS ${TARGET_TESTS} DESTINATION ${BIN_INSTALL_DIR})
-
-ADD_SUBDIRECTORY(tools)
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file exception.cpp
- * @author Oskar Świtalski <o.switalski@samsung.com>
- * @brief Tests for exceptions classes
- */
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <exception/Exception.h>
-#include <exception/CynaraException.h>
-
-using namespace AskUser;
-
-/**
- * @brief Exception should publicly inherit from std::exception
- *
- * Exception class must publicly inherit from another class, if child class is ought to be catched
- * by parent class catch block.
- *
- * @test Scenario:
- * - throw Exception
- * - check if std::exception could be catched
- */
-TEST(Exception, inherit_publicly_from_std_exception) {
- EXPECT_THROW(throw Exception(""), std::exception);
-}
-
-/**
- * @brief CynaraException should publicly inherit from std::exception
- *
- * Exception class must publicly inherit from another class, if child class is ought to be catched
- * by parent class catch block.
- *
- * @test Scenario:
- * - throw CynaraException
- * - check if std::exception could be catched
- */
-TEST(CynaraException, inherit_publicly_from_std_exception) {
- EXPECT_THROW(throw CynaraException("", 0), std::exception);
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file tests/main.cpp
- * @author Oskar Świtalski <o.switalski@samsung.com>
- * @version 1.0
- * @brief Unit-tests setup
- */
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-int main(int argc, char** argv) {
- // Disables elapsed time by default.
- ::testing::GTEST_FLAG(print_time) = false;
-
- // This allows the user to override the flag on the command line.
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
+++ /dev/null
-SET(TEST_PATH ${PROJECT_SOURCE_DIR}/test/tools/)
-
-PKG_CHECK_MODULES(TEST_DEP
- cynara-client
- cynara-admin
-)
-
-INCLUDE_DIRECTORIES(
- ${ASKUSER_PATH}/common
-)
-
-SET(TEST_SOURCES
- ${TEST_PATH}/main.cpp
- )
-
-ADD_DEFINITIONS(${TEST_DEP_CFLAGS})
-
-ADD_EXECUTABLE(${TARGET_TEST} ${TEST_SOURCES})
-
-SET_TARGET_PROPERTIES(${TARGET_TEST} PROPERTIES
- COMPILE_FLAGS
- -fpie
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_TEST}
- ${TEST_DEP_LIBRARIES}
- -pie
-)
-
-INSTALL(TARGETS ${TARGET_TEST} DESTINATION ${BIN_INSTALL_DIR})
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-/**
- * @file main.cpp
- * @author Oskar Świtalski <o.switalski@samsung.com>
- * @brief Main test file
- */
-
-#include <iostream>
-#include <string>
-
-#include <cynara-admin.h>
-#include <cynara-client.h>
-#include <cynara-error.h>
-
-#include <exception/CynaraException.h>
-#include <types/SupportedTypes.h>
-
-#include <unistd.h>
-
-cynara *cyn;
-cynara_admin *admin;
-
-void check_cynara_return(std::string func, int ret) {
- if (ret < 0) {
- throw AskUser::CynaraException(func, ret);
- }
-}
-
-int main(int argc, char **argv)
-{
- int ret;
-
- // below app has this privilege for any user in MANIFEST bucket and it is a privacy privilege
-// std::string client = "User::Pkg::org.tizen.task-mgr";
-// std::string user = "5001";
-// std::string privilege = "http://tizen.org/privilege/appmanager.kill";
- std::string client;
- std::string user;
- std::string privilege;
- std::string bucket = "";
-
- if (argc < 2) {
- client = "User::Pkg::org.tizen.task-mgr";
- user = "5001";
- privilege = "http://tizen.org/privilege/appmanager.kill";
- } else {
- client = argv[1];
- user = argv[2];
- privilege = argv[3];
- }
-
- try {
-
- ret = cynara_admin_initialize(&admin);
- check_cynara_return("cynara_admin_initialize", ret);
-
- cynara_admin_policy **policies = new cynara_admin_policy*[2];
- cynara_admin_policy policy = {&bucket[0], &client[0], &user[0], &privilege[0],
- AskUser::SupportedTypes::Service::ASK_USER , nullptr};
-
- policies[0] = &policy;
- policies[1] = nullptr;
-
- ret = cynara_admin_set_policies(admin, policies);
- check_cynara_return("cynara_admin_set_policies", ret);
-
- ret = cynara_admin_finish(admin);
- check_cynara_return("cynara_admin_finish", ret);
-
- ret = cynara_initialize(&cyn, nullptr);
- check_cynara_return("cynara_initialize", ret);
-
- for (int i = 0; i < 10; ++i) {
-
- ret = cynara_check(cyn, client.c_str(), "session", user.c_str(), privilege.c_str());
- check_cynara_return("cynara_check", ret);
-
- switch (ret) {
- case CYNARA_API_ACCESS_ALLOWED:
- std::cout << "Allowed" << std::endl;
- break;
- case CYNARA_API_ACCESS_DENIED:
- std::cout << "Denied" << std::endl;
- break;
- }
-
- }
-
- ret = cynara_finish(cyn);
- check_cynara_return("cynara_finish", ret);
-
- } catch (std::exception &e) {
- std::cerr << e.what() << std::endl;
- } catch (...) {
- std::cerr << "Unknown error" << std::endl;
- }
-
- return 0;
-}