This is an automated email from the ASF dual-hosted git repository.
laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new 71711592b refactor(security): Move security out of runtime (#1821)
71711592b is described below
commit 71711592b0ac5af1d63b1f7080b1e96324e57846
Author: Yingchun Lai <[email protected]>
AuthorDate: Mon Jan 8 17:43:14 2024 +0800
refactor(security): Move security out of runtime (#1821)
This is a pure refactor patch without any function changes.
The patch is aim to reduce the size and dependencies of security library,
mainly move the "security" out of "runtime", including:
- Add a test named "dsn_security_tests"
- Remove duplicate comments from **/CMakeLists.txt
---
.github/workflows/lint_and_test_cpp.yaml | 3 ++
src/CMakeLists.txt | 1 +
src/meta/meta_backup_service.cpp | 2 +-
src/meta/meta_service.h | 2 +-
src/meta/server_state.cpp | 2 +-
src/replica/replica.cpp | 2 +-
src/replica/replica_2pc.cpp | 2 +-
src/replica/replica_config.cpp | 2 +-
src/replica/replica_stub.cpp | 2 +-
src/replica/replica_stub.h | 2 +-
src/runtime/CMakeLists.txt | 4 +--
src/runtime/service_api_c.cpp | 5 ++-
src/{runtime => }/security/CMakeLists.txt | 27 +++++----------
src/{runtime => }/security/access_controller.cpp | 0
src/{runtime => }/security/access_controller.h | 0
src/{runtime => }/security/client_negotiation.cpp | 4 +--
src/{runtime => }/security/client_negotiation.h | 0
src/{runtime => }/security/init.cpp | 0
src/{runtime => }/security/init.h | 0
src/{runtime => }/security/kinit_context.cpp | 0
src/{runtime => }/security/kinit_context.h | 0
.../security/meta_access_controller.cpp | 0
.../security/meta_access_controller.h | 0
src/{runtime => }/security/negotiation.cpp | 2 +-
src/{runtime => }/security/negotiation.h | 0
src/{runtime => }/security/negotiation_manager.cpp | 2 +-
src/{runtime => }/security/negotiation_manager.h | 2 +-
src/{runtime => }/security/negotiation_utils.h | 0
.../security/replica_access_controller.cpp | 0
.../security/replica_access_controller.h | 0
src/{runtime => }/security/sasl_client_wrapper.cpp | 0
src/{runtime => }/security/sasl_client_wrapper.h | 0
src/{runtime => }/security/sasl_init.cpp | 0
src/{runtime => }/security/sasl_init.h | 0
src/{runtime => }/security/sasl_server_wrapper.cpp | 0
src/{runtime => }/security/sasl_server_wrapper.h | 0
src/{runtime => }/security/sasl_wrapper.cpp | 0
src/{runtime => }/security/sasl_wrapper.h | 0
src/{runtime => }/security/server_negotiation.cpp | 4 +--
src/{runtime => }/security/server_negotiation.h | 0
.../security => security/test}/CMakeLists.txt | 37 ++++++++------------
.../test/client_negotiation_test.cpp | 4 +--
src/security/test/config.ini | 24 +++++++++++++
.../test/main.cpp} | 39 ++++++++++++----------
.../test/meta_access_controller_test.cpp | 2 +-
.../test/negotiation_manager_test.cpp | 4 +--
.../test/replica_access_controller_test.cpp | 2 +-
.../CMakeLists.txt => security/test/run.sh} | 31 ++++-------------
.../test/server_negotiation_test.cpp | 6 ++--
49 files changed, 104 insertions(+), 115 deletions(-)
diff --git a/.github/workflows/lint_and_test_cpp.yaml
b/.github/workflows/lint_and_test_cpp.yaml
index a17121972..510508562 100644
--- a/.github/workflows/lint_and_test_cpp.yaml
+++ b/.github/workflows/lint_and_test_cpp.yaml
@@ -143,6 +143,7 @@ jobs:
- dsn.replication.simple_kv
- dsn.rep_tests.simple_kv
- dsn_runtime_tests
+ - dsn_security_tests
- dsn_utils_tests
- dsn.zookeeper.tests
# TODO(yingchun): Disable it because we find it's too flaky, we will
re-enable it after
@@ -223,6 +224,7 @@ jobs:
- dsn.replication.simple_kv
- dsn.rep_tests.simple_kv
- dsn_runtime_tests
+ - dsn_security_tests
- dsn_utils_tests
- dsn.zookeeper.tests
# TODO(yingchun): Disable it because we find it's too flaky, we will
re-enable it after
@@ -308,6 +310,7 @@ jobs:
# - dsn.replication.simple_kv
# - dsn.rep_tests.simple_kv
# - dsn_runtime_tests
+# - dsn_security_tests
# - dsn_utils_tests
# - dsn.zookeeper.tests
# - partition_split_test
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 253cb6cf6..1a9009877 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,6 +51,7 @@ add_subdirectory(remote_cmd)
add_subdirectory(replica)
add_subdirectory(runtime)
add_subdirectory(sample)
+add_subdirectory(security)
add_subdirectory(server)
add_subdirectory(server/test)
add_subdirectory(shell)
diff --git a/src/meta/meta_backup_service.cpp b/src/meta/meta_backup_service.cpp
index f132716b6..1f2879140 100644
--- a/src/meta/meta_backup_service.cpp
+++ b/src/meta/meta_backup_service.cpp
@@ -41,7 +41,7 @@
#include "runtime/rpc/rpc_holder.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "runtime/task/task_code.h"
#include "server_state.h"
diff --git a/src/meta/meta_service.h b/src/meta/meta_service.h
index d13415b6f..e46ad908b 100644
--- a/src/meta/meta_service.h
+++ b/src/meta/meta_service.h
@@ -51,7 +51,7 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/serverlet.h"
#include "runtime/task/task.h"
#include "runtime/task/task_code.h"
diff --git a/src/meta/server_state.cpp b/src/meta/server_state.cpp
index fde44e78e..89241f399 100644
--- a/src/meta/server_state.cpp
+++ b/src/meta/server_state.cpp
@@ -63,7 +63,7 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "runtime/task/task.h"
#include "runtime/task/task_spec.h"
diff --git a/src/replica/replica.cpp b/src/replica/replica.cpp
index 3274dc081..1286d7452 100644
--- a/src/replica/replica.cpp
+++ b/src/replica/replica.cpp
@@ -51,7 +51,7 @@
#include "replica_disk_migrator.h"
#include "replica_stub.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "split/replica_split_manager.h"
#include "utils/filesystem.h"
#include "utils/fmt_logging.h"
diff --git a/src/replica/replica_2pc.cpp b/src/replica/replica_2pc.cpp
index 084bba023..cf2f84df2 100644
--- a/src/replica/replica_2pc.cpp
+++ b/src/replica/replica_2pc.cpp
@@ -61,7 +61,7 @@
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/rpc_stream.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "runtime/task/task.h"
#include "runtime/task/task_code.h"
diff --git a/src/replica/replica_config.cpp b/src/replica/replica_config.cpp
index de14a2d12..bf2e07f50 100644
--- a/src/replica/replica_config.cpp
+++ b/src/replica/replica_config.cpp
@@ -61,7 +61,7 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "runtime/task/task.h"
#include "split/replica_split_manager.h"
diff --git a/src/replica/replica_stub.cpp b/src/replica/replica_stub.cpp
index 44c6e6bf4..f3167d32a 100644
--- a/src/replica/replica_stub.cpp
+++ b/src/replica/replica_stub.cpp
@@ -65,7 +65,7 @@
#include "ranger/access_type.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "split/replica_split_manager.h"
#include "utils/command_manager.h"
diff --git a/src/replica/replica_stub.h b/src/replica/replica_stub.h
index de158f992..08ae770a5 100644
--- a/src/replica/replica_stub.h
+++ b/src/replica/replica_stub.h
@@ -56,7 +56,7 @@
#include "ranger/access_type.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_holder.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/serverlet.h"
#include "runtime/task/task.h"
#include "runtime/task/task_code.h"
diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt
index ac98bfc5d..6527ffb17 100644
--- a/src/runtime/CMakeLists.txt
+++ b/src/runtime/CMakeLists.txt
@@ -25,11 +25,9 @@
add_subdirectory(test)
add_subdirectory(rpc)
add_subdirectory(task)
-add_subdirectory(security)
# TODO(zlw) remove perf_counter from dsn_runtime after the refactor by WuTao
add_library(dsn_runtime STATIC
- $<TARGET_OBJECTS:dsn.security>
$<TARGET_OBJECTS:dsn.rpc>
$<TARGET_OBJECTS:dsn.task>
$<TARGET_OBJECTS:dsn.perf_counter>
@@ -50,6 +48,6 @@ add_library(dsn_runtime STATIC
tool_api.cpp
tracer.cpp
zlocks.cpp)
-target_link_libraries(dsn_runtime PRIVATE dsn_utils sasl2 gssapi_krb5 krb5)
+target_link_libraries(dsn_runtime PRIVATE dsn_security dsn_utils sasl2
gssapi_krb5 krb5)
define_file_basename_for_sources(dsn_runtime)
install(TARGETS dsn_runtime DESTINATION "lib")
diff --git a/src/runtime/service_api_c.cpp b/src/runtime/service_api_c.cpp
index 9db79e2f9..271037aaf 100644
--- a/src/runtime/service_api_c.cpp
+++ b/src/runtime/service_api_c.cpp
@@ -52,8 +52,8 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_engine.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/init.h"
-#include "runtime/security/negotiation_manager.h"
+#include "security/init.h"
+#include "security/negotiation_manager.h"
#include "runtime/service_app.h"
#include "runtime/service_engine.h"
#include "runtime/task/task.h"
@@ -82,7 +82,6 @@ DSN_DEFINE_bool(core,
pause_on_start,
false,
"whether to pause at startup time for easier debugging");
-
#ifdef DSN_ENABLE_GPERF
DSN_DEFINE_double(core,
tcmalloc_release_rate,
diff --git a/src/runtime/security/CMakeLists.txt b/src/security/CMakeLists.txt
similarity index 72%
copy from src/runtime/security/CMakeLists.txt
copy to src/security/CMakeLists.txt
index 02075bde9..e996d2ebc 100644
--- a/src/runtime/security/CMakeLists.txt
+++ b/src/security/CMakeLists.txt
@@ -15,28 +15,17 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME dsn.security)
-
+set(MY_PROJ_NAME dsn_security)
thrift_generate_cpp(
SECURITY_THRIFT_SRCS
SECURITY_THRIFT_HDRS
- ${PROJECT_ROOT}/idl/security.thrift
-)
-
+ ${PROJECT_ROOT}/idl/security.thrift)
set(MY_PROJ_SRC ${SECURITY_THRIFT_SRCS})
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_INC_PATH "")
-
-set(MY_PROJ_LIBS "")
-
-set(MY_PROJ_LIB_PATH "")
-
-# Extra files that will be installed
-set(MY_BINPLACES "")
-
+set(MY_PROJ_LIBS
+ dsn_meta_server
+ dsn_replication_common
+ dsn_runtime
+ dsn_utils)
dsn_add_object()
+add_subdirectory(test)
diff --git a/src/runtime/security/access_controller.cpp
b/src/security/access_controller.cpp
similarity index 100%
rename from src/runtime/security/access_controller.cpp
rename to src/security/access_controller.cpp
diff --git a/src/runtime/security/access_controller.h
b/src/security/access_controller.h
similarity index 100%
rename from src/runtime/security/access_controller.h
rename to src/security/access_controller.h
diff --git a/src/runtime/security/client_negotiation.cpp
b/src/security/client_negotiation.cpp
similarity index 98%
rename from src/runtime/security/client_negotiation.cpp
rename to src/security/client_negotiation.cpp
index bd8946faa..9d19b82fb 100644
--- a/src/runtime/security/client_negotiation.cpp
+++ b/src/security/client_negotiation.cpp
@@ -28,8 +28,8 @@
#include "negotiation_utils.h"
#include "runtime/rpc/network.h"
#include "runtime/rpc/rpc_address.h"
-#include "runtime/security/negotiation.h"
-#include "runtime/security/sasl_wrapper.h"
+#include "security/negotiation.h"
+#include "security/sasl_wrapper.h"
#include "utils/autoref_ptr.h"
#include "utils/error_code.h"
#include "utils/errors.h"
diff --git a/src/runtime/security/client_negotiation.h
b/src/security/client_negotiation.h
similarity index 100%
rename from src/runtime/security/client_negotiation.h
rename to src/security/client_negotiation.h
diff --git a/src/runtime/security/init.cpp b/src/security/init.cpp
similarity index 100%
rename from src/runtime/security/init.cpp
rename to src/security/init.cpp
diff --git a/src/runtime/security/init.h b/src/security/init.h
similarity index 100%
rename from src/runtime/security/init.h
rename to src/security/init.h
diff --git a/src/runtime/security/kinit_context.cpp
b/src/security/kinit_context.cpp
similarity index 100%
rename from src/runtime/security/kinit_context.cpp
rename to src/security/kinit_context.cpp
diff --git a/src/runtime/security/kinit_context.h b/src/security/kinit_context.h
similarity index 100%
rename from src/runtime/security/kinit_context.h
rename to src/security/kinit_context.h
diff --git a/src/runtime/security/meta_access_controller.cpp
b/src/security/meta_access_controller.cpp
similarity index 100%
rename from src/runtime/security/meta_access_controller.cpp
rename to src/security/meta_access_controller.cpp
diff --git a/src/runtime/security/meta_access_controller.h
b/src/security/meta_access_controller.h
similarity index 100%
rename from src/runtime/security/meta_access_controller.h
rename to src/security/meta_access_controller.h
diff --git a/src/runtime/security/negotiation.cpp b/src/security/negotiation.cpp
similarity index 98%
rename from src/runtime/security/negotiation.cpp
rename to src/security/negotiation.cpp
index a63d9cb61..e8a615b6e 100644
--- a/src/runtime/security/negotiation.cpp
+++ b/src/security/negotiation.cpp
@@ -21,7 +21,7 @@
#include "client_negotiation.h"
#include "negotiation_utils.h"
-#include "runtime/security/sasl_wrapper.h"
+#include "security/sasl_wrapper.h"
#include "server_negotiation.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
diff --git a/src/runtime/security/negotiation.h b/src/security/negotiation.h
similarity index 100%
rename from src/runtime/security/negotiation.h
rename to src/security/negotiation.h
diff --git a/src/runtime/security/negotiation_manager.cpp
b/src/security/negotiation_manager.cpp
similarity index 99%
rename from src/runtime/security/negotiation_manager.cpp
rename to src/security/negotiation_manager.cpp
index d289732dc..4f7105049 100644
--- a/src/runtime/security/negotiation_manager.cpp
+++ b/src/security/negotiation_manager.cpp
@@ -71,7 +71,7 @@ void
negotiation_manager::on_negotiation_request(negotiation_rpc rpc)
"only server session receives negotiation request");
// reply SASL_AUTH_DISABLE if auth is not enable
- if (!security::FLAGS_enable_auth) {
+ if (!FLAGS_enable_auth) {
rpc.response().status = negotiation_status::type::SASL_AUTH_DISABLE;
return;
}
diff --git a/src/runtime/security/negotiation_manager.h
b/src/security/negotiation_manager.h
similarity index 98%
rename from src/runtime/security/negotiation_manager.h
rename to src/security/negotiation_manager.h
index 25864f802..e3f6bebd5 100644
--- a/src/runtime/security/negotiation_manager.h
+++ b/src/security/negotiation_manager.h
@@ -20,7 +20,7 @@
#include <memory>
#include <unordered_map>
-#include "runtime/security/negotiation.h"
+#include "security/negotiation.h"
#include "runtime/serverlet.h"
#include "utils/singleton.h"
diff --git a/src/runtime/security/negotiation_utils.h
b/src/security/negotiation_utils.h
similarity index 100%
rename from src/runtime/security/negotiation_utils.h
rename to src/security/negotiation_utils.h
diff --git a/src/runtime/security/replica_access_controller.cpp
b/src/security/replica_access_controller.cpp
similarity index 100%
rename from src/runtime/security/replica_access_controller.cpp
rename to src/security/replica_access_controller.cpp
diff --git a/src/runtime/security/replica_access_controller.h
b/src/security/replica_access_controller.h
similarity index 100%
rename from src/runtime/security/replica_access_controller.h
rename to src/security/replica_access_controller.h
diff --git a/src/runtime/security/sasl_client_wrapper.cpp
b/src/security/sasl_client_wrapper.cpp
similarity index 100%
rename from src/runtime/security/sasl_client_wrapper.cpp
rename to src/security/sasl_client_wrapper.cpp
diff --git a/src/runtime/security/sasl_client_wrapper.h
b/src/security/sasl_client_wrapper.h
similarity index 100%
rename from src/runtime/security/sasl_client_wrapper.h
rename to src/security/sasl_client_wrapper.h
diff --git a/src/runtime/security/sasl_init.cpp b/src/security/sasl_init.cpp
similarity index 100%
rename from src/runtime/security/sasl_init.cpp
rename to src/security/sasl_init.cpp
diff --git a/src/runtime/security/sasl_init.h b/src/security/sasl_init.h
similarity index 100%
rename from src/runtime/security/sasl_init.h
rename to src/security/sasl_init.h
diff --git a/src/runtime/security/sasl_server_wrapper.cpp
b/src/security/sasl_server_wrapper.cpp
similarity index 100%
rename from src/runtime/security/sasl_server_wrapper.cpp
rename to src/security/sasl_server_wrapper.cpp
diff --git a/src/runtime/security/sasl_server_wrapper.h
b/src/security/sasl_server_wrapper.h
similarity index 100%
copy from src/runtime/security/sasl_server_wrapper.h
copy to src/security/sasl_server_wrapper.h
diff --git a/src/runtime/security/sasl_wrapper.cpp
b/src/security/sasl_wrapper.cpp
similarity index 100%
rename from src/runtime/security/sasl_wrapper.cpp
rename to src/security/sasl_wrapper.cpp
diff --git a/src/runtime/security/sasl_wrapper.h b/src/security/sasl_wrapper.h
similarity index 100%
rename from src/runtime/security/sasl_wrapper.h
rename to src/security/sasl_wrapper.h
diff --git a/src/runtime/security/server_negotiation.cpp
b/src/security/server_negotiation.cpp
similarity index 98%
rename from src/runtime/security/server_negotiation.cpp
rename to src/security/server_negotiation.cpp
index 373dd2e7e..b85edca63 100644
--- a/src/runtime/security/server_negotiation.cpp
+++ b/src/security/server_negotiation.cpp
@@ -24,8 +24,8 @@
#include "fmt/format.h"
#include "runtime/rpc/network.h"
#include "runtime/rpc/rpc_address.h"
-#include "runtime/security/negotiation.h"
-#include "runtime/security/sasl_wrapper.h"
+#include "security/negotiation.h"
+#include "security/sasl_wrapper.h"
#include "security_types.h"
#include "utils/autoref_ptr.h"
#include "utils/blob.h"
diff --git a/src/runtime/security/server_negotiation.h
b/src/security/server_negotiation.h
similarity index 100%
rename from src/runtime/security/server_negotiation.h
rename to src/security/server_negotiation.h
diff --git a/src/runtime/security/CMakeLists.txt
b/src/security/test/CMakeLists.txt
similarity index 63%
copy from src/runtime/security/CMakeLists.txt
copy to src/security/test/CMakeLists.txt
index 02075bde9..b5725a530 100644
--- a/src/runtime/security/CMakeLists.txt
+++ b/src/security/test/CMakeLists.txt
@@ -15,28 +15,17 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME dsn.security)
-
-thrift_generate_cpp(
- SECURITY_THRIFT_SRCS
- SECURITY_THRIFT_HDRS
- ${PROJECT_ROOT}/idl/security.thrift
-)
-
-set(MY_PROJ_SRC ${SECURITY_THRIFT_SRCS})
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
+set(MY_PROJ_NAME dsn_security_tests)
+set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_INC_PATH "")
-
-set(MY_PROJ_LIBS "")
-
-set(MY_PROJ_LIB_PATH "")
-
-# Extra files that will be installed
-set(MY_BINPLACES "")
-
-dsn_add_object()
+set(MY_PROJ_LIBS
+ dsn_security
+ dsn_meta_server
+ dsn_replication_common
+ dsn_runtime
+ dsn_utils
+ gtest)
+set(MY_BINPLACES
+ config.ini
+ run.sh)
+dsn_add_test()
diff --git a/src/runtime/test/client_negotiation_test.cpp
b/src/security/test/client_negotiation_test.cpp
similarity index 98%
rename from src/runtime/test/client_negotiation_test.cpp
rename to src/security/test/client_negotiation_test.cpp
index a60832ef7..a22a1d171 100644
--- a/src/runtime/test/client_negotiation_test.cpp
+++ b/src/security/test/client_negotiation_test.cpp
@@ -24,8 +24,8 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_holder.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/client_negotiation.h"
-#include "runtime/security/negotiation.h"
+#include "security/client_negotiation.h"
+#include "security/negotiation.h"
#include "security_types.h"
#include "utils/blob.h"
#include "utils/error_code.h"
diff --git a/src/security/test/config.ini b/src/security/test/config.ini
new file mode 100644
index 000000000..e0c1f4590
--- /dev/null
+++ b/src/security/test/config.ini
@@ -0,0 +1,24 @@
+; 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.
+
+[apps.client]
+type = test
+arguments = localhost 20101
+pools = THREAD_POOL_DEFAULT
+
+[core]
+tool = nativerun
diff --git a/src/runtime/security/sasl_server_wrapper.h
b/src/security/test/main.cpp
similarity index 59%
rename from src/runtime/security/sasl_server_wrapper.h
rename to src/security/test/main.cpp
index 960336bef..0edcfcaa1 100644
--- a/src/runtime/security/sasl_server_wrapper.h
+++ b/src/security/test/main.cpp
@@ -15,26 +15,29 @@
// specific language governing permissions and limitations
// under the License.
-#pragma once
+#include <chrono>
+#include <gtest/gtest.h>
+#include <thread>
-#include <string>
+#include "runtime/app_model.h"
+#include "runtime/service_app.h"
+#include "runtime/test_utils.h"
-#include "sasl_wrapper.h"
-#include "utils/errors.h"
+int g_test_count = 0;
+int g_test_ret = 0;
-namespace dsn {
-class blob;
-
-namespace security {
-class sasl_server_wrapper : public sasl_wrapper
+GTEST_API_ int main(int argc, char **argv)
{
-public:
- sasl_server_wrapper() = default;
- ~sasl_server_wrapper() = default;
+ testing::InitGoogleTest(&argc, argv);
+
+ dsn::service_app::register_factory<test_client>("test");
+ dsn_run(argc, argv, false);
+ while (g_test_count == 0) {
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
- error_s init();
- error_s start(const std::string &mechanism, const blob &input, blob
&output);
- error_s step(const blob &input, blob &output);
-};
-} // namespace security
-} // namespace dsn
+#ifndef ENABLE_GCOV
+ dsn_exit(g_test_ret);
+#endif
+ return g_test_ret;
+}
diff --git a/src/runtime/test/meta_access_controller_test.cpp
b/src/security/test/meta_access_controller_test.cpp
similarity index 98%
rename from src/runtime/test/meta_access_controller_test.cpp
rename to src/security/test/meta_access_controller_test.cpp
index bdec097b8..31d1368a0 100644
--- a/src/runtime/test/meta_access_controller_test.cpp
+++ b/src/security/test/meta_access_controller_test.cpp
@@ -25,7 +25,7 @@
#include "runtime/rpc/network.sim.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/access_controller.h"
+#include "security/access_controller.h"
#include "runtime/task/task_code.h"
#include "utils/autoref_ptr.h"
#include "utils/flags.h"
diff --git a/src/runtime/test/negotiation_manager_test.cpp
b/src/security/test/negotiation_manager_test.cpp
similarity index 98%
rename from src/runtime/test/negotiation_manager_test.cpp
rename to src/security/test/negotiation_manager_test.cpp
index 401f63b57..eafb3edc3 100644
--- a/src/runtime/test/negotiation_manager_test.cpp
+++ b/src/security/test/negotiation_manager_test.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "runtime/security/negotiation_manager.h"
+#include "security/negotiation_manager.h"
#include "failure_detector/fd.code.definition.h"
#include "gtest/gtest.h"
@@ -26,7 +26,7 @@
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_holder.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/negotiation_utils.h"
+#include "security/negotiation_utils.h"
#include "runtime/task/task_code.h"
#include "security_types.h"
#include "utils/autoref_ptr.h"
diff --git a/src/runtime/test/replica_access_controller_test.cpp
b/src/security/test/replica_access_controller_test.cpp
similarity index 98%
rename from src/runtime/test/replica_access_controller_test.cpp
rename to src/security/test/replica_access_controller_test.cpp
index b0d17da75..37f186b00 100644
--- a/src/runtime/test/replica_access_controller_test.cpp
+++ b/src/security/test/replica_access_controller_test.cpp
@@ -27,7 +27,7 @@
#include "runtime/rpc/network.sim.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_message.h"
-#include "runtime/security/replica_access_controller.h"
+#include "security/replica_access_controller.h"
#include "utils/autoref_ptr.h"
#include "utils/flags.h"
diff --git a/src/runtime/security/CMakeLists.txt b/src/security/test/run.sh
old mode 100644
new mode 100755
similarity index 60%
rename from src/runtime/security/CMakeLists.txt
rename to src/security/test/run.sh
index 02075bde9..4d756ca52
--- a/src/runtime/security/CMakeLists.txt
+++ b/src/security/test/run.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
# 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
@@ -15,28 +16,10 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME dsn.security)
+if [ -z "${REPORT_DIR}" ]; then
+ REPORT_DIR="."
+fi
-thrift_generate_cpp(
- SECURITY_THRIFT_SRCS
- SECURITY_THRIFT_HDRS
- ${PROJECT_ROOT}/idl/security.thrift
-)
-
-set(MY_PROJ_SRC ${SECURITY_THRIFT_SRCS})
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
-set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_INC_PATH "")
-
-set(MY_PROJ_LIBS "")
-
-set(MY_PROJ_LIB_PATH "")
-
-# Extra files that will be installed
-set(MY_BINPLACES "")
-
-dsn_add_object()
+rm -rf data dsn_security_tests.xml
+output_xml="${REPORT_DIR}/dsn_security_tests.xml"
+GTEST_OUTPUT="xml:${output_xml}" ./dsn_security_tests config.ini
diff --git a/src/runtime/test/server_negotiation_test.cpp
b/src/security/test/server_negotiation_test.cpp
similarity index 98%
rename from src/runtime/test/server_negotiation_test.cpp
rename to src/security/test/server_negotiation_test.cpp
index fce5fdfd8..99e57145a 100644
--- a/src/runtime/test/server_negotiation_test.cpp
+++ b/src/security/test/server_negotiation_test.cpp
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include "runtime/security/server_negotiation.h"
+#include "security/server_negotiation.h"
#include <memory>
#include <utility>
@@ -24,8 +24,8 @@
#include "runtime/rpc/network.sim.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_holder.h"
-#include "runtime/security/negotiation.h"
-#include "runtime/security/negotiation_utils.h"
+#include "security/negotiation.h"
+#include "security/negotiation_utils.h"
#include "security_types.h"
#include "utils/blob.h"
#include "utils/fail_point.h"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]