You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/05/04 17:40:55 UTC
[geode-native] branch develop updated: GEODE-9214: Remove ACE time
library references (#797)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new baaca3d GEODE-9214: Remove ACE time library references (#797)
baaca3d is described below
commit baaca3d8a84961ec6a39bde02d7e6e4ecee8ec3b
Author: Mario Salazar de Torres <ma...@est.tech>
AuthorDate: Tue May 4 19:40:45 2021 +0200
GEODE-9214: Remove ACE time library references (#797)
* GEODE-9214: Remove ACE time library references
- Replaced all references to ACE time library by boost/STL functions.
- Also replaced old ITs logging function implementation so it doesn't
use ACE.
- Changed test/cpp logging to Boost.Log
- Created modules to avoid including Boost.Log in headers from
test/security.
- Added security to old ITs to solve undefined symbols from
test/security.
- Added C4596 warning supression for test/security that solves a
inclusion issue related to Boost.Log in Windows platform.
---
cppcache/integration-test/CMakeLists.txt | 1 +
cppcache/integration-test/fw_dunit.cpp | 79 +++++++----
.../testThinClientPRSingleHopServerGroup.cpp | 7 -
tests/cpp/fwklib/CMakeLists.txt | 2 +-
tests/cpp/fwklib/FwkException.hpp | 8 ++
tests/cpp/fwklib/FwkLog.cpp | 87 ------------
tests/cpp/fwklib/FwkLog.hpp | 106 ---------------
tests/cpp/security/CMakeLists.txt | 8 ++
tests/cpp/security/CredentialGenerator.cpp | 79 +++++++++++
tests/cpp/security/CredentialGenerator.hpp | 80 +----------
tests/cpp/security/DummyCredentialGenerator.cpp | 89 ++++++++++++
tests/cpp/security/DummyCredentialGenerator.hpp | 37 +----
tests/cpp/security/DummyCredentialGenerator2.cpp | 64 +++++++++
tests/cpp/security/DummyCredentialGenerator2.hpp | 17 +--
tests/cpp/security/DummyCredentialGenerator3.cpp | 63 +++++++++
tests/cpp/security/DummyCredentialGenerator3.hpp | 16 +--
tests/cpp/security/LdapUserCredentialGenerator.cpp | 63 +++++++++
tests/cpp/security/LdapUserCredentialGenerator.hpp | 17 +--
tests/cpp/security/PkcsCredentialGenerator.cpp | 84 ++++++++++++
tests/cpp/security/PkcsCredentialGenerator.hpp | 39 +-----
tests/cpp/security/XmlAuthzCredentialGenerator.cpp | 151 +++++++++++++++++++++
tests/cpp/security/XmlAuthzCredentialGenerator.hpp | 110 +--------------
tests/cpp/testobject/ArrayOfByte.hpp | 25 ++--
tests/cpp/testobject/BatchObject.cpp | 6 +-
tests/cpp/testobject/BatchObject.hpp | 10 +-
tests/cpp/testobject/DeltaFastAssetAccount.cpp | 8 +-
tests/cpp/testobject/DeltaFastAssetAccount.hpp | 17 +--
tests/cpp/testobject/DeltaPSTObject.cpp | 6 +-
tests/cpp/testobject/DeltaPSTObject.hpp | 10 +-
tests/cpp/testobject/DeltaTestImpl.hpp | 1 -
tests/cpp/testobject/EqStruct.cpp | 7 +-
tests/cpp/testobject/EqStruct.hpp | 10 +-
tests/cpp/testobject/FastAsset.hpp | 4 -
tests/cpp/testobject/FastAssetAccount.cpp | 7 +-
tests/cpp/testobject/FastAssetAccount.hpp | 18 +--
tests/cpp/testobject/PSTObject.cpp | 6 +-
tests/cpp/testobject/PSTObject.hpp | 10 +-
37 files changed, 717 insertions(+), 635 deletions(-)
diff --git a/cppcache/integration-test/CMakeLists.txt b/cppcache/integration-test/CMakeLists.txt
index 66c8887..d987045 100644
--- a/cppcache/integration-test/CMakeLists.txt
+++ b/cppcache/integration-test/CMakeLists.txt
@@ -117,6 +117,7 @@ foreach(FILE ${SOURCES})
apache-geode
testobject
framework
+ security
)
target_include_directories(${TEST}
diff --git a/cppcache/integration-test/fw_dunit.cpp b/cppcache/integration-test/fw_dunit.cpp
index 17beb1e..fcf2b2a 100644
--- a/cppcache/integration-test/fw_dunit.cpp
+++ b/cppcache/integration-test/fw_dunit.cpp
@@ -22,6 +22,7 @@
#include <string>
#include <iostream>
+#include <iomanip>
#include <list>
#include <map>
@@ -66,15 +67,6 @@ void setupCRTOutput() {
#endif
#endif
}
-
-void getTimeStr(char *bufPtr, size_t sizeOfBuf) {
- ACE_TCHAR timestamp[64] = {0}; // only 35 needed here
- ACE::timestamp(timestamp, sizeof timestamp);
- // timestamp is like "Tue May 17 2005 12:54:22.546780"
- // for our purpose we just want "12:54:22.546780"
- strncpy(bufPtr, ×tamp[0], sizeOfBuf);
-}
-
// some common values..
#define WORKER_STATE_READY 1
#define WORKER_STATE_DONE 2
@@ -688,36 +680,63 @@ void sleep(int millis) {
}
void logCoordinator(std::string s, int lineno, const char * /*filename*/) {
- char buf[128] = {0};
- dunit::getTimeStr(buf, sizeof(buf));
-
- fprintf(stdout, "[TEST coordinator:pid(%d)] %s at line: %d\n",
- boost::this_process::get_id(), s.c_str(), lineno);
- fflush(stdout);
+ using std::chrono::duration_cast;
+ using std::chrono::microseconds;
+ using std::chrono::system_clock;
+
+ auto now = system_clock::now();
+ auto in_time_t = system_clock::to_time_t(now);
+ auto localtime = std::localtime(&in_time_t);
+ auto usec =
+ duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+ std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+ << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+ << " coordinator:pid(" << boost::this_process::get_id() << ")] "
+ << s << " at line: " << lineno << std::endl
+ << std::flush;
}
// log a message and print the worker id as well.. used by fw_helper with no
// worker id.
void log(std::string s, int lineno, const char * /*filename*/, int /*id*/) {
- char buf[128] = {0};
- dunit::getTimeStr(buf, sizeof(buf));
-
- fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n",
- boost::this_process::get_id(), s.c_str(), lineno);
- fflush(stdout);
+ using std::chrono::duration_cast;
+ using std::chrono::microseconds;
+ using std::chrono::system_clock;
+
+ auto now = system_clock::now();
+ auto in_time_t = system_clock::to_time_t(now);
+ auto localtime = std::localtime(&in_time_t);
+ auto usec =
+ duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+ std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+ << std::setfill('0') << std::setw(6) << usec << std::setw(0)
+ << " 0:pid(" << boost::this_process::get_id() << ")] " << s
+ << " at line: " << lineno << std::endl
+ << std::flush;
}
// log a message and print the worker id as well..
void log(std::string s, int lineno, const char * /*filename*/) {
- char buf[128] = {0};
- dunit::getTimeStr(buf, sizeof(buf));
-
- fprintf(stdout, "[TEST %s %s:pid(%d)] %s at line: %d\n", buf,
- (dunit::TestWorker::procWorkerId
- ? dunit::TestWorker::procWorkerId->getIdName()
- : "coordinator"),
- boost::this_process::get_id(), s.c_str(), lineno);
- fflush(stdout);
+ using std::chrono::duration_cast;
+ using std::chrono::microseconds;
+ using std::chrono::system_clock;
+
+ auto now = system_clock::now();
+ auto in_time_t = system_clock::to_time_t(now);
+ auto localtime = std::localtime(&in_time_t);
+ auto usec =
+ duration_cast<microseconds>(now.time_since_epoch()).count() % 1000;
+
+ std::cout << "[TEST " << std::put_time(localtime, "%Y/%m/%d %H:%M:%S") << '.'
+ << std::setfill('0') << std::setw(6) << usec << std::setw(0) << ' '
+ << (dunit::TestWorker::procWorkerId
+ ? dunit::TestWorker::procWorkerId->getIdName()
+ : "coordinator")
+ << ":pid(" << boost::this_process::get_id() << ")] " << s
+ << " at line: " << lineno << std::endl
+ << std::flush;
}
void cleanup() { gClientCleanup.callClientCleanup(); }
diff --git a/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp b/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
index 08518c5..cf7be02 100644
--- a/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
+++ b/cppcache/integration-test/testThinClientPRSingleHopServerGroup.cpp
@@ -20,22 +20,15 @@
#include <string>
-#include <ace/OS.h>
-#include <ace/High_Res_Timer.h>
-#include <ace/ACE.h>
-
#include <statistics/StatisticsFactory.hpp>
#include "fw_dunit.hpp"
-#include "BuiltinCacheableWrappers.hpp"
#include "Utils.hpp"
#include "CacheHelper.hpp"
// Include these 2 headers for access to CacheImpl for test hooks.
-#include "CacheImplHelper.hpp"
#include "testUtils.hpp"
-
#include "ThinClientHelper.hpp"
#define CLIENT1 s1p1
diff --git a/tests/cpp/fwklib/CMakeLists.txt b/tests/cpp/fwklib/CMakeLists.txt
index 6a671b2..49acf69 100644
--- a/tests/cpp/fwklib/CMakeLists.txt
+++ b/tests/cpp/fwklib/CMakeLists.txt
@@ -16,7 +16,6 @@
project(framework LANGUAGES CXX)
add_library(framework STATIC
- FwkLog.cpp
GsRandom.cpp
)
@@ -44,6 +43,7 @@ target_link_libraries(framework
apache-geode
PRIVATE
ACE::ACE
+ Boost::boost
internal
_WarningsAsError
)
diff --git a/tests/cpp/fwklib/FwkException.hpp b/tests/cpp/fwklib/FwkException.hpp
index 8b378dc..36f6571 100644
--- a/tests/cpp/fwklib/FwkException.hpp
+++ b/tests/cpp/fwklib/FwkException.hpp
@@ -34,6 +34,14 @@
// ----------------------------------------------------------------------------
+#define FWKEXCEPTION(x) \
+ do { \
+ std::ostringstream os; \
+ os << x << " In file: " << __FILE__ << " at line: " << __LINE__; \
+ throw apache::geode::client::testframework::FwkException( \
+ os.str().c_str()); \
+ } while (0)
+
namespace apache {
namespace geode {
namespace client {
diff --git a/tests/cpp/fwklib/FwkLog.cpp b/tests/cpp/fwklib/FwkLog.cpp
deleted file mode 100644
index bd90a24..0000000
--- a/tests/cpp/fwklib/FwkLog.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 <cinttypes>
-#include <fwklib/FwkLog.hpp>
-
-#include <geode/Exception.hpp>
-
-#include "hacks/AceThreadId.h"
-
-namespace apache {
-namespace geode {
-namespace client {
-namespace testframework {
-
-static ACE_utsname u;
-
-const char* getNodeName() { return u.nodename; }
-
-const char* dirAndFile(const char* str) {
- if (!str) {
- return "NULL";
- }
-
- const char* ptr = str + strlen(str);
- int32_t found = 0;
- while (ptr > str) {
- ptr--;
- if ((*ptr == '/') || (*ptr == '\\')) {
- found++;
- if (found >= 2) {
- if (ptr == str) {
- return str;
- }
- return ++ptr;
- }
- }
- }
- return ptr;
-}
-
-void plog(const char* l, const char* s, const char* filename, int32_t lineno) {
- // ACE_TCHAR tstamp[64];
- // ACE::timestamp( tstamp, 64, 1 );
- // tstamp is like "Tue May 17 2005 12:54:22.546780"
- // for our purpose we just want "12:54:22.546780"
- char buf[256] = {0};
- const size_t MINBUFSIZE = 128;
- ACE_Time_Value clock = ACE_OS::gettimeofday();
- time_t secs = clock.sec();
- struct tm* tm_val = ACE_OS::localtime(&secs);
- char* pbuf = buf;
- pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
- pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
- static_cast<int64_t>(clock.usec()));
- ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
- static bool needInit = true;
- if (needInit) {
- ACE_OS::uname(&u);
- needInit = false;
- }
-
- const char* fil = dirAndFile(filename);
-
- fprintf(stdout, "[%s %s %s:P%d:T%" PRIu64 "]::%s::%d %s %s\n", buf,
- u.sysname, u.nodename, ACE_OS::getpid(),
- hacks::aceThreadId(ACE_OS::thr_self()), fil, lineno, l, s);
- fflush(stdout);
-}
-} // namespace testframework
-} // namespace client
-} // namespace geode
-} // namespace apache
diff --git a/tests/cpp/fwklib/FwkLog.hpp b/tests/cpp/fwklib/FwkLog.hpp
deleted file mode 100644
index d6bd605..0000000
--- a/tests/cpp/fwklib/FwkLog.hpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#pragma once
-
-#ifndef GEODE_FWKLIB_FWKLOG_H_
-#define GEODE_FWKLIB_FWKLOG_H_
-
-// ----------------------------------------------------------------------------
-
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Task.h>
-
-#include <geode/internal/geode_base.hpp>
-
-#include "FwkException.hpp"
-
-// kludge to compile on bar
-#define _CPP_CMATH 1
-#include <sstream>
-
-// ----------------------------------------------------------------------------
-
-namespace apache {
-namespace geode {
-namespace client {
-namespace testframework {
-
-const char* strnrchr(const char* str, const char tok, int32_t cnt);
-const char* dirAndFile(const char* str);
-void plog(const char* l, const char* s, const char* filename, int32_t lineno);
-const char* getNodeName();
-
-/* Macro for logging */
-#ifdef DEBUG
-
-#define FWKDEBUG(x) \
- do { \
- std::ostringstream os; \
- os << x; \
- plog("Debug", os.str().c_str(), __FILE__, __LINE__); \
- } while (0)
-
-#else
-
-#define FWKDEBUG(x)
-
-#endif
-
-#define FWKINFO(x) \
- do { \
- std::ostringstream os; \
- os << x; \
- apache::geode::client::testframework::plog("Info", os.str().c_str(), \
- __FILE__, __LINE__); \
- } while (0)
-#define FWKWARN(x) \
- do { \
- std::ostringstream os; \
- os << x; \
- apache::geode::client::testframework::plog("Warn", os.str().c_str(), \
- __FILE__, __LINE__); \
- } while (0)
-#define FWKERROR(x) \
- do { \
- std::ostringstream os; \
- os << x; \
- apache::geode::client::testframework::plog("Error", os.str().c_str(), \
- __FILE__, __LINE__); \
- } while (0)
-#define FWKSEVERE(x) \
- do { \
- std::ostringstream os; \
- os << x; \
- apache::geode::client::testframework::plog("Severe", os.str().c_str(), \
- __FILE__, __LINE__); \
- } while (0)
-#define FWKEXCEPTION(x) \
- do { \
- std::ostringstream os; \
- os << x << " In file: " << __FILE__ << " at line: " << __LINE__; \
- throw apache::geode::client::testframework::FwkException( \
- os.str().c_str()); \
- } while (0)
-
-} // namespace testframework
-} // namespace client
-} // namespace geode
-} // namespace apache
-
-#endif // GEODE_FWKLIB_FWKLOG_H_
diff --git a/tests/cpp/security/CMakeLists.txt b/tests/cpp/security/CMakeLists.txt
index 847bb5d..938bf9e 100644
--- a/tests/cpp/security/CMakeLists.txt
+++ b/tests/cpp/security/CMakeLists.txt
@@ -19,13 +19,19 @@ project(security LANGUAGES CXX)
add_library(security STATIC
CredentialGenerator.cpp
CredentialGenerator.hpp
+ DummyCredentialGenerator.cpp
DummyCredentialGenerator.hpp
+ DummyCredentialGenerator2.cpp
DummyCredentialGenerator2.hpp
+ DummyCredentialGenerator3.cpp
DummyCredentialGenerator3.hpp
+ LdapUserCredentialGenerator.cpp
LdapUserCredentialGenerator.hpp
NoopCredentialGenerator.hpp
+ PkcsCredentialGenerator.cpp
PkcsCredentialGenerator.hpp
typedefs.hpp
+ XmlAuthzCredentialGenerator.cpp
XmlAuthzCredentialGenerator.hpp
)
@@ -47,6 +53,8 @@ target_link_libraries(security
OpenSSL::SSL
PRIVATE
ACE::ACE
+ Boost::boost
+ Boost::log
_WarningsAsError
)
diff --git a/tests/cpp/security/CredentialGenerator.cpp b/tests/cpp/security/CredentialGenerator.cpp
index 9d8157f..9fd07c4 100644
--- a/tests/cpp/security/CredentialGenerator.cpp
+++ b/tests/cpp/security/CredentialGenerator.cpp
@@ -17,6 +17,20 @@
#include "CredentialGenerator.hpp"
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
#include "DummyCredentialGenerator.hpp"
#include "DummyCredentialGenerator2.hpp"
#include "DummyCredentialGenerator3.hpp"
@@ -60,6 +74,71 @@ std::shared_ptr<CredentialGenerator> CredentialGenerator::create(
}
}
+void CredentialGenerator::dump() {
+ BOOST_LOG_TRIVIAL(info) << "dumping all registered classes ";
+ registeredClassMap::iterator it = generators().begin();
+ while (it != generators().end()) {
+ BOOST_LOG_TRIVIAL(info) << ((*it).second)->toString();
+ it++;
+ }
+}
+
+void CredentialGenerator::getAuthInit(std::shared_ptr<Properties>& prop) {
+ std::string authinit = getClientAuthInitLoaderFactory();
+ if (!authinit.empty()) {
+ BOOST_LOG_TRIVIAL(info) << "Authentication initializer : " << authinit
+ << " library " << getClientAuthInitLoaderLibrary();
+
+ prop->insert("security-client-auth-factory", authinit.c_str());
+ prop->insert("security-client-auth-library",
+ getClientAuthInitLoaderLibrary().c_str());
+ }
+}
+
+std::string CredentialGenerator::getServerCmdParams(std::string securityParams,
+ std::string workingDir,
+ bool userMode) {
+ std::string securityCmdStr;
+ BOOST_LOG_TRIVIAL(info) << "User mode is " << userMode;
+ if (securityParams.find("authenticator") != std::string::npos &&
+ !getClientAuthenticator().empty()) {
+ securityCmdStr = getInitArgs(workingDir, userMode);
+ securityCmdStr +=
+ std::string(" --J=-Dgemfire.security-client-authenticator=") +
+ getClientAuthenticator();
+ }
+ if ((securityParams.find("authorizer") != std::string::npos) &&
+ (!getClientAuthorizer().empty())) {
+ securityCmdStr += std::string(" --J=-Dgemfire.security-client-accessor=") +
+ getClientAuthorizer();
+ }
+ if ((securityParams.find("authorizerPP") != std::string::npos) &&
+ (!getClientAuthorizer().empty())) {
+ securityCmdStr +=
+ std::string(" --J=-Dgemfire.security-client-accessor-pp=") +
+ getClientAuthorizer();
+ }
+ if (m_id == ID_PKI) {
+ securityCmdStr +=
+ std::string(" --J=-Dgemfire.security-publickey-filepath=") +
+ getPublickeyfile();
+ securityCmdStr +=
+ std::string(" --J=-Dgemfire.security-publickey-pass=geode");
+ }
+ if ((securityParams.find("dummy") != std::string::npos) &&
+ (!getClientDummyAuthorizer().empty())) {
+ securityCmdStr += std::string(" --J=-Dgemfire.security-client-accessor=") +
+ getClientDummyAuthorizer();
+ }
+#ifdef __COMPILE_DUNIT_ // lets suppress -N option in case of unit tests.
+ int idx;
+ while ((idx = securityCmdStr.find("--J=-Dgemfire.", 0)) >= 0) {
+ securityCmdStr.replace(idx, 2, "");
+ }
+#endif
+ return securityCmdStr;
+}
+
void CredentialGenerator::getValidCredentials(std::shared_ptr<Properties>&) {}
void CredentialGenerator::getInvalidCredentials(std::shared_ptr<Properties>&) {}
diff --git a/tests/cpp/security/CredentialGenerator.hpp b/tests/cpp/security/CredentialGenerator.hpp
index 22fca50..d35b4e3 100644
--- a/tests/cpp/security/CredentialGenerator.hpp
+++ b/tests/cpp/security/CredentialGenerator.hpp
@@ -32,23 +32,12 @@
// ----------------------------------------------------------------------------
-#include <geode/Properties.hpp>
-
-#ifndef __COMPILE_DUNIT_
-#include <fwklib/FwkLog.hpp>
-#else
-#ifndef FWKINFO
-#define FWKINFO(x)
-#endif
-#ifndef FWKDEBUG
-#define FWKDEBUG(x)
-#endif
-#endif
-
#include <map>
#include <ace/OS.h>
+#include <geode/Properties.hpp>
+
#include "typedefs.hpp"
namespace apache {
@@ -145,28 +134,11 @@ class CredentialGenerator {
sprintf(chID, "%d", m_id);
return std::string(chID) + m_name;
}
- static void dump() {
- FWKINFO("dumping all registered classes ");
- registeredClassMap::iterator it = generators().begin();
- while (it != generators().end()) {
- FWKINFO(((*it).second)->toString());
- it++;
- }
- }
+ static void dump();
void hashCode() {}
- void getAuthInit(std::shared_ptr<Properties>& prop) {
- std::string authinit = this->getClientAuthInitLoaderFactory();
- if (!authinit.empty()) {
- FWKINFO("Authentication initializer : "
- << authinit << " library "
- << this->getClientAuthInitLoaderLibrary());
- prop->insert("security-client-auth-factory", authinit.c_str());
- prop->insert("security-client-auth-library",
- this->getClientAuthInitLoaderLibrary().c_str());
- }
- }
+ void getAuthInit(std::shared_ptr<Properties>& prop);
std::string getPublickeyfile() {
char* tempPath = nullptr;
@@ -185,49 +157,7 @@ class CredentialGenerator {
std::string getServerCmdParams(std::string securityParams,
std::string workingDir = "",
- bool userMode = false) {
- std::string securityCmdStr;
- FWKINFO("User mode is " << userMode);
- if (securityParams.find("authenticator") != std::string::npos &&
- !this->getClientAuthenticator().empty()) {
- securityCmdStr = this->getInitArgs(workingDir, userMode);
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-client-authenticator=") +
- this->getClientAuthenticator();
- }
- if ((securityParams.find("authorizer") != std::string::npos) &&
- (!this->getClientAuthorizer().empty())) {
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-client-accessor=") +
- this->getClientAuthorizer();
- }
- if ((securityParams.find("authorizerPP") != std::string::npos) &&
- (!this->getClientAuthorizer().empty())) {
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-client-accessor-pp=") +
- this->getClientAuthorizer();
- }
- if (m_id == ID_PKI) {
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-publickey-filepath=") +
- this->getPublickeyfile();
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-publickey-pass=geode");
- }
- if ((securityParams.find("dummy") != std::string::npos) &&
- (!this->getClientDummyAuthorizer().empty())) {
- securityCmdStr +=
- std::string(" --J=-Dgemfire.security-client-accessor=") +
- this->getClientDummyAuthorizer();
- }
-#ifdef __COMPILE_DUNIT_ // lets suppress -N option in case of unit tests.
- int idx;
- while ((idx = securityCmdStr.find("--J=-Dgemfire.", 0)) >= 0) {
- securityCmdStr.replace(idx, 2, "");
- }
-#endif
- return securityCmdStr;
- }
+ bool userMode = false);
virtual void getValidCredentials(std::shared_ptr<Properties>& p);
diff --git a/tests/cpp/security/DummyCredentialGenerator.cpp b/tests/cpp/security/DummyCredentialGenerator.cpp
new file mode 100644
index 0000000..28cd052
--- /dev/null
+++ b/tests/cpp/security/DummyCredentialGenerator.cpp
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "DummyCredentialGenerator.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+
+std::string DummyCredentialGenerator::getInitArgs(std::string workingDir,
+ bool userMode) {
+ std::string additionalArgs;
+ char* buildDir = ACE_OS::getenv("BUILDDIR");
+ if (buildDir && workingDir.length() == 0) {
+ workingDir = std::string(buildDir);
+ workingDir += std::string("/framework/xml/Security/");
+ }
+
+ BOOST_LOG_TRIVIAL(info) << "Inside dummy Credentials usermode is "
+ << userMode;
+
+ if (userMode) {
+ additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
+ std::string(workingDir) + std::string("authz-dummyMU.xml");
+ } else {
+ additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
+ std::string(workingDir) + std::string("authz-dummy.xml");
+ }
+
+ return additionalArgs;
+}
+
+void DummyCredentialGenerator::getValidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "user1");
+ p->insert("security-password", "user1");
+
+ BOOST_LOG_TRIVIAL(debug) << "inserted valid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+void DummyCredentialGenerator::getInvalidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "1user");
+ p->insert("security-password", "user1");
+
+ BOOST_LOG_TRIVIAL(debug) << "inserted invalid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/DummyCredentialGenerator.hpp b/tests/cpp/security/DummyCredentialGenerator.hpp
index a81ac58..3781e64 100644
--- a/tests/cpp/security/DummyCredentialGenerator.hpp
+++ b/tests/cpp/security/DummyCredentialGenerator.hpp
@@ -33,25 +33,7 @@ class DummyCredentialGenerator : public CredentialGenerator {
public:
DummyCredentialGenerator() : CredentialGenerator(ID_DUMMY, "DUMMY") {}
- std::string getInitArgs(std::string workingDir, bool userMode) override {
- std::string additionalArgs;
- char* buildDir = ACE_OS::getenv("BUILDDIR");
- if (buildDir && workingDir.length() == 0) {
- workingDir = std::string(buildDir);
- workingDir += std::string("/framework/xml/Security/");
- }
- FWKINFO("Inside dummy Credentials usermode is " << userMode);
- if (userMode) {
- additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
- std::string(workingDir) +
- std::string("authz-dummyMU.xml");
- } else {
- additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
- std::string(workingDir) + std::string("authz-dummy.xml");
- }
-
- return additionalArgs;
- }
+ std::string getInitArgs(std::string workingDir, bool userMode) override;
std::string getClientAuthInitLoaderFactory() override {
return "createUserPasswordAuthInitInstance";
@@ -70,21 +52,8 @@ class DummyCredentialGenerator : public CredentialGenerator {
return "javaobject.DummyAuthorization.create";
}
- void getValidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "user1");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted valid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
-
- void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "1user");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted invalid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
+ void getValidCredentials(std::shared_ptr<Properties>& p) override;
+ void getInvalidCredentials(std::shared_ptr<Properties>& p) override;
void getAllowedCredentialsForOps(opCodeList& opCodes,
std::shared_ptr<Properties>& p,
diff --git a/tests/cpp/security/DummyCredentialGenerator2.cpp b/tests/cpp/security/DummyCredentialGenerator2.cpp
new file mode 100644
index 0000000..eb3046d
--- /dev/null
+++ b/tests/cpp/security/DummyCredentialGenerator2.cpp
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "DummyCredentialGenerator2.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+
+void DummyCredentialGenerator2::getInvalidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "1user");
+ p->insert("security-password", "user1");
+ BOOST_LOG_TRIVIAL(debug) << "inserted invalid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+void DummyCredentialGenerator2::getValidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "user1");
+ p->insert("security-password", "user1");
+ BOOST_LOG_TRIVIAL(debug) << "inserted valid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/DummyCredentialGenerator2.hpp b/tests/cpp/security/DummyCredentialGenerator2.hpp
index afe33cb..f91eb3b 100644
--- a/tests/cpp/security/DummyCredentialGenerator2.hpp
+++ b/tests/cpp/security/DummyCredentialGenerator2.hpp
@@ -69,22 +69,9 @@ class DummyCredentialGenerator2 : public CredentialGenerator {
return "javaobject.DummyAuthorization.create";
}
- void getValidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "user1");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted valid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
-
- void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "1user");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted invalid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
+ void getValidCredentials(std::shared_ptr<Properties>& p) override;
+ void getInvalidCredentials(std::shared_ptr<Properties>& p) override;
void getAllowedCredentialsForOps(opCodeList& opCodes,
std::shared_ptr<Properties>& p,
stringList* regionNames) override {
diff --git a/tests/cpp/security/DummyCredentialGenerator3.cpp b/tests/cpp/security/DummyCredentialGenerator3.cpp
new file mode 100644
index 0000000..a732ed0
--- /dev/null
+++ b/tests/cpp/security/DummyCredentialGenerator3.cpp
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "DummyCredentialGenerator3.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+void DummyCredentialGenerator3::getValidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "user1");
+ p->insert("security-password", "user1");
+ BOOST_LOG_TRIVIAL(debug) << "inserted valid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+void DummyCredentialGenerator3::getInvalidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "1user");
+ p->insert("security-password", "user1");
+ BOOST_LOG_TRIVIAL(debug) << "inserted invalid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/DummyCredentialGenerator3.hpp b/tests/cpp/security/DummyCredentialGenerator3.hpp
index 6e448de..c5c2194 100644
--- a/tests/cpp/security/DummyCredentialGenerator3.hpp
+++ b/tests/cpp/security/DummyCredentialGenerator3.hpp
@@ -69,21 +69,9 @@ class DummyCredentialGenerator3 : public CredentialGenerator {
return "javaobject.DummyAuthorization.create";
}
- void getValidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "user1");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted valid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
+ void getValidCredentials(std::shared_ptr<Properties>& p) override;
- void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "1user");
- p->insert("security-password", "user1");
- FWKDEBUG("inserted invalid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
+ void getInvalidCredentials(std::shared_ptr<Properties>& p) override;
void getAllowedCredentialsForOps(opCodeList& opCodes,
std::shared_ptr<Properties>& p,
diff --git a/tests/cpp/security/LdapUserCredentialGenerator.cpp b/tests/cpp/security/LdapUserCredentialGenerator.cpp
new file mode 100644
index 0000000..6df00e0
--- /dev/null
+++ b/tests/cpp/security/LdapUserCredentialGenerator.cpp
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "LdapUserCredentialGenerator.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+void LdapUserCredentialGenerator::getValidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "geode1");
+ p->insert("security-password", "geode1");
+ BOOST_LOG_TRIVIAL(debug) << "inserted valid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+void LdapUserCredentialGenerator::getInvalidCredentials(
+ std::shared_ptr<Properties>& p) {
+ p->insert("security-username", "geode1");
+ p->insert("security-password", "1geode");
+ BOOST_LOG_TRIVIAL(debug) << "inserted invalid security-username "
+ << p->find("security-username")->value()
+ << " password "
+ << p->find("security-password")->value();
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/LdapUserCredentialGenerator.hpp b/tests/cpp/security/LdapUserCredentialGenerator.hpp
index 97d8430..a486e4a 100644
--- a/tests/cpp/security/LdapUserCredentialGenerator.hpp
+++ b/tests/cpp/security/LdapUserCredentialGenerator.hpp
@@ -81,21 +81,10 @@ class LdapUserCredentialGenerator : public CredentialGenerator {
std::string getClientDummyAuthorizer() override {
return "javaobject.DummyAuthorization.create";
}
- void getValidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "geode1");
- p->insert("security-password", "geode1");
- FWKDEBUG("inserted valid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
- void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
- p->insert("security-username", "geode1");
- p->insert("security-password", "1geode");
- FWKDEBUG("inserted invalid security-username "
- << p->find("security-username")->value().c_str() << " password "
- << p->find("security-password")->value().c_str());
- }
+ void getValidCredentials(std::shared_ptr<Properties>& p) override;
+
+ void getInvalidCredentials(std::shared_ptr<Properties>& p) override;
void getAllowedCredentialsForOps(opCodeList& opCodes,
std::shared_ptr<Properties>& p,
diff --git a/tests/cpp/security/PkcsCredentialGenerator.cpp b/tests/cpp/security/PkcsCredentialGenerator.cpp
new file mode 100644
index 0000000..f09b19b
--- /dev/null
+++ b/tests/cpp/security/PkcsCredentialGenerator.cpp
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "PkcsCredentialGenerator.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+std::string PKCSCredentialGenerator::getInitArgs(std::string workingDir, bool) {
+ BOOST_LOG_TRIVIAL(info) << "Inside PKCS credentials";
+ std::string additionalArgs;
+ char* buildDir = ACE_OS::getenv("BUILDDIR");
+
+ if (buildDir && workingDir.length() == 0) {
+ workingDir = std::string(buildDir);
+ workingDir += std::string("/framework/xml/Security/");
+ }
+
+ if (buildDir && workingDir.length() == 0) {
+ workingDir = std::string(buildDir);
+ workingDir += std::string("/framework/xml/Security/");
+ }
+
+ char* authzXmlUri = ACE_OS::getenv("AUTHZ_XML_URI");
+ additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
+ std::string(workingDir) +
+ std::string(authzXmlUri ? authzXmlUri : "authz-pkcs.xml");
+
+ return additionalArgs;
+}
+
+void PKCSCredentialGenerator::getValidCredentials(
+ std::shared_ptr<Properties>& p) {
+ char username[20] = {'\0'};
+ sprintf(username, "geode%d", randomValue(1, 10));
+ setPKCSProperties(p, username);
+ BOOST_LOG_TRIVIAL(info) << "inserted valid security-username "
+ << p->find("security-username")->value();
+}
+
+void PKCSCredentialGenerator::getInvalidCredentials(
+ std::shared_ptr<Properties>& p) {
+ char username[20] = {'\0'};
+ sprintf(username, "%dgeode", randomValue(1, 11));
+ setPKCSProperties(p, username);
+ BOOST_LOG_TRIVIAL(info) << "inserted invalid security-username "
+ << p->find("security-username")->value();
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/PkcsCredentialGenerator.hpp b/tests/cpp/security/PkcsCredentialGenerator.hpp
index f21a3d6..c3943f9 100644
--- a/tests/cpp/security/PkcsCredentialGenerator.hpp
+++ b/tests/cpp/security/PkcsCredentialGenerator.hpp
@@ -50,28 +50,7 @@ class PKCSCredentialGenerator : public CredentialGenerator {
public:
PKCSCredentialGenerator() : CredentialGenerator(ID_PKI, "PKCS") {}
- std::string getInitArgs(std::string workingDir, bool) override {
- FWKINFO("Inside PKCS credentials");
- std::string additionalArgs;
- char* buildDir = ACE_OS::getenv("BUILDDIR");
-
- if (buildDir && workingDir.length() == 0) {
- workingDir = std::string(buildDir);
- workingDir += std::string("/framework/xml/Security/");
- }
-
- if (buildDir && workingDir.length() == 0) {
- workingDir = std::string(buildDir);
- workingDir += std::string("/framework/xml/Security/");
- }
-
- char* authzXmlUri = ACE_OS::getenv("AUTHZ_XML_URI");
- additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
- std::string(workingDir) +
- std::string(authzXmlUri ? authzXmlUri : "authz-pkcs.xml");
-
- return additionalArgs;
- }
+ std::string getInitArgs(std::string workingDir, bool) override;
std::string getClientAuthInitLoaderFactory() override {
return "createPKCSAuthInitInstance";
@@ -117,21 +96,9 @@ class PKCSCredentialGenerator : public CredentialGenerator {
insertKeyStorePath(p, username);
}
- void getValidCredentials(std::shared_ptr<Properties>& p) override {
- char username[20] = {'\0'};
- sprintf(username, "geode%d", randomValue(1, 10));
- setPKCSProperties(p, username);
- FWKINFO("inserted valid security-username "
- << p->find("security-username")->value().c_str());
- }
+ void getValidCredentials(std::shared_ptr<Properties>& p) override;
- void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
- char username[20] = {'\0'};
- sprintf(username, "%dgeode", randomValue(1, 11));
- setPKCSProperties(p, username);
- FWKINFO("inserted invalid security-username "
- << p->find("security-username")->value().c_str());
- }
+ void getInvalidCredentials(std::shared_ptr<Properties>& p) override;
void getAllowedCredentialsForOps(opCodeList& opCodes,
std::shared_ptr<Properties>& p,
diff --git a/tests/cpp/security/XmlAuthzCredentialGenerator.cpp b/tests/cpp/security/XmlAuthzCredentialGenerator.cpp
new file mode 100644
index 0000000..89cecd4
--- /dev/null
+++ b/tests/cpp/security/XmlAuthzCredentialGenerator.cpp
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "XmlAuthzCredentialGenerator.hpp"
+
+// Disable warning for "extra qualifications" here. One of the boost log
+// headers triggers this warning. Note: use of disable pragma here is
+// intentional - attempts to use push/pop as you ordinarily should just
+// yielded a gripe from the MS tools that "warning number '4596' is not a
+// valid compiler warning". re-enabling the warning after the include
+// fails in the same way, so just leave it disabled for the rest of the
+// file. This is safe, since the warning can only trigger inside a class
+// declaration, of which there are none in this file.
+#ifdef WIN32
+#pragma warning(disable : 4596)
+#endif
+
+#include <boost/log/trivial.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace testframework {
+namespace security {
+
+void XmlAuthzCredentialGenerator::getAllowedDummyAuthz(ROLES role) {
+ const char* adminUsers[] = {"admin", "root", "administrator"};
+ const int adminUsrSz = (sizeof adminUsers / sizeof *adminUsers) - 1;
+ std::string validity = "invalid";
+
+ if (role == NO_ROLE) {
+ role = getRequiredRole();
+ validity = "valid";
+ }
+ char userName[100];
+ switch (role) {
+ case READER_ROLE:
+ sprintf(userName, kPRiUsername, "reader", randomValue(2));
+ break;
+ case WRITER_ROLE:
+ sprintf(userName, kPRiUsername, "writer", randomValue(2));
+ break;
+ case QUERY_ROLE:
+ sprintf(userName, kPRiUsername, "reader", randomValue(1) + 3);
+ break;
+ case ADMIN_ROLE:
+ sprintf(userName, "%s", adminUsers[randomValue(adminUsrSz)]);
+ break;
+ case NO_ROLE:
+ sprintf(userName, kPRiUsername, "user", randomValue(2));
+ break;
+ }
+
+ (*m_prop)->insert("security-username", userName);
+ (*m_prop)->insert("security-password", userName);
+
+ BOOST_LOG_TRIVIAL(info)
+ << "inserted " << validity << " dummy security-username "
+ << (*m_prop)->find("security-username")->value().c_str() << " password "
+ << ((*m_prop)->find("security-password") != nullptr
+ ? (*m_prop)->find("security-password")->value().c_str()
+ : "not set");
+}
+
+std::string XmlAuthzCredentialGenerator::getAllowedUser(ROLES role) {
+ const std::string userPrefix = "geode";
+ const int readerIndices[] = {3, 4, 5};
+ const int writerIndices[] = {6, 7, 8};
+ const int queryIndices[] = {9, 10};
+ const int adminIndices[] = {1, 2};
+ const int readerIndSz = (sizeof readerIndices / sizeof *readerIndices) - 1;
+ const int writerIndSz = (sizeof writerIndices / sizeof *writerIndices) - 1;
+ const int queryIndSz = (sizeof queryIndices / sizeof *queryIndices) - 1;
+ const int adminIndSz = (sizeof adminIndices / sizeof *adminIndices) - 1;
+
+ std::string validity = "invalid";
+
+ if (role == NO_ROLE) {
+ role = getRequiredRole();
+ validity = "valid";
+ }
+ char userName[256];
+ switch (role) {
+ case READER_ROLE:
+ sprintf(userName, kPRiUsername, userPrefix.c_str(),
+ readerIndices[randomValue(readerIndSz)]);
+ break;
+ case WRITER_ROLE:
+ sprintf(userName, kPRiUsername, userPrefix.c_str(),
+ writerIndices[randomValue(writerIndSz)]);
+ break;
+ case QUERY_ROLE:
+ sprintf(userName, kPRiUsername, userPrefix.c_str(),
+ queryIndices[randomValue(queryIndSz)]);
+ break;
+ case ADMIN_ROLE:
+ case NO_ROLE:
+ sprintf(userName, kPRiUsername, userPrefix.c_str(),
+ adminIndices[randomValue(adminIndSz)]);
+ break;
+ }
+ BOOST_LOG_TRIVIAL(info) << "inserted " << validity << " username "
+ << userName;
+ return std::string(userName);
+}
+
+void XmlAuthzCredentialGenerator::getAllowedLdapAuthz(ROLES role) {
+ const std::string userName = getAllowedUser(role);
+ (*m_prop)->insert("security-username", userName.c_str());
+ (*m_prop)->insert("security-password", userName.c_str());
+
+ BOOST_LOG_TRIVIAL(info)
+ << "inserted ldap security-username "
+ << (*m_prop)->find("security-username")->value() << " password "
+ << ((*m_prop)->find("security-password") != nullptr
+ ? (*m_prop)->find("security-password")->value()
+ : "not set");
+}
+
+void XmlAuthzCredentialGenerator::getAllowedPkcsAuthz(ROLES role) {
+ const std::string userName = getAllowedUser(role);
+ (*m_prop)->insert("security-alias", userName.c_str());
+ (*m_prop)->insert("security-keystorepass", "geode");
+
+ BOOST_LOG_TRIVIAL(info)
+ << "inserted PKCS security-alias"
+ << (*m_prop)->find("security-alias")->value() << " password "
+ << ((*m_prop)->find("security-keystorepass") != nullptr
+ ? (*m_prop)->find("security-keystorepass")->value()
+ : "not set");
+}
+
+} // namespace security
+} // namespace testframework
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
index c951689..64545f0 100644
--- a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
+++ b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
@@ -174,112 +174,10 @@ class XmlAuthzCredentialGenerator {
}
private:
- void getAllowedDummyAuthz(ROLES role) {
- const char* adminUsers[] = {"admin", "root", "administrator"};
- const int adminUsrSz = (sizeof adminUsers / sizeof *adminUsers) - 1;
- std::string validity = "invalid";
-
- if (role == NO_ROLE) {
- role = getRequiredRole();
- validity = "valid";
- }
- char userName[100];
- switch (role) {
- case READER_ROLE:
- sprintf(userName, kPRiUsername, "reader", randomValue(2));
- break;
- case WRITER_ROLE:
- sprintf(userName, kPRiUsername, "writer", randomValue(2));
- break;
- case QUERY_ROLE:
- sprintf(userName, kPRiUsername, "reader", randomValue(1) + 3);
- break;
- case ADMIN_ROLE:
- sprintf(userName, "%s", adminUsers[randomValue(adminUsrSz)]);
- break;
- case NO_ROLE:
- sprintf(userName, kPRiUsername, "user", randomValue(2));
- break;
- }
-
- (*m_prop)->insert("security-username", userName);
- (*m_prop)->insert("security-password", userName);
-
- FWKINFO("inserted "
- << validity << " dummy security-username "
- << (*m_prop)->find("security-username")->value().c_str()
- << " password "
- << ((*m_prop)->find("security-password") != nullptr
- ? (*m_prop)->find("security-password")->value().c_str()
- : "not set"));
- }
-
- std::string getAllowedUser(ROLES role) {
- const std::string userPrefix = "geode";
- const int readerIndices[] = {3, 4, 5};
- const int writerIndices[] = {6, 7, 8};
- const int queryIndices[] = {9, 10};
- const int adminIndices[] = {1, 2};
- const int readerIndSz = (sizeof readerIndices / sizeof *readerIndices) - 1;
- const int writerIndSz = (sizeof writerIndices / sizeof *writerIndices) - 1;
- const int queryIndSz = (sizeof queryIndices / sizeof *queryIndices) - 1;
- const int adminIndSz = (sizeof adminIndices / sizeof *adminIndices) - 1;
-
- std::string validity = "invalid";
-
- if (role == NO_ROLE) {
- role = getRequiredRole();
- validity = "valid";
- }
- char userName[256];
- switch (role) {
- case READER_ROLE:
- sprintf(userName, kPRiUsername, userPrefix.c_str(),
- readerIndices[randomValue(readerIndSz)]);
- break;
- case WRITER_ROLE:
- sprintf(userName, kPRiUsername, userPrefix.c_str(),
- writerIndices[randomValue(writerIndSz)]);
- break;
- case QUERY_ROLE:
- sprintf(userName, kPRiUsername, userPrefix.c_str(),
- queryIndices[randomValue(queryIndSz)]);
- break;
- case ADMIN_ROLE:
- case NO_ROLE:
- sprintf(userName, kPRiUsername, userPrefix.c_str(),
- adminIndices[randomValue(adminIndSz)]);
- break;
- }
- FWKINFO("inserted " << validity << " username " << userName);
- return std::string(userName);
- }
-
- void getAllowedLdapAuthz(ROLES role) {
- const std::string userName = getAllowedUser(role);
- (*m_prop)->insert("security-username", userName.c_str());
- (*m_prop)->insert("security-password", userName.c_str());
-
- FWKINFO("inserted ldap security-username "
- << (*m_prop)->find("security-username")->value().c_str()
- << " password "
- << ((*m_prop)->find("security-password") != nullptr
- ? (*m_prop)->find("security-password")->value().c_str()
- : "not set"));
- }
-
- void getAllowedPkcsAuthz(ROLES role) {
- const std::string userName = getAllowedUser(role);
- (*m_prop)->insert("security-alias", userName.c_str());
- (*m_prop)->insert("security-keystorepass", "geode");
-
- FWKINFO("inserted PKCS security-alias"
- << (*m_prop)->find("security-alias")->value().c_str()
- << " password "
- << ((*m_prop)->find("security-keystorepass") != nullptr
- ? (*m_prop)->find("security-keystorepass")->value().c_str()
- : "not set"));
- }
+ void getAllowedDummyAuthz(ROLES role);
+ std::string getAllowedUser(ROLES role);
+ void getAllowedLdapAuthz(ROLES role);
+ void getAllowedPkcsAuthz(ROLES role);
ROLES getRequiredRole() {
bool requireReaders = true, requireWriters = true, requireQuery = true;
diff --git a/tests/cpp/testobject/ArrayOfByte.hpp b/tests/cpp/testobject/ArrayOfByte.hpp
index ca91ac8..b66db20 100644
--- a/tests/cpp/testobject/ArrayOfByte.hpp
+++ b/tests/cpp/testobject/ArrayOfByte.hpp
@@ -20,7 +20,7 @@
* limitations under the License.
*/
-#include <fwklib/FwkLog.hpp>
+#include <fwklib/FwkException.hpp>
#include <string>
#include <ace/Time_Value.h>
@@ -30,6 +30,14 @@
#include "SerializationRegistry.hpp"
#include "testobject_export.h"
+#define FWKEXCEPTION(x) \
+ do { \
+ std::ostringstream os; \
+ os << x << " In file: " << __FILE__ << " at line: " << __LINE__; \
+ throw apache::geode::client::testframework::FwkException( \
+ os.str().c_str()); \
+ } while (0)
+
namespace testobject {
using apache::geode::client::CacheableBytes;
@@ -49,12 +57,8 @@ class TESTOBJECT_EXPORT ArrayOfByte {
int32_t index = 1234;
dos.writeInt(index);
if (encodeTimestamp) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- int64_t timestamp = tusec * 1000;
- dos.writeInt(timestamp);
+ dos.writeInt(
+ std::chrono::system_clock::now().time_since_epoch().count());
}
} catch (Exception &e) {
FWKEXCEPTION("Unable to write to stream " << e.what());
@@ -110,12 +114,7 @@ class TESTOBJECT_EXPORT ArrayOfByte {
DataOutputInternal dos;
try {
dos.writeInt(index);
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- int64_t timestamp = tusec * 1000;
- dos.writeInt(timestamp);
+ dos.writeInt(std::chrono::system_clock::now().time_since_epoch().count());
} catch (Exception &e) {
FWKEXCEPTION("Unable to write to stream " << e.what());
}
diff --git a/tests/cpp/testobject/BatchObject.cpp b/tests/cpp/testobject/BatchObject.cpp
index 50d53c0..a2f8635 100644
--- a/tests/cpp/testobject/BatchObject.cpp
+++ b/tests/cpp/testobject/BatchObject.cpp
@@ -23,11 +23,7 @@ using apache::geode::client::CacheableBytes;
BatchObject::BatchObject(int32_t anIndex, int32_t batchSize, int32_t size) {
index = anIndex;
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
batch = anIndex / batchSize;
byteArray = CacheableBytes::create(std::vector<int8_t>(size));
}
diff --git a/tests/cpp/testobject/BatchObject.hpp b/tests/cpp/testobject/BatchObject.hpp
index 8a8d29e..8d88d6c 100644
--- a/tests/cpp/testobject/BatchObject.hpp
+++ b/tests/cpp/testobject/BatchObject.hpp
@@ -23,10 +23,6 @@
#include <cinttypes>
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include <geode/CacheableBuiltins.hpp>
#include "TimestampedObject.hpp"
@@ -67,11 +63,7 @@ class TESTOBJECT_EXPORT BatchObject : public TimestampedObject {
int getIndex() { return index; }
int getBatch() { return batch; }
void resetTimestamp() override {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
static apache::geode::client::Serializable* createDeserializable() {
diff --git a/tests/cpp/testobject/DeltaFastAssetAccount.cpp b/tests/cpp/testobject/DeltaFastAssetAccount.cpp
index 111818f..dbde67c 100644
--- a/tests/cpp/testobject/DeltaFastAssetAccount.cpp
+++ b/tests/cpp/testobject/DeltaFastAssetAccount.cpp
@@ -35,13 +35,11 @@ DeltaFastAssetAccount::DeltaFastAssetAccount(int index, bool encodeTimestp,
assets->emplace(CacheableInt32::create(i), asset);
netWorth += asset->getValue();
}
+
if (encodeTimestamp) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
+
getBeforeUpdate = getbfrUpdate;
}
diff --git a/tests/cpp/testobject/DeltaFastAssetAccount.hpp b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
index ad96bdc..9662004 100644
--- a/tests/cpp/testobject/DeltaFastAssetAccount.hpp
+++ b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
@@ -23,10 +23,6 @@
#include <cinttypes>
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include <geode/CacheableBuiltins.hpp>
#include <geode/Delta.hpp>
@@ -103,15 +99,10 @@ class TESTOBJECT_EXPORT DeltaFastAssetAccount : public DataSerializable,
}
void resetTimestamp() {
- if (encodeTimestamp) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
- } else {
- timestamp = 0;
- }
+ timestamp =
+ encodeTimestamp
+ ? std::chrono::system_clock::now().time_since_epoch().count()
+ : 0;
}
void update() {
diff --git a/tests/cpp/testobject/DeltaPSTObject.cpp b/tests/cpp/testobject/DeltaPSTObject.cpp
index b34cb58..f055100 100644
--- a/tests/cpp/testobject/DeltaPSTObject.cpp
+++ b/tests/cpp/testobject/DeltaPSTObject.cpp
@@ -24,11 +24,7 @@
namespace testobject {
DeltaPSTObject::DeltaPSTObject(int size, bool encodeKey) : Delta() {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
field1 = 1234;
field2 = '*';
if (size == 0) {
diff --git a/tests/cpp/testobject/DeltaPSTObject.hpp b/tests/cpp/testobject/DeltaPSTObject.hpp
index ddab236..3927cef 100644
--- a/tests/cpp/testobject/DeltaPSTObject.hpp
+++ b/tests/cpp/testobject/DeltaPSTObject.hpp
@@ -23,10 +23,6 @@
#include <cinttypes>
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include <geode/Delta.hpp>
#include "TimestampedObject.hpp"
@@ -69,11 +65,7 @@ class TESTOBJECT_EXPORT DeltaPSTObject : public DataSerializable, public Delta {
uint64_t getTimestamp() { return timestamp; }
void resetTimestamp() {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
inline std::shared_ptr<Delta> clone() const override { return nullptr; }
diff --git a/tests/cpp/testobject/DeltaTestImpl.hpp b/tests/cpp/testobject/DeltaTestImpl.hpp
index 96eab03..209fb37 100644
--- a/tests/cpp/testobject/DeltaTestImpl.hpp
+++ b/tests/cpp/testobject/DeltaTestImpl.hpp
@@ -25,7 +25,6 @@
#include <ace/OS.h>
#include <ace/Recursive_Thread_Mutex.h>
#include <ace/Task.h>
-#include <ace/Time_Value.h>
#include <geode/DataSerializable.hpp>
#include <geode/Delta.hpp>
diff --git a/tests/cpp/testobject/EqStruct.cpp b/tests/cpp/testobject/EqStruct.cpp
index 3584e90..30b31a3 100644
--- a/tests/cpp/testobject/EqStruct.cpp
+++ b/tests/cpp/testobject/EqStruct.cpp
@@ -25,11 +25,8 @@ namespace testobject {
EqStruct::EqStruct(int index) {
myIndex = index; // index
state = "1";
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
executedPriceSum = 5.5;
cxlQty = 10;
isSyntheticOrder = 0;
diff --git a/tests/cpp/testobject/EqStruct.hpp b/tests/cpp/testobject/EqStruct.hpp
index 538063d..0e33539 100644
--- a/tests/cpp/testobject/EqStruct.hpp
+++ b/tests/cpp/testobject/EqStruct.hpp
@@ -24,10 +24,6 @@
#include <fwklib/FwkException.hpp>
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include "TimestampedObject.hpp"
#include "testobject_export.h"
@@ -127,11 +123,7 @@ class TESTOBJECT_EXPORT EqStruct : public TimestampedObject {
uint64_t getTimestamp() override { return timestamp; }
void resetTimestamp() override {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
static apache::geode::client::Serializable* createDeserializable() {
diff --git a/tests/cpp/testobject/FastAsset.hpp b/tests/cpp/testobject/FastAsset.hpp
index 8f21a79..8ef534d 100644
--- a/tests/cpp/testobject/FastAsset.hpp
+++ b/tests/cpp/testobject/FastAsset.hpp
@@ -26,10 +26,6 @@
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include "TimestampedObject.hpp"
#include "testobject_export.h"
diff --git a/tests/cpp/testobject/FastAssetAccount.cpp b/tests/cpp/testobject/FastAssetAccount.cpp
index 9f154d5..3946e69 100644
--- a/tests/cpp/testobject/FastAssetAccount.cpp
+++ b/tests/cpp/testobject/FastAssetAccount.cpp
@@ -39,12 +39,9 @@ FastAssetAccount::FastAssetAccount(int idx, bool encodeTimestp, int maxVal,
assets->emplace(CacheableInt32::create(i), asset);
netWorth += asset->getValue();
}
+
if (encodeTimestamp) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
}
diff --git a/tests/cpp/testobject/FastAssetAccount.hpp b/tests/cpp/testobject/FastAssetAccount.hpp
index 7ed2905..b310336 100644
--- a/tests/cpp/testobject/FastAssetAccount.hpp
+++ b/tests/cpp/testobject/FastAssetAccount.hpp
@@ -22,10 +22,6 @@
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include <geode/CacheableBuiltins.hpp>
#include "TimestampedObject.hpp"
@@ -92,16 +88,12 @@ class TESTOBJECT_EXPORT FastAssetAccount : public TimestampedObject {
}
void resetTimestamp() override {
- if (encodeTimestamp) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
- } else {
- timestamp = 0;
- }
+ timestamp =
+ encodeTimestamp
+ ? std::chrono::system_clock::now().time_since_epoch().count()
+ : 0;
}
+
void update() {
incrementNetWorth();
if (encodeTimestamp) {
diff --git a/tests/cpp/testobject/PSTObject.cpp b/tests/cpp/testobject/PSTObject.cpp
index 96b2e44..d9e55ef 100644
--- a/tests/cpp/testobject/PSTObject.cpp
+++ b/tests/cpp/testobject/PSTObject.cpp
@@ -24,11 +24,7 @@
namespace testobject {
PSTObject::PSTObject(int size, bool encodeKey) {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec = 0;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
field1 = 1234;
field2 = '*';
if (size == 0) {
diff --git a/tests/cpp/testobject/PSTObject.hpp b/tests/cpp/testobject/PSTObject.hpp
index fddb1c4..c738ed6 100644
--- a/tests/cpp/testobject/PSTObject.hpp
+++ b/tests/cpp/testobject/PSTObject.hpp
@@ -23,10 +23,6 @@
#include <cinttypes>
#include <string>
-#include <ace/ACE.h>
-#include <ace/OS.h>
-#include <ace/Time_Value.h>
-
#include <geode/CacheableBuiltins.hpp>
#include "TimestampedObject.hpp"
@@ -68,11 +64,7 @@ class TESTOBJECT_EXPORT PSTObject : public TimestampedObject {
uint64_t getTimestamp() override { return timestamp; }
void resetTimestamp() override {
- ACE_Time_Value startTime;
- startTime = ACE_OS::gettimeofday();
- ACE_UINT64 tusec;
- startTime.to_usec(tusec);
- timestamp = tusec * 1000;
+ timestamp = std::chrono::system_clock::now().time_since_epoch().count();
}
static apache::geode::client::Serializable* createDeserializable() {