Skip to content

Commit

Permalink
Address merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Apr 10, 2024
2 parents c7a3b9f + b2847cd commit 57a2a65
Show file tree
Hide file tree
Showing 58 changed files with 765 additions and 464 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ common/proto/common/Version.proto
compose/.env
compose/globus
compose/keys
compose/logs
compose/unset_env.sh
config/datafed.sh
config/datafed-authz.cfg
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
smaller images
4. [912] - Adding working compose instance for core metadata services.
5. [937] - Working metadata services running together as part of CI
6. [945] - Added C functions for comparing POSIX path in Authz module
6. [946] - Added docker compose for DataFed Repository and for Metadata Services
7. [945] - Added C functions for comparing POSIX path in Authz module

## PATCH Bug fixes/Technical Debt/Documentation

Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ OPTION(BUILD_PYTHON_CLIENT "Build python client" TRUE)
OPTION(BUILD_TESTS "Build Tests" TRUE)
OPTION(BUILD_WEB_SERVER "Build DataFed Web Server" TRUE)
OPTION(ENABLE_UNIT_TESTS "Enable unit tests" TRUE)
OPTION(BUILD_SHARED_LIBS "Build using shared libraries. By default this is off.
With the exception of the libdatafed-authz which must be a shared library. This
includes also attempting to link with shared libraries instead of static ones" OFF)
OPTION(BUILD_SHARED_LIBS "By default DataFed tries to build static libraries
with the exception of libdatafed-authz which must always be a shared library,
it will also try to link with as many static libraries as possible. However,
building with static depencies is not completely possible because some system
libraries must be shared libraries for DataFed to be interoperable. If this
setting is turned on DataFed will build it's libraries as shared and try to
link to shared libraries." OFF)

set(INSTALL_REPO_SERVER ${BUILD_REPO_SERVER})
set(INSTALL_AUTHZ ${BUILD_AUTHZ})
Expand Down
5 changes: 5 additions & 0 deletions cmake/curl_version.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <curl/curl.h>
#include <iostream>

/**
* This script is used to show what vesion of curl is being used with the
* rest of the build process and will print the version number of the curl
* library.
**/
int main() {
std::cout << curl_version() << std::endl;
return 0;
Expand Down
5 changes: 5 additions & 0 deletions cmake/zlib_version.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <iostream>
#include <zlib.h>

/**
* This little file is used to make sure that we are compiling with the version
* of a library that we think we are. This one when run will print the zlib
* version numbers.
**/
int main() {
std::cout << zlibVersion() << std::endl;
return 0;
Expand Down
3 changes: 2 additions & 1 deletion common/include/common/CommunicatorFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class CommunicatorFactory {
LogContext m_log_context;

public:
CommunicatorFactory(LogContext log_context) : m_log_context(log_context){};
explicit CommunicatorFactory(const LogContext &log_context)
: m_log_context(log_context){};

std::unique_ptr<ICommunicator> create(const SocketOptions &socket_options,
const ICredentials &credentials,
Expand Down
20 changes: 19 additions & 1 deletion common/include/common/DynaLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,25 @@

namespace SDMS {

enum class LogLevel { CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE };
/**
* Here unsigned int is used so that we can compare the numeric values when
* choosing whether to print a log message.
*
* CRITICAL = 0
* ERROR = 1
* WARNING = 2
* INFO = 3
* DEBUG = 4
* TRACE = 5
**/
enum class LogLevel : unsigned int {
CRITICAL,
ERROR,
WARNING,
INFO,
DEBUG,
TRACE
};

std::string toString(const LogLevel level);
int toSysLog(const LogLevel level);
Expand Down
6 changes: 3 additions & 3 deletions common/include/common/GSSAPI_Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ class gssString {
m_gss_buf.length = 0;
}

gssString(const std::string &a_src) {
explicit gssString(const std::string &a_src) {
m_gss_buf.value = 0;
m_gss_buf.length = 0;

set(a_src);
}

gssString(const char *a_src) {
explicit gssString(const char *a_src) {
m_gss_buf.value = 0;
m_gss_buf.length = 0;

set(a_src);
}

gssString(gss_name_t a_src) {
explicit gssString(gss_name_t a_src) {
m_gss_buf.value = 0;
m_gss_buf.length = 0;

Expand Down
3 changes: 2 additions & 1 deletion common/include/common/ServerFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ServerFactory {
LogContext m_log_context;

public:
ServerFactory(LogContext log_context) : m_log_context(log_context){};
explicit ServerFactory(const LogContext &log_context)
: m_log_context(log_context){};

std::unique_ptr<IServer> create(
ServerType server_type,
Expand Down
4 changes: 2 additions & 2 deletions common/include/common/SmartTokenizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ template <char delim = ' ', bool keep_empty = false> class SmartTokenizer {

SmartTokenizer() {}

SmartTokenizer(const std::string &a_input_str) {
explicit SmartTokenizer(const std::string &a_input_str) {
m_buffer.reserve(a_input_str.size());
_parse(a_input_str.c_str(), a_input_str.size());
}
Expand Down Expand Up @@ -133,4 +133,4 @@ template <char delim = ' ', bool keep_empty = false> class SmartTokenizer {
std::vector<const char *> m_tokens;
};

#endif
#endif
18 changes: 9 additions & 9 deletions common/include/common/libjson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,17 @@ class Value {

Value() : m_type(VT_NULL), m_value({0}) {}

Value(bool a_value) : m_type(VT_BOOL) { m_value.b = a_value; }
explicit Value(bool a_value) : m_type(VT_BOOL) { m_value.b = a_value; }

Value(double a_value) : m_type(VT_NUMBER) { m_value.n = a_value; }
explicit Value(double a_value) : m_type(VT_NUMBER) { m_value.n = a_value; }

Value(int a_value) : m_type(VT_NUMBER) { m_value.n = a_value; }
explicit Value(int a_value) : m_type(VT_NUMBER) { m_value.n = a_value; }

Value(const std::string &a_value) : m_type(VT_STRING) {
explicit Value(const std::string &a_value) : m_type(VT_STRING) {
m_value.s = new String(a_value);
}

Value(const char *a_value) : m_type(VT_STRING) {
explicit Value(const char *a_value) : m_type(VT_STRING) {
m_value.s = new String(a_value);
}

Expand All @@ -410,7 +410,7 @@ class Value {
a_source.m_value.o = 0;
}

Value(ValueType a_type) : m_type(a_type) {
explicit Value(ValueType a_type) : m_type(a_type) {
if (m_type == VT_OBJECT) {
m_value.o = new Object();
} else if (m_type == VT_ARRAY) {
Expand Down Expand Up @@ -837,7 +837,7 @@ class Value {
switch (m_type) {
case VT_OBJECT:
a_buffer.append("{");
for (ObjectIter i = m_value.o->begin(); i != m_value.o->end(); i++) {
for (ObjectIter i = m_value.o->begin(); i != m_value.o->end(); ++i) {
if (i != m_value.o->begin())
a_buffer.append(",\"");
else
Expand All @@ -851,7 +851,7 @@ class Value {
break;
case VT_ARRAY:
a_buffer.append("[");
for (ArrayIter i = m_value.a->begin(); i != m_value.a->end(); i++) {
for (ArrayIter i = m_value.a->begin(); i != m_value.a->end(); ++i) {
if (i != m_value.a->begin())
a_buffer.append(",");
i->toStringRecurse(a_buffer);
Expand Down Expand Up @@ -883,7 +883,7 @@ class Value {

a_buffer.append("\"");

for (c = a_value.begin(); c != a_value.end(); c++) {
for (c = a_value.begin(); c != a_value.end(); ++c) {
if (*c < 0x20) {
a_buffer.append(a, c);
a = c + 1;
Expand Down
18 changes: 12 additions & 6 deletions common/source/DynaLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,43 @@ void Logger::addStream(std::ostream &stream) {

void Logger::trace(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::TRACE) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::TRACE)) {
output(LogLevel::TRACE, file, func, line_num, context, message);
}
}
void Logger::debug(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::DEBUG) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::DEBUG)) {
output(LogLevel::DEBUG, file, func, line_num, context, message);
}
}
void Logger::info(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::INFO) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::INFO)) {
output(LogLevel::INFO, file, func, line_num, context, message);
}
}
void Logger::warning(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::WARNING) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::WARNING)) {
output(LogLevel::WARNING, file, func, line_num, context, message);
}
}
void Logger::error(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::ERROR) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::ERROR)) {
output(LogLevel::ERROR, file, func, line_num, context, message);
}
}
void Logger::critical(std::string file, std::string func, int line_num,
const LogContext &context, const std::string &message) {
if (m_log_level >= LogLevel::CRITICAL) {
if (static_cast<unsigned int>(m_log_level) >=
static_cast<unsigned int>(LogLevel::CRITICAL)) {
output(LogLevel::CRITICAL, file, func, line_num, context, message);
}
}
Expand Down
6 changes: 3 additions & 3 deletions common/source/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ void hexDump(const char *a_buffer, const char *a_buffer_end, ostream &a_out) {
const unsigned char *e = (unsigned char *)a_buffer_end;
bool done = false;

int l = 0, i = 0;
int l = 0;
while (!done) {
a_out << setw(4) << dec << l << ": ";

for (i = 0; i < 16; ++i) {
for (int i = 0; i < 16; ++i) {
if (i == 8)
a_out << " ";

Expand All @@ -102,7 +102,7 @@ void hexDump(const char *a_buffer, const char *a_buffer_end, ostream &a_out) {

a_out << " ";

for (i = 0; i < 16; ++i) {
for (int i = 0; i < 16; ++i) {
if (p + i != e) {
if (isprint(*(p + i)))
a_out << *(p + i);
Expand Down
3 changes: 1 addition & 2 deletions common/source/communicators/ZeroMQCommunicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace SDMS {
class ZeroMQCommunicator : public ICommunicator {
protected:
std::unique_ptr<ISocket> m_socket;
uint16_t m_zmq_context;
void *m_zmq_socket = nullptr;
int m_zmq_socket_type;
void *m_zmq_ctx = nullptr;
Expand All @@ -43,7 +42,7 @@ class ZeroMQCommunicator : public ICommunicator {

public:
/** To be used by children*/
ZeroMQCommunicator(const LogContext &log_context)
explicit ZeroMQCommunicator(const LogContext &log_context)
: m_log_context(log_context){};

ZeroMQCommunicator(const SocketOptions &socket_options,
Expand Down
2 changes: 1 addition & 1 deletion common/source/servers/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void Proxy::run() {
// public
if (resp_from_client_socket.error == false and
resp_from_client_socket.time_out == false) {
if (not resp_from_server_socket.message) {
if (not resp_from_client_socket.message) {
DL_ERROR(
m_log_context,
"Proxy::run - Something is wrong, message "
Expand Down
6 changes: 3 additions & 3 deletions common/source/servers/ProxyBasicZMQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

namespace SDMS {

std::string sanitize(std::string val, const std::string pattern,
const std::string replacement) {
std::string sanitize(std::string val, const std::string &pattern,
const std::string &replacement) {
for (auto at = val.find(pattern, 0); at != std::string::npos;
at = val.find(pattern, at + replacement.length())) {

Expand Down Expand Up @@ -186,7 +186,7 @@ void ProxyBasicZMQ::run() {
* loop.
**/
auto terminate_call = [](std::chrono::duration<double> duration,
const std::string address, int thread_id,
const std::string &address, int thread_id,
LogContext log_context) {
log_context.thread_name += "-terminate_after_timeout";
log_context.thread_id = thread_id;
Expand Down
2 changes: 1 addition & 1 deletion common/tests/security/tcp_secure/test_tcp_secure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ echo "TIMEOUT: ${TIMEOUT_CMD}"
echo "MAX_TEST_TIME: ${MAX_TEST_TIME_SEC}"

# Grab the first 30 packets sent on the loop back interface (127.0.0.1) and port 7515
match=$( ${TIMEOUT_CMD} ${MAX_TEST_TIME_SEC} ${TCPDUMP_CMD} -vvv -A port 7515 -i lo | grep token)
match=$( "${TIMEOUT_CMD}" "${MAX_TEST_TIME_SEC}" "${TCPDUMP_CMD}" -vvv -A port 7515 -i lo | grep token)

echo "Content of grep ${match}"
# If '.magic_token' is returned from the network sniffer then we know that
Expand Down
9 changes: 9 additions & 0 deletions common/tests/unit/test_DynaLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ using namespace SDMS;

BOOST_AUTO_TEST_SUITE(LogTest)

BOOST_AUTO_TEST_CASE(testing_Enum) {
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::TRACE) == 5);
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::DEBUG) == 4);
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::INFO) == 3);
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::WARNING) == 2);
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::ERROR) == 1);
BOOST_CHECK(static_cast<unsigned int>(SDMS::LogLevel::CRITICAL) == 0);
}

BOOST_AUTO_TEST_CASE(testing_LogOutput) {

std::string file_name = "./log_output_test1.txt";
Expand Down
2 changes: 2 additions & 0 deletions common/tests/unit/test_ProtoBufMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ BOOST_AUTO_TEST_CASE(testing_ProtoBufFactory_ProtocolID) {

uint8_t proto_id =
proto_map.getProtocolID(MessageProtocol::GOOGLE_ANONONYMOUS);
BOOST_CHECK(proto_id == 1);
proto_id = proto_map.getProtocolID(MessageProtocol::GOOGLE_AUTHORIZED);
BOOST_CHECK(proto_id == 2);
}

BOOST_AUTO_TEST_CASE(testing_ProtoBufFactory) {
Expand Down
2 changes: 1 addition & 1 deletion common/tests/unit/test_SocketFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_SUITE(SocketFactoryTest)

class DummyCredential : public ICredentials {
public:
DummyCredential(const std::string &pub_key) : m_pub_key(pub_key){};
explicit DummyCredential(const std::string &pub_key) : m_pub_key(pub_key){};

private:
std::string m_pub_key = "";
Expand Down
Loading

0 comments on commit 57a2a65

Please sign in to comment.