#
-#Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+#Copyright (c) 2014-2015 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.
${PROJECT_SOURCE_DIR}/tests/security-manager-tests/common/sm_api.cpp
${PROJECT_SOURCE_DIR}/tests/security-manager-tests/common/sm_db.cpp
${PROJECT_SOURCE_DIR}/tests/security-manager-tests/common/sm_request.cpp
+ ${PROJECT_SOURCE_DIR}/tests/security-manager-tests/common/sm_user_request.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client.cpp
${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp
)
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ */
+
+#include <sm_user_request.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+UserRequest::UserRequest()
+ : m_req(nullptr)
+ , m_uid(false, 0)
+ , m_utype(false, static_cast<security_manager_user_type>(0))
+{
+ int result = security_manager_user_req_new(&m_req);
+ RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
+ "creation of new request failed. Result: " << result);
+ RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
+}
+
+UserRequest::~UserRequest()
+{
+ security_manager_user_req_free(m_req);
+}
+
+void UserRequest::setUid(const uid_t uid, lib_retcode expectedResult)
+{
+ int result = security_manager_user_req_set_uid(m_req, uid);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "setting uid returned wrong value."
+ << " Uid: " << uid << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+ m_uid.first = true;
+ m_uid.second = uid;
+}
+
+void UserRequest::setUserType(const security_manager_user_type utype, lib_retcode expectedResult)
+{
+ int result = security_manager_user_req_set_user_type(m_req, utype);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "setting user type returned wrong value."
+ << " User type: " << utype << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+ m_utype.first = true;
+ m_utype.second = utype;
+}
+
+std::ostream& operator<<(std::ostream &os, const UserRequest &request)
+{
+ if (request.m_uid.first)
+ os << "uid: " << request.m_uid.second << "; ";
+
+ if (request.m_utype.first)
+ os << "utype: " << request.m_utype.second << "; ";
+
+ return os;
+}
+
+} // namespace SecurityManagerTest
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_USERREQUEST
+#define SECURITY_MANAGER_TEST_USERREQUEST
+
+#include <iostream>
+#include <sys/types.h>
+#include <utility>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+class UserRequest
+{
+public:
+ UserRequest();
+ UserRequest(const UserRequest&) = delete;
+ UserRequest& operator=(const UserRequest&) = delete;
+ ~UserRequest();
+
+ void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+ void setUserType(const security_manager_user_type utype,
+ lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+
+ const user_req *get() const { return m_req; }
+ friend std::ostream& operator<<(std::ostream &, const UserRequest&);
+
+private:
+ user_req *m_req;
+
+ std::pair<bool, uid_t> m_uid;
+ std::pair<bool, security_manager_user_type> m_utype;
+};
+
+std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::UserRequest &request);
+
+} // namespace SecurityManagerTest
+
+#endif // SECURITY_MANAGER_TEST_USERREQUEST