#include "EasySetup.h"
#include "ESRichCommon.h"
+#include "ocrandom.h"
+#include "cainterface.h"
+#include "OCPlatform.h"
+
#define PROV_RESOURCE_TYPE "ocf.wk.prov"
using namespace OIC::Service;
}
private:
+ bool isValidResourceToTest(std::shared_ptr<OC::OCResource> resource)
+ {
+ if((resource->connectivityType() & CT_ADAPTER_TCP) == CT_ADAPTER_TCP)
+ {
+ return false;
+ }
+
+ CAEndpoint_t *tempInfo = NULL;
+ uint32_t tempSize = 0;
+
+ CAResult_t res = CAGetNetworkInformation(&tempInfo, &tempSize);
+ if (CA_STATUS_OK != res || NULL == tempInfo || 0 >= tempSize)
+ {
+ free(tempInfo);
+ return false;
+ }
+
+ for (uint32_t index = 0; index < tempSize; index++)
+ {
+ if (CA_ADAPTER_IP == tempInfo[index].adapter)
+ {
+ if(resource->host().find(tempInfo[index].addr) != std::string::npos &&
+ resource->host().find(std::to_string(tempInfo[index].port).c_str()) != std::string::npos)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
void discoverRemoteEnrolleeCb(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_discoveryCb)
{
m_discoveryCb(resource);
void discoverRemoteEnrolleeCbToGetConfiguration(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_getConfigurationCb
&& !m_remoteEnrollee)
{
void discoverRemoteEnrolleeCbToGetStatus(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) && m_getStatusCb
&& !m_remoteEnrollee)
{
void discoverRemoteEnrolleeCbToProvisionDeviceProperties(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) &&
m_DevicePropProvisioningCb && !m_remoteEnrollee)
{
void discoverRemoteEnrolleeCbToProvisionCloudProperties(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE) &&
m_CloudPropProvisioningCb && !m_remoteEnrollee)
{
GTest_Main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
easysetup_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
-easysetup_test_env.AppendUnique(LIBS = [
+easysetup_test_env.PrependUnique(LIBS = [
'connectivity_abstraction', 'oc', 'octbstack', 'oc_logger', 'coap',
GTest_Main, GTest])
easysetup_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master', gtest_dir + '/include'])
-easysetup_test_env.AppendUnique(CPPPATH = ['../../../../resource/include',
- '../inc',
- '../../inc',
- '../../mediator/richsdk/inc'])
+easysetup_test_env.AppendUnique(CPPPATH = [src_dir + '/resource/include',
+ src_dir + '/resource/csdk/connectivity/api',
+ src_dir + '/service/easy-setup/inc',
+ src_dir + '/service/easy-setup/enrollee/inc',
+ src_dir + '/service/easy-setup/mediator/richsdk/inc'])
######################################################################
# Build Test
#include "ESEnrolleeCommon.h"
#include "easysetup.h"
+#include "ocrandom.h"
+#include "cainterface.h"
+#include "OCPlatform.h"
+
#define PROV_RESOURCE_TYPE "ocf.wk.prov"
using namespace OC;
}
private:
+ bool isValidResourceToTest(std::shared_ptr<OC::OCResource> resource)
+ {
+ if((resource->connectivityType() & CT_ADAPTER_TCP) == CT_ADAPTER_TCP)
+ {
+ return false;
+ }
+
+ CAEndpoint_t *tempInfo = NULL;
+ uint32_t tempSize = 0;
+
+ CAResult_t res = CAGetNetworkInformation(&tempInfo, &tempSize);
+ if (CA_STATUS_OK != res || NULL == tempInfo || 0 >= tempSize)
+ {
+ free(tempInfo);
+ return false;
+ }
+
+ for (uint32_t index = 0; index < tempSize; index++)
+ {
+ if (CA_ADAPTER_IP == tempInfo[index].adapter)
+ {
+ if(resource->host().find(tempInfo[index].addr) != std::string::npos &&
+ resource->host().find(std::to_string(tempInfo[index].port).c_str()) != std::string::npos)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
void discoverRemoteEnrolleeCb(std::shared_ptr<OC::OCResource> resource)
{
+ if(!isValidResourceToTest(resource))
+ {
+ return ;
+ }
+
if(!resource->getResourceTypes().at(0).compare(PROV_RESOURCE_TYPE))
{
m_enrolleeResource = resource;
GTest_Main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
easysetup_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
-easysetup_test_env.AppendUnique(LIBS = [
+easysetup_test_env.PrependUnique(LIBS = [
'connectivity_abstraction', 'oc', 'octbstack', 'oc_logger', 'coap',
GTest_Main, GTest])
easysetup_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master', gtest_dir + '/include'])
easysetup_test_env.AppendUnique(CPPPATH = [ src_dir + '/resource/include',
+ src_dir + '/resource/csdk/connectivity/api',
src_dir + '/service/easy-setup/mediator/richsdk/inc',
src_dir + '/service/easy-setup/inc',
src_dir + '/service/easy-setup/enrollee/inc'])