Commit a05a151f authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko Committed by Aleksey

the security unit tests

the security unit tests with coverage more 75%

Change-Id: Ia84e693fc00e2e7da9ce83cd845fced011fc8d43
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent 18e3b8fe
......@@ -142,6 +142,7 @@ if target_os not in ['windows', 'winrt']:
'-fdata-sections', '-fno-exceptions'])
if target_os == 'msys_nt':
libcoap_env.Replace(CCFLAGS = str(libcoap_env['CCFLAGS']).replace('/WX',''))
libcoap_env.AppendUnique(CPPDEFINES=['_DEFAULT_SOURCE'])
libcoap_env.AppendUnique(CFLAGS=['-std=c99'])
......
......@@ -27,7 +27,6 @@ Import('test_env')
# SConscript file for Local PKI google tests
srmtest_env = test_env.Clone()
target_os = srmtest_env.get('TARGET_OS')
rd_mode = srmtest_env.get('RD_MODE')
######################################################################
# Build flags
......@@ -51,21 +50,27 @@ srmtest_env.PrependUnique(CPPPATH=[
'../../stack/include/internal',
'../../../oc_logger/include',
'../provisioning/include',
'../include'
'../include',
'#resource/csdk/security/include/experimental',
'#resource/csdk/security/provisioning/include/internal',
'#resource/csdk/logger/include/experimental',
'#resource/csdk/connectivity/common/inc',
'#resource/csdk/security/src',
'#extlibs/mbedtls/mbedtls/include',
'#resource/csdk/security/provisioning/include/cloud'
])
srmtest_env.PrependUnique(LIBS=[
'octbstack_internal',
'ocsrm',
'routingmanager',
'oc_logger_internal',
'connectivity_abstraction_internal',
'coap'
'coap',
'ocpmapi_internal',
'ocsrm',
'mbedtls', 'mbedx509', 'mbedcrypto'
])
if srmtest_env.get('SECURED') == '1':
srmtest_env.AppendUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
if srmtest_env.get('LOGGING') == '1':
srmtest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
......@@ -73,6 +78,7 @@ if srmtest_env.get('MULTIPLE_OWNER') == '1':
srmtest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
if target_os == 'windows':
# srmtest_env.Replace(CCFLAGS = str(srmtest_env['CCFLAGS']).replace('/WX',''))
srmtest_env.AppendUnique(LIBS=['sqlite3'])
#Disable deprecated code warning we are still testing deprecated functions till they are removed.
srmtest_env.AppendUnique(CCFLAGS=['/wd4996'])
......@@ -88,35 +94,37 @@ else:
######################################################################
# Source files and Targets
######################################################################
unittests = []
unittests_src = []
unittests_src += [
'aclresourcetest.cpp',
'amaclresourcetest.cpp',
'pstatresource.cpp',
'doxmresource.cpp',
'policyengine.cpp',
'securityresourcemanager.cpp',
'credentialresource.cpp',
'spresource.cpp',
'srmutility.cpp',
'iotvticalendartest.cpp',
'base64tests.cpp',
'pbkdf2tests.cpp',
'srmtestcommon.cpp',
'crlresourcetest.cpp',
'ocsecurity.cpp',
'certhelpers.cpp'
unittests_src = [
'tools.cpp',
'aclresourcetest.cpp',
'amaclresourcetest.cpp',
'pstatresource.cpp',
'doxmresource.cpp',
'policyengine.cpp',
'securityresourcemanager.cpp',
'credentialresource.cpp',
'spresource.cpp',
'srmutility.cpp',
'iotvticalendartest.cpp',
'base64tests.cpp',
'pbkdf2tests.cpp',
'crlresourcetest.cpp',
'ocsecurity.cpp',
'certhelpers.cpp',
'deviceonboardingstate.cpp',
'occertutility.cpp',
'pkix_interface.cpp',
'srmtestcommon.cpp',
'csrresource.cpp'
]
if target_os not in ['msys_nt', 'windows']:
unittests_src += [
'oxmpincommon.cpp',
'oxmverifycommon.cpp'
'oxmverifycommon.cpp',
'rolesresource.cpp'
]
unittests += srmtest_env.Program('unittest', unittests_src)
# this path will be passed as a command-line parameter,
# so needs encoding to avoid problems with escapes on Windows
unittest_build_dir = Dir('.').abspath + os.sep
......@@ -130,20 +138,20 @@ srmtest_env.AppendUnique(CPPDEFINES=[
'SECURITY_BUILD_UNITTEST_DIR=' + unittest_build_dir
])
unittests += srmtest_env.ScanJSON('resource/csdk/security/unittest')
srmtest_env.AppendTarget('test')
if srmtest_env.get('TEST') == '1':
if target_os in ['linux', 'windows']:
out_dir = srmtest_env.get('BUILD_DIR')
result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:' + result_dir])
srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
run_test(srmtest_env,
if srmtest_env.get('TEST') == '1' and target_os in ['linux', 'windows']:
unittests = srmtest_env.Program('unittest', unittests_src)
unittests += srmtest_env.ScanJSON('resource/csdk/security/unittest')
out_dir = srmtest_env.get('BUILD_DIR')
result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:' + result_dir])
srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
run_test(srmtest_env,
'resource_csdk_security_unittest.memcheck',
'resource/csdk/security/unittest/unittest')
srmtest_env.UserInstallTargetExtra(unittests, 'tests/resource/csdk/security/')
srmtest_env.UserInstallTargetExtra(unittests, 'tests/resource/csdk/security/')
......@@ -19,25 +19,53 @@
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <gtest/gtest.h>
#include "cainterface.h"
#include "ocstack.h"
#include "ocpayload.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include "experimental/payload_logging.h"
#include "psinterface.h"
#include "secureresourcemanager.h"
#include "srmresourcestrings.h"
#include "srmutility.h"
#include "amaclresource.h"
#include "security_internals.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "tools.h"
#undef TAG
#include "../src/amaclresource.c"
#undef TAG
#include "../src/psinterface.c"
#ifdef __cplusplus
}
#endif
using namespace std;
#ifdef TAG
#undef TAG
#endif
#define TAG "SRM-AMACL-UT"
TEST(AMACLResourceTest, CBORAMACLConversion)
#define SVR_DB_FILE_NAME TAG".dat"
#define PM_DB_FILE_NAME TAG".db"
class SRM_AMACL_UT : public ::testing::Test
{
public:
static void SetUpTestCase()
{
IOT_Init(PM_DB_FILE_NAME);
EXPECT_EQ(OC_STACK_OK, InitAmaclResource());
}
static void TearDownTestCase()
{
DeInitAmaclResource();
IOT_DeInit(PM_DB_FILE_NAME);
}
};
TEST_F(SRM_AMACL_UT , CBORAMACLConversion)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, AmaclToCBORPayload(NULL , NULL, NULL));
OicSecAmacl_t *secAmacl = (OicSecAmacl_t *) OICCalloc(1, sizeof(*secAmacl));
ASSERT_TRUE(NULL != secAmacl);
......@@ -107,3 +135,42 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
DeleteAmaclList(amacl);
OICFree(psStorage);
}
TEST_F(SRM_AMACL_UT , HandleAmaclGetRequest)
{
OCEntityHandlerRequest *ehRequest = (OCEntityHandlerRequest *)OICCalloc(1,
sizeof(OCEntityHandlerRequest));
ASSERT_TRUE(OC_EH_ERROR == HandleAmaclGetRequest(ehRequest));
}
TEST_F(SRM_AMACL_UT , HandleAmaclPostRequest)
{
OCEntityHandlerRequest *ehRequest = (OCEntityHandlerRequest *)OICCalloc(1,
sizeof(OCEntityHandlerRequest));
size_t size = 0;
uint8_t *cbor = NULL;
OicSecAmacl_t *amAcl = (OicSecAmacl_t *)OICCalloc(1, sizeof(OicSecAmacl_t));
amAcl->resourcesLen = 3;
amAcl->resources = (char**)OICCalloc(amAcl->resourcesLen, sizeof(char*));
for (size_t i = 0; i < amAcl->resourcesLen; i++)
{
amAcl->resources[i] = (char*)OICCalloc(32, sizeof(char));
}
EXPECT_EQ(OC_STACK_OK, AmaclToCBORPayload(amAcl, &cbor, &size));
DeleteAmaclList(amAcl);
ASSERT_TRUE(cbor != NULL);
ehRequest->payload = (OCPayload *)OCSecurityPayloadCreate(cbor, size);
ASSERT_TRUE(NULL != ehRequest->payload);
ASSERT_TRUE(OC_EH_ERROR == HandleAmaclPostRequest(ehRequest));
}
TEST_F(SRM_AMACL_UT , AmaclEntityHandler)
{
OCEntityHandlerRequest *ehRequest = (OCEntityHandlerRequest *)OICCalloc(1,
sizeof(OCEntityHandlerRequest));
ASSERT_TRUE(OC_EH_ERROR == AmaclEntityHandler(OC_REQUEST_FLAG, ehRequest, NULL));
}
......@@ -18,20 +18,227 @@
*
* *****************************************************************/
#include <gtest/gtest.h>
#include "octypes.h"
#include "csrresource.h"
#include "certhelpers.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "tools.h"
#undef TAG
#include "../src/certhelpers.c"
#include "utlist.h"
#include "occertutility.h"
#include "mbedtls/pem.h"
#ifdef __cplusplus
}
#endif
using namespace std;
#ifdef TAG
#undef TAG
#endif
#define TAG "CERT-HLP-UT"
TEST(OCInternalGenerateKeyPairTest, InvalidPK)
#define SVR_DB_FILE_NAME TAG".dat"
#define PM_DB_FILE_NAME TAG".db"
#define ISSUER_CERT "resource/csdk/security/unittest/issuer/cert.pem"
#define ISSUER_KEY "resource/csdk/security/unittest/issuer/key.pem"
#define ISSUER_CERT_DER "resource/csdk/security/unittest/issuer/cert.der"
#define PEM_BEGIN_CRT "-----BEGIN CERTIFICATE-----\n"
#define PEM_END_CRT "-----END CERTIFICATE-----\n"
static mbedtls_pk_context keyPair;
static uint8_t *certificate;
static size_t certificateLen;
static uint8_t *pubKey;
static size_t pubKeyLen;
static const char *publicKey;
static const char *issuerCert;
static uint8_t *issuerCertDer;
static size_t issuerCertDerLen;
static const char* certificateCAPem;
//static uint8_t* certificateCA;
static size_t certificateCALen;
static const char *privateKeyCA;
static const char *publicKeyCA;
static uint8_t *pubKeyCA;
static size_t pubKeyCALen;
class CERT_HLP : public ::testing::Test
{
public:
static void SetUpTestCase()
{
OicUuid_t *subjectUuid = NULL;
const char *issuerPrivateKey = NULL;
issuerCert = NULL;
ASSERT_EQ(0, readTextFile(ISSUER_CERT, &issuerCert));
ASSERT_NE(nullptr, issuerCert);
ASSERT_EQ(0, readTextFile(ISSUER_KEY, &issuerPrivateKey));
ASSERT_NE(nullptr, issuerPrivateKey);
ASSERT_EQ(0, readFile(ISSUER_CERT_DER, &issuerCertDer, &issuerCertDerLen));
ASSERT_NE(nullptr, issuerCertDer);
subjectUuid = createUuid();
ASSERT_NE(nullptr, subjectUuid);
mbedtls_pk_context keyPairCA;
EXPECT_GE(OCInternalGenerateKeyPair(&keyPairCA), 0);
int ret = 0;
size_t len = 2048;
uint8_t *buf = (uint8_t*)OICCalloc(len, 1);
ASSERT_NE(buf, nullptr);
ret = 0;
ret = mbedtls_pk_write_pubkey_der(&keyPairCA, buf, len);
ASSERT_GE(ret, 0);
pubKeyCA = (uint8_t*)OICCalloc(ret, 1);
memcpy(pubKeyCA, buf + len - ret, ret);
pubKeyCALen = ret;
ret = 0;
ret = mbedtls_pk_write_pubkey_pem(&keyPairCA, buf, len);
ASSERT_EQ(ret, 0);
ret = (int)strlen((const char*)buf);
publicKeyCA = (char*)OICCalloc(ret + 1, 1);
ASSERT_NE(publicKeyCA, nullptr);
memcpy((char*)publicKeyCA, buf, ret);
ret = 0;
ret = mbedtls_pk_write_key_pem(&keyPairCA, buf, len);
ASSERT_GE(ret, 0);
size_t pkLen = strlen((const char*)buf);
privateKeyCA = (char*)OICCalloc( pkLen+ 1, 1);
ASSERT_NE(privateKeyCA, nullptr);
memcpy((char*)privateKeyCA, buf, pkLen);
OIC_LOG_V(INFO, TAG, "pk: len:%lu pem:\n%s", pkLen, privateKeyCA);
const char *serial = NULL;
size_t serialLen = 0;
ASSERT_EQ(OC_STACK_OK, OCGenerateRandomSerialNumber((char**)&serial, &serialLen));
EXPECT_EQ(OC_STACK_OK, OCGenerateRootCACertificate(
"C=UA, O=Samsung, CN=CA",
publicKeyCA, issuerCert, issuerPrivateKey,
serial, "20190101235959", "20210101235959",
(char**)&certificateCAPem, &certificateCALen
));
ASSERT_NE(nullptr, certificateCAPem);
ASSERT_TRUE(certificateCALen > 0);
mbedtls_pk_free(&keyPairCA);
OIC_LOG_V(INFO, TAG, "ca: pem:\n%s", certificateCAPem);
//OCSaveTrustCertChain
mbedtls_pk_init(&keyPair);
EXPECT_GE(OCInternalGenerateKeyPair(&keyPair), 0);
ret = 0;
ret = mbedtls_pk_write_pubkey_der(&keyPair, buf, len);
ASSERT_GE(ret, 0);
pubKey = (uint8_t*)OICCalloc(ret, 1);
memcpy(pubKey, buf + len - ret, ret);
pubKeyLen = ret;
ret = 0;
ret = mbedtls_pk_write_pubkey_pem(&keyPair, buf, len);
ASSERT_EQ(ret, 0);
ret = (int)strlen((const char*)buf);
publicKey = (char*)OICCalloc(ret + 1, 1);
ASSERT_NE(publicKey, nullptr);
memcpy((char*)publicKey, buf, ret);
ASSERT_EQ(OC_STACK_OK, OCGenerateRandomSerialNumber((char**)&serial, &serialLen));
EXPECT_EQ(OC_STACK_OK, OCGenerateRoleCertificate(
subjectUuid, publicKey, certificateCAPem, privateKeyCA,
serial, "20190101235959", "20210101235959", "1.3.6.1.4.1.44924.1.7", "samsung",
(char**)&certificate, &certificateLen
));
ASSERT_NE(nullptr, certificate);
ASSERT_TRUE(certificateLen > 0);
OICFree(buf);
}
static void TearDownTestCase()
{
mbedtls_pk_free(&keyPair);
}
};
TEST_F(CERT_HLP, OCInternalGenerateKeyPair)
{
EXPECT_EQ(-1, OCInternalGenerateKeyPair(NULL));
}
TEST(OCInternalIsValidCertChainTest, InvalidCertificateBuffer)
TEST_F(CERT_HLP, InvalidCertificateBuffer)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCInternalIsValidCertChain(NULL, 0));
}
TEST_F(CERT_HLP, GenerateCSRForKey)
{
OCByteString *csr = (OCByteString *)OICCalloc(1, sizeof(OCByteString));
EXPECT_EQ(-1, OCInternalCSRRequest(NULL, NULL, OIC_ENCODING_RAW, NULL));
EXPECT_EQ(-1, GenerateCSRForKey("test", &keyPair, OIC_ENCODING_RAW, csr));
EXPECT_GE(0, GenerateCSRForKey("test", &keyPair, OIC_ENCODING_PEM, csr));
EXPECT_GE(0, GenerateCSRForKey("%$#!!===========,,,,,,,,,,", &keyPair, OIC_ENCODING_PEM, csr));
EXPECT_GE(0, GenerateCSRForKey("C=UA,O=Samsung,CN=uuid:44444442-4444-4444-5555-666666666666", &keyPair, OIC_ENCODING_DER, csr));
OICFree(csr);
}
TEST_F(CERT_HLP, OCInternalIsValidRoleCertificate)
{
size_t _pubKeyLen = 2048;
uint8_t* _pubKey = NULL;
ByteArrayLL_t *crt = NULL, *tmp = NULL, *list = getCerts();
LL_FOREACH_SAFE(list, crt, tmp)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCInternalIsValidRoleCertificate(crt->cert->data, crt->cert->len, &_pubKey,
&_pubKeyLen));
LL_DELETE(list, crt);
OICFree(crt->cert->data);
OICFree(crt->cert);
OICFree(crt);
}
}
TEST_F(CERT_HLP, OCInternalVerifyRoleCertificate)
{
OicSecKey_t *certificateChain = NULL;
OicSecRole_t *roles = NULL;
size_t rolesLength = 0;
ByteArrayLL_t *trustedCaCerts = (ByteArrayLL_t*)OICCalloc(1, sizeof(ByteArrayLL_t));
trustedCaCerts->next = NULL;
trustedCaCerts->cert = (ByteArray_t*)OICCalloc(1, sizeof(ByteArray_t));
trustedCaCerts->cert->data = (uint8_t*)certificateCAPem;
trustedCaCerts->cert->len = certificateCALen;
time_t rtime;
time(&rtime);
struct tm *notValidAfter = localtime(&rtime);
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCInternalVerifyRoleCertificate(certificateChain, trustedCaCerts,
&roles, &rolesLength, notValidAfter));
certificateChain = (OicSecKey_t *)OICCalloc(1, sizeof(OicSecKey_t));
certificateChain->data = certificate;
certificateChain->len = certificateLen;
certificateChain->encoding = OIC_ENCODING_DER;
EXPECT_EQ(OC_STACK_OK, OCInternalVerifyRoleCertificate(certificateChain, trustedCaCerts, &roles,
&rolesLength, notValidAfter));
certificateChain->data[certificateChain->len - 1] = 1;
EXPECT_EQ(OC_STACK_OK, OCInternalVerifyRoleCertificate(certificateChain, trustedCaCerts, &roles,
&rolesLength, notValidAfter));
}
......@@ -17,37 +17,55 @@
* limitations under the License.
*
******************************************************************/
#ifdef __WITH_DTLS__
#include <gtest/gtest.h>
#include "experimental/logger.h"
#include "ocpayload.h"
#include "ocstack.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include "resourcemanager.h"
#include "crlresource.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "tools.h"
#undef TAG
#include "../src/crlresource.c"
#include "srmtestcommon.h"
#include "srmutility.h"
#include "psinterface.h"
#include "security_internals.h"
#include "ocserverrequest.h"
#ifdef __cplusplus
}
#endif
#ifdef TAG
#undef TAG
#endif
#define TAG "SRM-CRL-UT"
//InitCRLResource Tests
TEST(CRLResourceTest, InitCRLResource)
#define SVR_DB_FILE_NAME TAG".dat"
#define PM_DB_FILE_NAME TAG".db"
class CRL : public ::testing::Test
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, InitCRLResource());
}
public:
//DeInitCredResource Tests
TEST(CRLResourceTest, DeInitCRLResource)
static void SetUpTestCase()
{
IOT_Init(PM_DB_FILE_NAME);
}
static void TearDownTestCase()
{
IOT_DeInit(PM_DB_FILE_NAME);
}
};
OCStackResult responseHandler(OCEntityHandlerResponse * ehResponse)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, DeInitCRLResource());
OC_UNUSED(ehResponse);
OIC_LOG_V(DEBUG, TAG, "%s run", __func__);
return OC_STACK_OK;
}
//GetCRLResource Tests
TEST(CRLResourceTest, GetCRLResource)
TEST_F(CRL, GetCRLResource)
{
OicSecCrl_t *nullCrl = GetCRLResource();
EXPECT_NE((OicSecCrl_t*)NULL, nullCrl);
......@@ -55,20 +73,21 @@ TEST(CRLResourceTest, GetCRLResource)
}
//CrlToCBORPayload Tests
TEST(CRLResourceTest, CrlToCBORPayload)
TEST_F(CRL, CrlToCBORPayload)
{
uint8_t *payload = NULL;
size_t size;
OicSecCrl_t *crl = GetCRLResource();
ASSERT_TRUE(NULL != crl);
size = 0;
EXPECT_EQ(OC_STACK_INVALID_PARAM, CrlToCBORPayload(NULL, &payload, &size, NULL));
EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
DeleteCrl(crl);
OICFree(payload);
}
//CBORPaylodToCrl Tests
TEST(CRLResourceTest, CBORPayloadToCrl)
TEST_F(CRL, CBORPayloadToCrl)
{
uint8_t *payload = NULL;
size_t size;
......@@ -78,13 +97,14 @@ TEST(CRLResourceTest, CBORPayloadToCrl)
EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
DeleteCrl(crl);
crl = NULL;
EXPECT_EQ(OC_STACK_INVALID_PARAM, CBORPayloadToCrl(NULL, size, &crl));
EXPECT_EQ(OC_STACK_OK, CBORPayloadToCrl(payload, size, &crl));
DeleteCrl(crl);
OICFree(payload);
}
//GetDerCrl Tests
TEST(CRLResourceTest, GetDerCrl)
TEST_F(CRL, GetDerCrl)
{
ByteArray crlArray = {NULL, 0};
GetDerCrl(&crlArray);
......@@ -92,4 +112,96 @@ TEST(CRLResourceTest, GetDerCrl)
OICFree(crlArray.data);
}
#endif
TEST_F(CRL, copyCrl)
{
OicSecCrl_t *src = GetCRLResource();
OicSecCrl_t *dst = (OicSecCrl_t*)OICCalloc(1, sizeof(OicSecCrl_t));
EXPECT_TRUE(copyCrl(src, dst));
}
TEST_F(CRL, getCurrentUTCTime)
{
char *time = (char*)OICCalloc(512,1);
getCurrentUTCTime(time, 512);
ASSERT_STRNE(NULL, time);
OICFree(time);
}
TEST_F(CRL, UpdateCRLResource)
{
OicSecCrl_t *src = GetCRLResource();
EXPECT_EQ(OC_STACK_OK, UpdateCRLResource(src));
}
TEST_F(CRL, ValidateQuery)
{
char *q = (char*)OICCalloc(512,1);
EXPECT_TRUE(ValidateQuery(q));
snprintf(q, 512, "%s=lo",OC_RSRVD_INTERFACE);
EXPECT_FALSE(ValidateQuery(q));
OICFree(q);
}
TEST_F(CRL, HandleCRLGetRequest)
{
OCServerRequest *srvReq = (OCServerRequest*)OICCalloc(1, sizeof(OCServerRequest));
srvReq->ehResponseHandler = responseHandler;
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
ehReq.method = OC_REST_GET;
ehReq.requestHandle = (OCRequestHandle) srvReq;