Commit 492772b0 authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko Committed by Aleksey

the security provisioning unittests

the security provisioning unittests
coverage up t0 75

Change-Id: Idd98ddf4c61de900842c4c7e9567c1ed527dc59a
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent a05a151f
......@@ -59,7 +59,6 @@ cfg_client = 'oic_svr_db_client.dat'
server_bin = 'sample_server' + sptest_env.get('PROGSUFFIX')
unittest_bin = 'unittest' + sptest_env.get('PROGSUFFIX')
######################################################################
# Functions
######################################################################
......@@ -74,10 +73,9 @@ def clean_config():
safe_remove('oic_svr_db_server1.dat')
safe_remove('oic_svr_db_server2.dat')
safe_remove(cfg_client)
safe_remove('test.db')
safe_remove('PDM.db')
safe_remove('secureresourceprovider.dat')
safe_remove('device_properties.dat')
safe_remove('LIB_UNITTEST.dat')
safe_remove('secureresourceprovider.dat')
def start_srv(num):
......@@ -85,7 +83,10 @@ def start_srv(num):
print("no executable file")
return
cfg_srv = 'oic_svr_db_server' + num + '.dat'
copyfile(sec_provisioning_src_dir + 'oic_svr_db_server_justworks.dat', cfg_srv)
cfg = sec_provisioning_src_dir + 'oic_svr_db_server_justworks.dat'
if not path.exists(cfg):
raise Exception("cannot copy file: "+cfg)
copyfile(cfg, cfg_srv)
if not sptest_env.get('RELEASE'):
po = Popen(
unittest_build_dir + server_bin + ' ' + num + ' ' + cfg_srv,
......@@ -133,20 +134,20 @@ def kill_all():
def run_test(target, source, env):
kill_all()
clean_config()
copyfile(sec_provisioning_src_dir + 'oic_svr_db_client.dat', cfg_client)
cfg = sec_provisioning_src_dir + 'oic_svr_db_client.dat'
if not path.exists(cfg):
raise Exception("cannot copy file: "+cfg)
copyfile(cfg, cfg_client)
po_srv1 = start_srv(str(1))
po_srv2 = start_srv(str(2))
print("Waiting for servers start")
sleep(3)
call([unittest_build_dir + unittest_bin])
print("Servers are stopping")
sleep(3)
po_srv1.terminate()
po_srv2.terminate()
clean_config()
kill_all()
######################################################################
# Build flags
######################################################################
......@@ -178,7 +179,9 @@ sptest_env.PrependUnique(CPPPATH=[
'#resource/csdk/security/include',
'#resource/csdk/security/include/experimental',
'#resource/csdk/security/provisioning/src/cloud',
'#resource/csdk/security/provisioning/include/cloud/'
'#resource/csdk/security/provisioning/include/cloud/',
'#resource/csdk/logger/include/experimental',
'#extlibs/sqlite3'
])
sptest_env.PrependUnique(LIBS=[
......@@ -216,26 +219,29 @@ else:
# Source files and Targets
######################################################################
unittest_src = [
'pmutilitytest.cpp',
'secureresourceprovider.cpp',
'provisioningdatabasemanager.cpp',
'ocprovisioningmanager.cpp',
'credentialgeneratortest.cpp',
'otmunittest.cpp',
]
if sptest_env.get('WITH_TCP') == True and sptest_env.get('WITH_CLOUD') == True:
unittest_src = unittest_src + [
'cloudresource.cpp',
if target_os in ['linux']:
unittest_src = [
'tools.cpp',
'ocprovisioningmanager.cpp',
'pmutilitytest.cpp',
'secureresourceprovider.cpp',
'provisioningdatabasemanager.cpp',
'oxmjustworks.cpp',
'otmcontextlist.cpp',
'ownershiptransfermanager.cpp',
'oxmmanufacturercert.cpp',
'oxmrandompin.cpp',
'credentialgenerator.cpp',
'otmunittest.cpp'
]
if sptest_env.get('WITH_TCP') == True and sptest_env.get('WITH_CLOUD') == True:
unittest_src.append('cloudresource.cpp')
tests = sptest_env.Program(unittest_bin, unittest_src)
server = sptest_env.Program(server_bin, ['sampleserver.cpp'])
tests = sptest_env.Program(unittest_bin, unittest_src)
server = sptest_env.Program(server_bin, ['sampleserver.cpp'])
Alias('build', [tests, server])
Alias('build', [tests, server])
if sptest_env.get('TEST') == '1':
if target_os in ['linux', 'windows']:
if sptest_env.get('TEST') == '1':
print("Start tests")
sptest_env.Command('start', [server_bin, unittest_bin], Action(run_test))
/* *****************************************************************
*
* Copyright 2015 Samsung Electronics All Rights Reserved.
* Copyright 2019 Samsung Electronics All Rights Reserved.
*
*
*
......@@ -17,15 +17,50 @@
* limitations under the License.
*
* *****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <gtest/gtest.h>
#include "credentialgenerator.h"
#include "oic_malloc.h"
#ifdef __cplusplus
extern "C" {
#endif
TEST(PMGeneratePairWiseCredentialsTest, InvalidFirstDevID)
#include "ocprovisioningmanager.h"
#include "../src/credentialgenerator.c"
#include "tools.h"
#undef TAG
#ifdef __cplusplus
}
#endif
#undef TAG
#define TAG "CG_UNITTEST"
#define SVR_DB_FILE_NAME TAG".dat"
#define PM_DB_FILE_NAME TAG".db"
using namespace std;
class CG : public ::testing::Test
{
public:
static void SetUpTestCase()
{
IOT_Init(PM_DB_FILE_NAME);
}
static void TearDownTestCase()
{
IOT_DeInit(PM_DB_FILE_NAME);
}
};
TEST_F(CG, PMGeneratePairWiseCredentialsInvalidFirstDevID)
{
OicUuid_t *SecondDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(SecondDevID)
OicUuid_t *SecondDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (SecondDevID)
{
SecondDevID->id[0] = 2;
}
......@@ -37,15 +72,15 @@ TEST(PMGeneratePairWiseCredentialsTest, InvalidFirstDevID)
OICFree(SecondDevID);
}
TEST(PMGeneratePairWiseCredentialsTest, InvalidSecondDevID)
TEST_F(CG, PMGeneratePairWiseCredentialsInvalidSecondDevID)
{
OicUuid_t *firstDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(firstDevID)
OicUuid_t *firstDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (firstDevID)
{
firstDevID->id[0] = 1;
}
OicUuid_t *provisioningDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(provisioningDevID)
OicUuid_t *provisioningDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (provisioningDevID)
{
provisioningDevID->id[0] = 2;
}
......@@ -58,20 +93,20 @@ TEST(PMGeneratePairWiseCredentialsTest, InvalidSecondDevID)
OICFree(provisioningDevID);
}
TEST(PMGeneratePairWiseCredentialsTest, InvalidCred)
TEST_F(CG, PMGeneratePairWiseCredentialsInvalidCred)
{
OicUuid_t *firstDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(firstDevID)
OicUuid_t *firstDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (firstDevID)
{
firstDevID->id[0] = 1;
}
OicUuid_t *SecondDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(SecondDevID)
OicUuid_t *SecondDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (SecondDevID)
{
SecondDevID->id[0] = 2;
}
OicUuid_t *provisioningDevID = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
if(provisioningDevID)
OicUuid_t *provisioningDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
if (provisioningDevID)
{
provisioningDevID->id[0] = 3;
}
......@@ -82,3 +117,29 @@ TEST(PMGeneratePairWiseCredentialsTest, InvalidCred)
OICFree(SecondDevID);
OICFree(provisioningDevID);
}
TEST_F(CG, PMGeneratePairWiseCredentialsFull)
{
OicUuid_t *firstDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
EXPECT_TRUE(NULL != firstDevID);
ConvertStrToUuid("11111111-1234-1234-1234-123456789011", firstDevID);
OicUuid_t *secondDevID = (OicUuid_t *)OICMalloc(sizeof(OicUuid_t));
EXPECT_TRUE(NULL != secondDevID);
ConvertStrToUuid("11111111-1234-1234-1234-123456789012", secondDevID);
OicSecRole_t *firstRole = (OicSecRole_t *)OICMalloc(sizeof(OicSecRole_t));
OicSecRole_t *secondRole = (OicSecRole_t *)OICMalloc(sizeof(OicSecRole_t));
OicSecCred_t *firstCred = NULL;
OicSecCred_t *secondCred = NULL;
EXPECT_EQ(OC_STACK_OK, PMGeneratePairWiseCredentials(SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_256,
firstDevID, secondDevID, firstRole, secondRole, &firstCred, &secondCred));
OICFree(firstCred->privateData.data);
OICFree(secondCred->privateData.data);
OICFree(secondCred);
OICFree(firstCred);
OICFree(secondRole);
OICFree(firstRole);
OICFree(firstDevID);
OICFree(secondDevID);
}
......@@ -19,49 +19,53 @@
* *****************************************************************/
#include <gtest/gtest.h>
#include "ocprovisioningmanager.h"
#include "experimental/logger.h"
static OicSecAcl_t acl1;
static OicSecAcl_t acl2;
static OCProvisionDev_t pDev1;
static OCProvisionDev_t pDev2;
static OicSecCredType_t credType = SYMMETRIC_PAIR_WISE_KEY;
static OicSecOxm_t oicSecDoxmJustWorks = OIC_JUST_WORKS;
static OicSecOxm_t oicSecDoxmRandomPin = OIC_RANDOM_DEVICE_PIN;
static OicSecDoxm_t defaultDoxm1 =
{
&oicSecDoxmJustWorks, /* uint16_t *oxm */
1, /* size_t oxmLen */
OIC_JUST_WORKS, /* uint16_t oxmSel */
SYMMETRIC_PAIR_WISE_KEY,/* OicSecCredType_t sct */
false, /* bool owned */
{{0}}, /* OicUuid_t deviceID */
false, /* bool dpc */
{{0}}, /* OicUuid_t owner */
#ifdef MULTIPLE_OWNER
NULL, /* OicSecSubOwner_t* subOwners */
NULL, /* OicSecMom_t *mom */
#endif //MULTIPLE_OWNER
{{0}} /* rownerID */
};
#ifdef __cplusplus
extern "C" {
#endif
#include "../src/ocprovisioningmanager.c"
#include "tools.h"
#ifdef __cplusplus
}
#endif
static OicSecDoxm_t defaultDoxm2 =
{
&oicSecDoxmRandomPin, /* uint16_t *oxm */
1, /* size_t oxmLen */
OIC_RANDOM_DEVICE_PIN, /* uint16_t oxmSel */
SYMMETRIC_PAIR_WISE_KEY,/* OicSecCredType_t sct */
false, /* bool owned */
{{0}}, /* OicUuid_t deviceID */
false, /* bool dpc */
{{0}}, /* OicUuid_t owner */
#ifdef MULTIPLE_OWNER
NULL, /* OicSecSubOwner_t* subOwners */
NULL, /* OicSecMom_t *mom */
#endif //MULTIPLE_OWNER
{{0}} /* rownerID */
#undef TAG
#define TAG "OTM_OCPROVISIONINGMANAGER"
#define SVR_DB_FILE_NAME TAG".dat"
#define PM_DB_FILE_NAME TAG".db"
static OCProvisionDev_t *pDev1 = NULL;
static OCProvisionDev_t *pDev2 = NULL;
class PM : public ::testing::Test
{
public:
static void SetUpTestCase()
{
IOT_Init(PM_DB_FILE_NAME);
pDev1 = createProvisionDev();
pDev2 = createProvisionDev();
pDev2->endpoint.port = 9998;
ConvertStrToUuid("33333355-3333-3333-3333-111111111111", &pDev2->doxm->deviceID);
}
static void TearDownTestCase()
{
IOT_DeInit(PM_DB_FILE_NAME);
}
OicSecAcl_t acl1;
OicSecAcl_t acl2;
};
static void provisioningCB (void* UNUSED1, size_t UNUSED2, OCProvisionResult_t *UNUSED3, bool UNUSED4)
static void provisioningCB (void *UNUSED1, size_t UNUSED2, OCProvisionResult_t *UNUSED3,
bool UNUSED4)
{
//dummy callback
(void) UNUSED1;
......@@ -70,88 +74,112 @@ static void provisioningCB (void* UNUSED1, size_t UNUSED2, OCProvisionResult_t *
(void) UNUSED4;
}
static OCStackResult OTMLoadSecretCallback(OTMContext_t* otmCtx)
static OCStackResult OTMLoadSecretCallback(OTMContext_t *otmCtx)
{
//dummy callback
(void) otmCtx;
return OC_STACK_OK;
}
TEST(OCInitPMTest, NullPath)
TEST_F(PM, OCProvisionPairwiseDevicesTestNullDevice1)
{
EXPECT_EQ(OC_STACK_OK, OCInitPM(NULL));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_128, NULL, &acl1,
pDev2, &acl2, &provisioningCB));
}
TEST(OCProvisionPairwiseDevicesTest, NullDevice1)
TEST_F(PM, OCProvisionPairwiseDevicesTestNullDevice2)
{
pDev1.doxm = &defaultDoxm1;
uint8_t deviceId1[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64};
memcpy(pDev1.doxm->deviceID.id, deviceId1, sizeof(deviceId1));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_128, pDev1, &acl1,
NULL, &acl2, &provisioningCB));
}
pDev2.doxm = &defaultDoxm2;
uint8_t deviceId2[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x63};
memcpy(pDev2.doxm->deviceID.id, deviceId2, sizeof(deviceId2));
TEST_F(PM, OCProvisionPairwiseDevicesTestSamelDeviceId)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_128, pDev1, &acl1,
pDev1, &acl2, &provisioningCB));
}
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, credType,
OWNER_PSK_LENGTH_128, NULL, &acl1,
&pDev2, &acl2, &provisioningCB));
TEST_F(PM, OCProvisionPairwiseDevicesTestNullCallback)
{
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_128, pDev1, &acl1,
pDev2, &acl2, NULL));
}
TEST(OCProvisionPairwiseDevicesTest, NullDevice2)
TEST_F(PM, OCProvisionPairwiseDevicesTestInvalidKeySize)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, credType,
OWNER_PSK_LENGTH_128, &pDev1, &acl1,
NULL, &acl2, &provisioningCB));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
0, pDev1, &acl1,
pDev2, &acl2, &provisioningCB));
}
TEST(OCProvisionPairwiseDevicesTest, SamelDeviceId)
TEST_F(PM, OCProvisionPairwiseDevices)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, credType,
OWNER_PSK_LENGTH_128, &pDev1, &acl1,
&pDev1, &acl2, &provisioningCB));
PDMDeleteDevice(&pDev1->doxm->deviceID);
PDMDeleteDevice(&pDev2->doxm->deviceID);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&pDev1->doxm->deviceID));
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&pDev2->doxm->deviceID));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&pDev1->doxm->deviceID, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&pDev2->doxm->deviceID, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_256, pDev1, &acl1,
pDev2, &acl2, &provisioningCB));
EXPECT_EQ(OC_STACK_OK, PDMLinkDevices(&pDev1->doxm->deviceID, &pDev2->doxm->deviceID));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, SYMMETRIC_PAIR_WISE_KEY,
OWNER_PSK_LENGTH_256, pDev1, &acl1,
pDev2, &acl2, &provisioningCB));
}
TEST(OCProvisionPairwiseDevicesTest, NullCallback)
TEST_F(PM, OCGetDevInfoFromNetwork)
{
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCProvisionPairwiseDevices(NULL, credType,
OWNER_PSK_LENGTH_128, &pDev1, &acl1,
&pDev2, &acl2, NULL));
OCProvisionDev_t *pOwnedDevList = NULL;
OCProvisionDev_t *pUnownedDevList = NULL;
EXPECT_EQ(OC_STACK_OK, OCGetDevInfoFromNetwork(4, &pOwnedDevList, &pUnownedDevList));
}
TEST(OCProvisionPairwiseDevicesTest, InvalidKeySize)
TEST_F(PM, OCUnlinkDevicesTestNullDevice1)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCProvisionPairwiseDevices(NULL, credType,
0, &pDev1, &acl1,
&pDev2, &acl2 ,&provisioningCB));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL, NULL, pDev2, provisioningCB));
}
TEST(OCUnlinkDevicesTest, NullDevice1)
TEST_F(PM, OCUnlinkDevicesTestNullDevice2)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL, NULL, &pDev2, provisioningCB));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL, pDev1, NULL, provisioningCB));
}
TEST(OCUnlinkDevicesTest, NullDevice2)
TEST_F(PM, OCUnlinkDevicesTestNullCallback)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL, &pDev1, NULL, provisioningCB));
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCUnlinkDevices(NULL, pDev1, pDev2, NULL));
}
TEST(OCUnlinkDevicesTest, NullCallback)
TEST_F(PM, OCUnlinkDevicesTestSamelDeviceId)
{
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCUnlinkDevices(NULL, &pDev1, &pDev2, NULL));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL, pDev1, pDev1, provisioningCB));
}
TEST(OCUnlinkDevicesTest, SamelDeviceId)
TEST_F(PM, OCUnlinkDevicesTest)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCUnlinkDevices(NULL,&pDev1, &pDev1, &provisioningCB));
PDMDeleteDevice(&pDev1->doxm->deviceID);
PDMDeleteDevice(&pDev2->doxm->deviceID);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&pDev1->doxm->deviceID));
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&pDev2->doxm->deviceID));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&pDev1->doxm->deviceID, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&pDev2->doxm->deviceID, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, PDMLinkDevices(&pDev1->doxm->deviceID, &pDev2->doxm->deviceID));
EXPECT_EQ(OC_STACK_OK, OCUnlinkDevices(NULL, pDev1, pDev2, provisioningCB));
}
TEST(OCRemoveDeviceTest, NullTargetDevice)
TEST_F(PM, OCRemoveDeviceTestNullTargetDevice)
{
unsigned short waitTime = 10 ;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCRemoveDevice(NULL, waitTime, NULL, provisioningCB));
}
TEST(OCRemoveDeviceWithUuidTest, NullTargetDevice)
TEST_F(PM, OCRemoveDeviceWithUuidTestNullTargetDevice)
{
unsigned short waitTime = 10 ;
OicUuid_t uuid;
......@@ -160,33 +188,33 @@ TEST(OCRemoveDeviceWithUuidTest, NullTargetDevice)
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCRemoveDeviceWithUuid(NULL, waitTime, &uuid, NULL));
}
TEST(OCRemoveDeviceTest, NullResultCallback)
TEST_F(PM, OCRemoveDeviceTestNullResultCallback)
{
unsigned short waitTime = 10;
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCRemoveDevice(NULL, waitTime, &pDev1, NULL));
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCRemoveDevice(NULL, waitTime, pDev1, NULL));
}
TEST(OCRemoveDeviceTest, ZeroWaitTime)
TEST_F(PM, OCRemoveDeviceTestZeroWaitTime)
{
unsigned short waitTime = 0;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCRemoveDevice(NULL, waitTime, &pDev1, provisioningCB));
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCRemoveDevice(NULL, waitTime, pDev1, provisioningCB));
}
TEST(OCGetDevInfoFromNetworkTest, NullUnOwnedDeviceInfo)
TEST_F(PM, OCGetDevInfoFromNetworkTestNullUnOwnedDeviceInfo)
{
unsigned short waitTime = 10;
OCProvisionDev_t *ownedList = NULL;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCGetDevInfoFromNetwork(waitTime, &ownedList, NULL));
}
TEST(OCGetDevInfoFromNetworkTest, NullOwnedDeviceInfo)
TEST_F(PM, OCGetDevInfoFromNetworkTestNullOwnedDeviceInfo)
{
unsigned short waitTime = 10;
OCProvisionDev_t *unownedList = NULL;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCGetDevInfoFromNetwork(waitTime, NULL, &unownedList));
}
TEST(OCGetDevInfoFromNetworkTest, ZeroWaitTime)
TEST_F(PM, OCGetDevInfoFromNetworkTestZeroWaitTime)
{
unsigned short waitTime = 0;
OCProvisionDev_t *ownedList = NULL;
......@@ -194,61 +222,205 @@ TEST(OCGetDevInfoFromNetworkTest, ZeroWaitTime)
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCGetDevInfoFromNetwork(waitTime, &ownedList, &unownedList));
}
TEST(OCGetLinkedStatusTest, NULLDeviceID)
TEST_F(PM, OCGetLinkedStatusTestNULLDeviceID)
{
OCUuidList_t *list = NULL;
size_t noOfDevices = 0;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCGetLinkedStatus(NULL, &list, &noOfDevices));
}
TEST(OCDeleteUuidListTest, NullUuidList)
TEST_F(PM, OCDeleteUuidListTestNullUuidList)
{
OCDeleteUuidList(NULL);
EXPECT_EQ(1, 1);
}
TEST(OCDeleteACLListTest, NullACLList)
TEST_F(PM, OCDeleteACLListTestNullACLList)
{
OCDeleteACLList(NULL);
EXPECT_EQ(1, 1);
}
TEST(OCDeleteDiscoveredDevicesTest, NullProvisionDevList)
TEST_F(PM, OCDeleteDiscoveredDevicesTestNullProvisionDevList)
{
OCDeleteDiscoveredDevices(NULL);
EXPECT_EQ(1, 1);
}
TEST(OCSetOwnerTransferCallbackDataTest, NULLCallback)
TEST_F(PM, OCSetOwnerTransferCallbackDataTestNULLCallback)
{
OicSecOxm_t ownershipTransferMethod = OIC_JUST_WORKS;
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, OCSetOwnerTransferCallbackData(ownershipTransferMethod,
NULL));
NULL));
}
TEST(OCSetOwnerTransferCallbackDataTest, InvalidOXMType)
TEST_F(PM, OCSetOwnerTransferCallbackDataTestInvalidOXMType)
{
OicSecOxm_t ownershipTransferMethod = OIC_OXM_COUNT;
OTMCallbackData_t stOTMCallbackData = { &OTMLoadSecretCallback, NULL, NULL, NULL};
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetOwnerTransferCallbackData(ownershipTransferMethod,
&stOTMCallbackData));
&stOTMCallbackData));
}
TEST(OCResetDeviceTest, NULLCallback)
TEST_F(PM, UpdateLinkResults)
{