#include "ocprovisioningmanager.h"
#include "oxmjustworks.h"
#include "oxmrandompin.h"
+#include "oxmmanufacturercert.h"
#include "securevirtualresourcetypes.h"
#include "provisioningdatabasemanager.h"
+#ifdef MULTIPLE_OWNER
+#include "multipleownershiptransfermanager.h"
+#endif //MULTIPLE_OWNER
#include "srmutility.h"
#include "doxmresource.h"
#include "pmtypes.h"
EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
}
+TEST(ManufacturerCertOxMTest, NullParam)
+{
+ OTMContext_t* otmCtx = NULL;
+ OCStackResult res = OC_STACK_ERROR;
+ uint8_t *payloadRes = NULL;
+ size_t size = 0;
+
+ res = PrepareMCertificateCallback(otmCtx);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateSecureSessionMCertificateCallback(otmCtx);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateMCertificateBasedSelectOxmPayload(otmCtx, &payloadRes, &size);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateMCertificateBasedOwnerTransferPayload(otmCtx, &payloadRes, &size);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ OTMContext_t otmCtx2;
+ otmCtx2.selectedDeviceInfo = NULL;
+
+ res = InputPinCodeCallback(&otmCtx2);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateSecureSessionMCertificateCallback(&otmCtx2);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateMCertificateBasedSelectOxmPayload(&otmCtx2, &payloadRes, &size);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+
+ res = CreateMCertificateBasedOwnerTransferPayload(&otmCtx2, &payloadRes, &size);
+ EXPECT_TRUE(OC_STACK_INVALID_PARAM == res);
+}
/****************************************
* Test the OTM modules with sample server
static const char* g_otmCtx = "Test User Context";
static OCProvisionDev_t* g_unownedDevices = NULL;
static OCProvisionDev_t* g_ownedDevices = NULL;
+#ifdef MULTIPLE_OWNER
+static OCProvisionDev_t* g_motEnabledDevices = NULL;
+static OCProvisionDev_t* g_multiplOwnedDevices = NULL;
+#endif //MULTIPLE_OWNER
static void GetCurrentWorkingDirectory(char* buf, size_t bufsize)
{
g_doneCB = true;
}
+#ifdef MULTIPLE_OWNER
+static void updateDoxmForMOTCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError)
+{
+ if(!hasError)
+ {
+ OIC_LOG_V(INFO, TAG, "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx);
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, TAG, "POST 'doxm' FAILED - ctx: %s", (char*) ctx);
+ }
+ g_callbackResult = !hasError;
+ g_doneCB = true;
+}
+
+static void provisionPreconfiguredPinCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError)
+{
+ if(!hasError)
+ {
+ OIC_LOG_V(INFO, TAG, "Provision Preconfigured-PIN SUCCEEDED - ctx: %s", (char*) ctx);
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, TAG, "Provision Preconfigured-PIN FAILED - ctx: %s", (char*) ctx);
+ }
+ g_callbackResult = !hasError;
+ g_doneCB = true;
+}
+#endif //MULTIPLE_OWNER
// callback function(s) for provisioning client using C-level provisioning API
static void removeDeviceCB(void* ctx, int UNUSED1, OCProvisionResult_t* UNUSED2, bool hasError)
g_callbackResult = false;
}
+TEST(PerformSecureResourceDiscovery, NullParam)
+{
+ OCStackResult result = OC_STACK_ERROR;
+ OCProvisionDev_t* foundDevice = NULL;
+
+ OicUuid_t uuid;
+ ConvertStrToUuid("11111111-1111-1111-1111-111111111111", &uuid);
+
+ OIC_LOG(INFO, TAG, "Discovering Owned/Unowned Device using multicast\n");
+ result = OCDiscoverSingleDevice(DISCOVERY_TIMEOUT, &uuid, &foundDevice);
+ EXPECT_EQ(OC_STACK_OK, result);
+
+ int NumOfFoundDevice = 0;
+ OCProvisionDev_t* tempDev = foundDevice;
+ while(tempDev)
+ {
+ NumOfFoundDevice++;
+ tempDev = tempDev->next;
+ }
+ PMDeleteDeviceList(foundDevice);
+
+ EXPECT_EQ(true, NumOfFoundDevice > 0);
+}
TEST(PerformUnownedDeviceDiscovery, NullParam)
{
dev2 = tempDev;
break;
}
- else
- {
- break;
- }
}
tempDev = tempDev->next;
}
EXPECT_EQ(OC_STACK_OK, result);
}
+#ifdef MULTIPLE_OWNER
+TEST(RegisterPreconfiguredPIN, NullParam)
+{
+ OCStackResult result = SetPreconfigPin("12341234", strlen("12341234"));
+ EXPECT_EQ(OC_STACK_OK, result);
+}
+
+TEST(EnableMOT, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ if(NULL == g_ownedDevices)
+ {
+ OIC_LOG(INFO, TAG, "Discovering Only Owned Devices on Network..\n");
+ result = OCDiscoverOwnedDevices(DISCOVERY_TIMEOUT, &g_ownedDevices);
+ EXPECT_EQ(OC_STACK_OK, result);
+ RemoveUnknownDeviceFromDevList(g_ownedDevices);
+ }
+ EXPECT_NE((OCProvisionDev_t*)NULL, g_ownedDevices);
+
+ g_doneCB = false;
+ result = OCChangeMOTMode(NULL, g_ownedDevices, OIC_MULTIPLE_OWNER_ENABLE, updateDoxmForMOTCB);
+ EXPECT_EQ(OC_STACK_OK, result);
+ if(waitCallbackRet()) // input |g_doneCB| flag implicitly
+ {
+ OIC_LOG(ERROR, TAG, "OCChangeMOTMode callback error");
+ return;
+ }
+
+ EXPECT_TRUE(g_callbackResult);
+}
+
+TEST(DiscoverMOTEnabledDevices, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ if(g_motEnabledDevices)
+ {
+ PMDeleteDeviceList(g_motEnabledDevices);
+ }
+
+ OIC_LOG(INFO, TAG, "Discovering MOT Enabled Devices on Network..\n");
+ result = OCDiscoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT, &g_motEnabledDevices);
+ EXPECT_EQ(OC_STACK_OK, result);
+ RemoveUnknownDeviceFromDevList(g_motEnabledDevices);
+ EXPECT_NE((OCProvisionDev_t*)NULL, g_motEnabledDevices);
+}
+
+TEST(ProvisonPreconfiguredPIN, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ g_doneCB = false;
+ result = OCProvisionPreconfigPin(NULL, g_motEnabledDevices, "12341234", strlen("12341234"), provisionPreconfiguredPinCB);
+ EXPECT_EQ(OC_STACK_OK, result);
+ if(waitCallbackRet()) // input |g_doneCB| flag implicitly
+ {
+ OIC_LOG(ERROR, TAG, "OCProvisionPreconfigPin callback error");
+ return;
+ }
+
+ EXPECT_EQ(true, g_callbackResult);
+}
+
+TEST(SelectMOTMethod, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ g_doneCB = false;
+ result = OCSelectMOTMethod(NULL, g_motEnabledDevices, OIC_PRECONFIG_PIN, updateDoxmForMOTCB);
+ EXPECT_EQ(OC_STACK_OK, result);
+ if(waitCallbackRet()) // input |g_doneCB| flag implicitly
+ {
+ OIC_LOG(ERROR, TAG, "OCSelectMOTMethod callback error");
+ return;
+ }
+
+ EXPECT_EQ(true, g_callbackResult);
+}
+
+// TODO: Need to new server to perform MOT
+/*
+TEST(PerformMOT, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ g_doneCB = false;
+ result = OCDoMultipleOwnershipTransfer(NULL, g_motEnabledDevices, ownershipTransferCB);
+ EXPECT_EQ(OC_STACK_OK, result);
+ if(waitCallbackRet()) // input |g_doneCB| flag implicitly
+ {
+ OIC_LOG(ERROR, TAG, "OCDoMultipleOwnershipTransfer callback error");
+ return;
+ }
+ EXPECT_EQ(true, g_callbackResult);
+}
+
+TEST(DiscoverMultipleOwnedDevices, NullParam)
+{
+ OCStackResult result = OC_STACK_OK;
+
+ if(g_multiplOwnedDevices)
+ {
+ PMDeleteDeviceList(g_multiplOwnedDevices);
+ }
+
+ OIC_LOG(INFO, TAG, "Discovering MOT Enabled Devices on Network..\n");
+ result = OCDiscoverMultipleOwnedDevices(DISCOVERY_TIMEOUT, &g_multiplOwnedDevices);
+ EXPECT_EQ(OC_STACK_OK, result);
+ RemoveUnknownDeviceFromDevList(g_multiplOwnedDevices);
+ EXPECT_TRUE(NULL != g_multiplOwnedDevices);
+}*/
+
+#endif //MULTIPLE_OWNER
+
TEST(PerformRemoveDevice, NullParam)
{
OicUuid_t myUuid;