#include <unistd.h>
#endif
-#include <string>
-#include <map>
-#include <vector>
-#include <memory>
#include <algorithm>
#include <UnitTestHelper.h>
#include <gtest/gtest.h>
#include <HippoMocks/hippomocks.h>
-#include "Configuration.h"
-#include "BundleActivator.h"
-#include "BundleResource.h"
#include "RCSResourceContainer.h"
-#include "ResourceContainerBundleAPI.h"
#include "ResourceContainerImpl.h"
-#include "RemoteResourceUnit.h"
+#include "SoftSensorResource.h"
#include "RCSResourceObject.h"
#include "RCSRemoteResourceObject.h"
-#include "SoftSensorResource.h"
#include "ResourceContainerTestSimulator.h"
ptr->startMonitoring();
}
+#ifdef SECURED
+TEST_F(RemoteResourceUnitTest, DISABLED_onCacheCBCalled)
+#else
TEST_F(RemoteResourceUnitTest, onCacheCBCalled)
+#endif
{
bool isCalled = false;
mocks.ExpectCallFunc(onCacheCB).Do(
if lib_env.get('LOGGING'):
lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-
-
-
# Add third party libraries
SConscript(src_dir + '/service/third_party_libs.scons', 'lib_env')
print ''
if container_gtest_env.get('SECURED') == '1':
- if container_gtest_env.get('WITH_TCP') == True:
- container_gtest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
+ container_gtest_env.AppendUnique(CPPDEFINES = ['SECURED'])
+ if container_gtest_env.get('WITH_TCP') == True:
+ container_gtest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
container_gtest_env.AppendUnique(LIBS = ['resource_directory'])
######################################################################
# Build Test
######################################################################
-container_gtest_src = container_gtest_env.Glob('./*.cpp')
+if 'g++' in container_gtest_env.get('CXX'):
+ container_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
+
+container_gtest_src = container_gtest_env.Glob('./ResourceContainerTest.cpp')
container_test = container_gtest_env.Program('container_test', container_gtest_src)
Alias("container_test", container_test)
constexpr char RESOURCE_TYPE[]{ "resource.type" };
constexpr char SECOND_RESOURCETYPE[]{ "resource.type.second" };
+#ifdef SECURED
+const char * SVR_DB_FILE_NAME = "./oic_svr_db_re_client.dat";
+//OCPersistent Storage Handlers
+static FILE* client_open(const char * /*path*/, const char *mode)
+{
+ std::string file_name = SVR_DB_FILE_NAME;
+#ifndef LOCAL_RUNNING
+ file_name = "./service/resource-encapsulation/unittests/oic_svr_db_re_client.dat";
+#endif
+ return fopen(file_name.c_str(), mode);
+}
+#endif
+
void onResourceDiscovered(RCSRemoteResourceObject::Ptr)
{
TEST(DiscoveryManagerTest, ThrowIfDiscoverWithEmptyCallback)
{
+#ifdef SECURED
+ OCPersistentStorage gps {client_open, fread, fwrite, fclose, unlink };
+ OC::PlatformConfig cfg
+ { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0,
+ OC::QualityOfService::LowQos, &gps };
+ OC::OCPlatform::Configure(cfg);
+#endif
+
EXPECT_THROW(RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(), { }),
RCSInvalidParameterException);
}
'rcs_common'])
if lib_env.get('SECURED') == '1':
- if lib_env.get('WITH_TCP') == True:
- rcs_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
+ rcs_test_env.AppendUnique(CPPDEFINES = ['SECURED'])
+ if lib_env.get('WITH_TCP') == True:
+ rcs_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
+
+if 'g++' in rcs_test_env.get('CXX'):
+ rcs_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
######################################################################
# Build Test
# TODO: fix this test on linux and remove commented lines
if rcs_test_env.get('TEST') == '1':
- target_os = rcs_test_env.get('TARGET_OS')
- if target_os in ['linux'] and rcs_test_env.get('SECURED') != '1':
+ if target_os in ['linux']:
from tools.scons.RunTest import run_test
run_test(rcs_test_env,
# 'service_resource-encapsulation_unittests_rcs_client_test.memcheck',
'',
- 'service/resource-encapsulation/unittests/rcs_client_test',
- rcs_client_test)
+ 'service/resource-encapsulation/unittests/rcs_client_test')
+else:
+ rcs_test_env.AppendUnique(CPPDEFINES = ['LOCAL_RUNNING'])
+ if lib_env.get('SECURED') == '1':
+ src_dir = rcs_test_env.get('SRC_DIR')
+ svr_db_src_dir = os.path.join(src_dir, 'service/resource-encapsulation/unittests/')
+ svr_db_build_dir = os.path.join(rcs_test_env.get('BUILD_DIR'), 'service', 'resource-encapsulation', 'unittests') + os.sep
+ rcs_test_env.Alias("install",
+ rcs_test_env.Install(svr_db_build_dir,
+ os.path.join(svr_db_src_dir,
+ 'oic_svr_db_re_client.dat')))
--- /dev/null
+{
+ "acl": {
+ "aclist": {
+ "aces": [
+ {
+ "subjectuuid": "*",
+ "resources": [
+ {
+ "href": "/oic/res",
+ "rel": "",
+ "rt": ["oic.wk.res"],
+ "if": ["oic.if.ll"]
+ },
+ {
+ "href": "/oic/d",
+ "rel": "",
+ "rt": ["oic.wk.d"],
+ "if": ["oic.if.baseline", "oic.if.r"]
+ },
+ {
+ "href": "/oic/p",
+ "rel": "",
+ "rt": ["oic.wk.p"],
+ "if": ["oic.if.baseline", "oic.if.r"]
+ },
+ {
+ "href": "/oic/sec/acl",
+ "rel": "",
+ "rt": ["oic.r.acl"],
+ "if": ["oic.if.baseline"]
+ },
+ {
+ "href": "/a/TemperatureSensor",
+ "rel": "",
+ "rt": ["resource.type"],
+ "if": ["oic.if.baseline"]
+ }
+ ],
+ "permission": 2
+ },
+ {
+ "subjectuuid": "*",
+ "resources": [
+ {
+ "href": "/oic/sec/doxm",
+ "rel": "",
+ "rt": ["oic.r.doxm"],
+ "if": ["oic.if.baseline"]
+ },
+ {
+ "href": "/oic/sec/pstat",
+ "rel": "",
+ "rt": ["oic.r.pstat"],
+ "if": ["oic.if.baseline"]
+ }
+ ],
+ "permission": 2
+ },
+ {
+ "subjectuuid": "*",
+ "resources": [
+ {
+ "href": "/a/TemperatureSensor",
+ "rel": "",
+ "rt": ["resource.type"],
+ "if": ["oic.if.baseline"]
+ }
+ ],
+ "permission": 6
+ }
+ ]
+ },
+ "rowneruuid" : "32323232-3232-3232-3232-323232323232"
+ },
+ "pstat": {
+ "isop": true,
+ "deviceuuid": "32323232-3232-3232-3232-323232323232",
+ "rowneruuid": "32323232-3232-3232-3232-323232323232",
+ "cm": 0,
+ "tm": 0,
+ "om": 4,
+ "sm": 4
+ },
+ "doxm": {
+ "oxms": [0],
+ "oxmsel": 0,
+ "sct": 1,
+ "owned": true,
+ "deviceuuid": "32323232-3232-3232-3232-323232323232",
+ "devowneruuid": "32323232-3232-3232-3232-323232323232",
+ "rowneruuid": "32323232-3232-3232-3232-323232323232"
+ },
+ "cred": {
+ "creds": [
+ {
+ "credid": 1,
+ "subjectuuid": "31313131-3131-3131-3131-313131313131",
+ "credtype": 1,
+ "privatedata": {
+ "data": "AAAAAAAAAAAAAAAA",
+ "encoding": "oic.sec.encoding.raw"
+ }
+ }
+ ],
+ "rowneruuid": "32323232-3232-3232-3232-323232323232"
+ }
+}