aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/gpg/GpgContext.cpp10
-rw-r--r--src/gpg/GpgContext.h3
-rw-r--r--test/CMakeLists.txt9
-rw-r--r--test/GpgCoreTestBasicOpera.cpp23
-rw-r--r--test/GpgCoreTestKeyModel.cpp17
-rw-r--r--test/GpgFrontendTest.h3
8 files changed, 46 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c362d5f2..bc1ba3da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -174,6 +174,9 @@ if (APPLE)
if(XCODE_BUILD)
set(XCODE_CODE_SIGN_IDENTITY "\"${XCODE_CODE_SIGN_IDENTITY}\"")
message(STATUS "XCODE_CODE_SIGN_IDENTITY ${XCODE_CODE_SIGN_IDENTITY}")
+ if(APPLE_SANDBOX)
+ add_compile_definitions(APPLE_SANDBOX)
+ endif()
endif()
include_directories(
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f7dd86eb..fc7d8169 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -124,6 +124,9 @@ endif ()
if (APPLICATION_BUILD)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
if (APPLE)
+ if(APPLE_SANDBOX)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/gpg1.4 DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ endif()
file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
# Refresh App Bundle
file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app)
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index a8b86619..d2b500e2 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -45,7 +45,7 @@ namespace GpgFrontend {
* Set up gpgme-context, set paths to app-run path
*/
GpgContext::GpgContext(bool independent_database, std::string db_path,
- int channel)
+ bool gpg_alone, std::string gpg_path, int channel)
: SingletonFunctionObject<GpgContext>(channel) {
static bool _first = true;
@@ -64,6 +64,14 @@ GpgContext::GpgContext(bool independent_database, std::string db_path,
check_gpg_error(gpgme_new(&_p_ctx));
_ctx_ref = CtxRefHandler(_p_ctx);
+ if (gpg_alone) {
+ info.AppPath = gpg_path;
+ auto err = gpgme_ctx_set_engine_info(_ctx_ref.get(), GPGME_PROTOCOL_OpenPGP,
+ info.AppPath.c_str(),
+ info.DatabasePath.c_str());
+ assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR);
+ }
+
auto engineInfo = gpgme_ctx_get_engine_info(*this);
// Check ENV before running
diff --git a/src/gpg/GpgContext.h b/src/gpg/GpgContext.h
index 5812f49f..da19bfd9 100644
--- a/src/gpg/GpgContext.h
+++ b/src/gpg/GpgContext.h
@@ -38,7 +38,8 @@ namespace GpgFrontend {
class GpgContext : public SingletonFunctionObject<GpgContext> {
public:
explicit GpgContext(bool independent_database = false,
- std::string path = std::string(), int channel = 0);
+ std::string path = std::string(), bool gpg_alone = false,
+ std::string gpg_path = std::string(), int channel = 0);
~GpgContext() override = default;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8a5859f4..48b46832 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,14 +7,17 @@ file(COPY ${CMAKE_SOURCE_DIR}/test/data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/
aux_source_directory(. TEST_SOURCE)
add_executable(
- ${AppName}
- ${TEST_SOURCE}
+ ${AppName}
+ ${TEST_SOURCE}
)
if(GPG_CORE)
target_link_libraries(${AppName} gpg_core)
endif()
-target_link_libraries(${AppName} gtest gtest_main)
+target_link_libraries(${AppName} ${Boost_LIBRARIES} gtest gtest_main)
+if(APPLE)
+target_link_libraries(${AppName} intl)
+endif()
add_test(AllTestsInGpgFrontend ${AppName})
diff --git a/test/GpgCoreTestBasicOpera.cpp b/test/GpgCoreTestBasicOpera.cpp
index 40972982..b06068a1 100644
--- a/test/GpgCoreTestBasicOpera.cpp
+++ b/test/GpgCoreTestBasicOpera.cpp
@@ -41,8 +41,8 @@ TEST_F(GpgCoreTest, CoreEncryptDecrTest) {
ByteArray encrypt_text = "Hello GpgFrontend!";
ByteArrayPtr encr_out_data;
GpgEncrResult e_result;
- std::vector<GpgKey> keys;
- keys.push_back(std::move(encrpyt_key));
+ KeyListPtr keys = std::make_unique<KeyArgsList>();
+ keys->push_back(std::move(encrpyt_key));
auto err =
BasicOperator::GetInstance(default_channel)
.Encrypt(std::move(keys), encrypt_text, encr_out_data, e_result);
@@ -65,8 +65,8 @@ TEST_F(GpgCoreTest, CoreSignVerifyNormalTest) {
ByteArray sign_text = "Hello GpgFrontend!";
ByteArrayPtr sign_out_data;
GpgSignResult s_result;
- std::vector<GpgKey> keys;
- keys.push_back(std::move(encrpyt_key));
+ KeyListPtr keys = std::make_unique<KeyArgsList>();
+ keys->push_back(std::move(encrpyt_key));
auto err = BasicOperator::GetInstance(default_channel)
.Sign(std::move(keys), sign_text, sign_out_data,
GPGME_SIG_MODE_NORMAL, s_result);
@@ -90,8 +90,8 @@ TEST_F(GpgCoreTest, CoreSignVerifyDetachTest) {
ByteArray sign_text = "Hello GpgFrontend!";
ByteArrayPtr sign_out_data;
GpgSignResult s_result;
- std::vector<GpgKey> keys;
- keys.push_back(std::move(encrpyt_key));
+ KeyListPtr keys = std::make_unique<KeyArgsList>();
+ keys->push_back(std::move(encrpyt_key));
auto err = BasicOperator::GetInstance(default_channel)
.Sign(std::move(keys), sign_text, sign_out_data,
GPGME_SIG_MODE_DETACH, s_result);
@@ -114,8 +114,8 @@ TEST_F(GpgCoreTest, CoreSignVerifyClearTest) {
ByteArray sign_text = "Hello GpgFrontend!";
ByteArrayPtr sign_out_data;
GpgSignResult s_result;
- std::vector<GpgKey> keys;
- keys.push_back(std::move(sign_key));
+ KeyListPtr keys = std::make_unique<KeyArgsList>();
+ keys->push_back(std::move(sign_key));
auto err = BasicOperator::GetInstance(default_channel)
.Sign(std::move(keys), sign_text, sign_out_data,
GPGME_SIG_MODE_CLEAR, s_result);
@@ -147,9 +147,10 @@ TEST_F(GpgCoreTest, CoreEncryptSignDecrVerifyTest) {
GpgEncrResult e_result;
GpgSignResult s_result;
- std::vector<GpgKey> keys, sign_keys;
- keys.push_back(std::move(encrpyt_key));
- sign_keys.push_back(std::move(sign_key));
+ KeyListPtr keys = std::make_unique<KeyArgsList>(),
+ sign_keys = std::make_unique<KeyArgsList>();
+ keys->push_back(std::move(encrpyt_key));
+ sign_keys->push_back(std::move(sign_key));
auto err = BasicOperator::GetInstance(default_channel)
.EncryptSign(std::move(keys), std::move(sign_keys),
diff --git a/test/GpgCoreTestKeyModel.cpp b/test/GpgCoreTestKeyModel.cpp
index 4e85a8cf..194eeed2 100644
--- a/test/GpgCoreTestKeyModel.cpp
+++ b/test/GpgCoreTestKeyModel.cpp
@@ -75,18 +75,19 @@ TEST_F(GpgCoreTest, GpgKeyTest) {
ASSERT_EQ(key.email(), "[email protected]");
ASSERT_EQ(key.id(), "81704859182661FB");
ASSERT_EQ(key.fpr(), "9490795B78F8AFE9F93BD09281704859182661FB");
- ASSERT_EQ(key.expires(), boost::gregorian::from_simple_string("2023-09-05"));
+ ASSERT_EQ(key.expires(),
+ boost::posix_time::from_iso_string("20230905T040000"));
ASSERT_EQ(key.pubkey_algo(), "RSA");
ASSERT_EQ(key.length(), 3072);
ASSERT_EQ(key.last_update(),
- boost::gregorian::from_simple_string("1970-01-01"));
+ boost::posix_time::from_iso_string("19700101T000000"));
ASSERT_EQ(key.create_time(),
- boost::gregorian::from_simple_string("2021-09-05"));
+ boost::posix_time::from_iso_string("20210905T060153"));
ASSERT_EQ(key.owner_trust(), "Unknown");
using namespace boost::posix_time;
- ASSERT_EQ(key.expired(), key.expires() < second_clock::local_time().date());
+ ASSERT_EQ(key.expired(), key.expires() < second_clock::local_time());
}
TEST_F(GpgCoreTest, GpgSubKeyTest) {
@@ -100,7 +101,7 @@ TEST_F(GpgCoreTest, GpgSubKeyTest) {
ASSERT_FALSE(sub_key.revoked());
ASSERT_FALSE(sub_key.disabled());
ASSERT_EQ(sub_key.timestamp(),
- boost::gregorian::from_simple_string("2021-09-05"));
+ boost::posix_time::from_iso_string("20210905T060153"));
ASSERT_FALSE(sub_key.is_cardkey());
ASSERT_TRUE(sub_key.is_private_key());
@@ -112,11 +113,11 @@ TEST_F(GpgCoreTest, GpgSubKeyTest) {
ASSERT_FALSE(sub_key.can_authenticate());
ASSERT_FALSE(sub_key.can_sign());
ASSERT_TRUE(sub_key.can_encrypt());
- ASSERT_EQ(key.expires(), boost::gregorian::from_simple_string("2023-09-05"));
+ ASSERT_EQ(key.expires(),
+ boost::posix_time::from_iso_string("20230905T040000"));
using namespace boost::posix_time;
- ASSERT_EQ(sub_key.expired(),
- sub_key.expires() < second_clock::local_time().date());
+ ASSERT_EQ(sub_key.expired(), sub_key.expires() < second_clock::local_time());
}
TEST_F(GpgCoreTest, GpgUIDTest) {
diff --git a/test/GpgFrontendTest.h b/test/GpgFrontendTest.h
index 181c513e..ee872fc6 100644
--- a/test/GpgFrontendTest.h
+++ b/test/GpgFrontendTest.h
@@ -29,10 +29,11 @@
#include <gpg-error.h>
#include <gtest/gtest.h>
-#include <boost/date_time/gregorian/parsers.hpp>
+#include <boost/date_time.hpp>
#include <boost/dll.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
+#include <libconfig.h++>
#include <memory>
#include <string>
#include <vector>