Add API tests for new DCM EXT API 03/256103/9 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/6.5/unified/20211028.123926 accepted/tizen/7.0/unified/20221110.060250 accepted/tizen/7.0/unified/hotfix/20221116.105531 accepted/tizen/unified/20210422.005302 submit/tizen/20210419.104558 submit/tizen/20210421.104924 submit/tizen_6.5/20211028.162401 tizen_6.5.m2_release tizen_7.0_m2_release
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 29 Mar 2021 09:09:01 +0000 (11:09 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 1 Apr 2021 12:00:00 +0000 (14:00 +0200)
Change-Id: If68e66bd129cc0d567979243c743a5fbab640a21

tests/CMakeLists.txt
tests/api_test.cpp

index fac6b20..bb459c9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2020 - 2021 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -64,6 +64,7 @@ ADD_EXECUTABLE(${TARGET_TESTS}
        colour_log_formatter.cpp
        ../src/dcm-client/dcm_client.cpp
        ../src/dcm-client/device_certificate_manager.cpp
+       ../src/dcm-client/device_certificate_manager_ext.cpp
        ../src/shared/log.cpp
        ../src/shared/protobuf_asio.cpp
        ${PROTO_SRCS}
index 65aa90c..eb1aa73 100644 (file)
@@ -23,6 +23,7 @@
 #include <boost/algorithm/hex.hpp>
 
 #include "device_certificate_manager.h"
+#include "device_certificate_manager_ext.h"
 #include "test_macros.h"
 
 BOOST_AUTO_TEST_SUITE(API_TEST)
@@ -186,4 +187,34 @@ POSITIVE_TEST_CASE(test05_dcm_create_signature)
     free(signature);
 }
 
+NEGATIVE_TEST_CASE(test06_dcm_ext_api_invalid_params_on_client_side)
+{
+    int ret = dcm_ext_call_api(NULL, NULL, 0, NULL, NULL);
+    BOOST_REQUIRE_EQUAL(ret, DCM_EXT_ERROR_INVALID_PARAMETER);
+}
+
+NEGATIVE_TEST_CASE(test07_dcm_ext_api_invalid_method_name)
+{
+    int ret = dcm_ext_call_api("method-not-existing", NULL, 0, NULL, NULL);
+    BOOST_REQUIRE_EQUAL(ret, DCM_EXT_ERROR_INVALID_PARAMETER);
+}
+
+NEGATIVE_TEST_CASE(test08_dcm_ext_api_no_privilege)
+{
+    int ret = dcm_ext_call_api("method-with-a-privilege-not-granted", NULL, 0, NULL, NULL);
+    BOOST_REQUIRE_EQUAL(ret, DCM_EXT_ERROR_PERMISSION_DENIED);
+}
+
+POSITIVE_TEST_CASE(test09_dcm_ext_api_normal_call)
+{
+    size_t out_size;
+    char* output = NULL;
+    int input = 5;
+    int ret = dcm_ext_call_api("square-int-method", (char*)&input, sizeof(input), &output , &out_size);
+    BOOST_REQUIRE_EQUAL(ret, DCM_EXT_ERROR_NONE);
+    BOOST_REQUIRE_EQUAL(out_size, sizeof(int));
+    BOOST_REQUIRE_EQUAL((int)(*output), 25);
+    free(output);
+}
+
 BOOST_AUTO_TEST_SUITE_END()