return ehRet;
}
-static void updateWriteableProperty(const OicSecDoxm_t* src, OicSecDoxm_t* dst)
+OCStackResult DoxmUpdateWriteableProperty(const OicSecDoxm_t* src, OicSecDoxm_t* dst)
{
+ OCStackResult result = OC_STACK_OK;
+
if(src && dst)
- {
- // update oxmsel
+ {
+ // Update oxmsel
dst->oxmSel = src->oxmSel;
- //update owner
+ // Update owner
memcpy(&(dst->owner), &(src->owner), sizeof(OicUuid_t));
- //update rowner
+ // Update rowner
memcpy(&(dst->rownerID), &(src->rownerID), sizeof(OicUuid_t));
- //update deviceuuid
+ // Update deviceuuid
memcpy(&(dst->deviceID), &(src->deviceID), sizeof(OicUuid_t));
- //Update owned status
+ // Update owned status
if(dst->owned != src->owned)
{
dst->owned = src->owned;
#ifdef MULTIPLE_OWNER
if(src->mom)
{
- OIC_LOG(DEBUG, TAG, "dectected 'mom' property");
+ OIC_LOG(DEBUG, TAG, "Detected 'mom' property");
if(NULL == dst->mom)
{
dst->mom = (OicSecMom_t*)OICCalloc(1, sizeof(OicSecMom_t));
- if(NULL != dst->mom)
+ if (NULL == dst->mom)
{
- dst->mom->mode = src->mom->mode;
+ result = OC_STACK_NO_MEMORY;
}
}
+
+ if (NULL != dst->mom)
+ {
+ dst->mom->mode = src->mom->mode;
+ }
}
#endif //MULTIPLE_OWNER
}
+
+ return result;
}
#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
ehRet = OC_EH_NOT_ACCEPTABLE;
goto exit;
}
- //Update gDoxm based on newDoxm
- updateWriteableProperty(newDoxm, gDoxm);
+
+ // Update gDoxm based on newDoxm
+ res = DoxmUpdateWriteableProperty(newDoxm, gDoxm);
+ if (OC_STACK_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "gDoxm properties were not able to be updated so we cannot handle the request.");
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
#ifdef MULTIPLE_OWNER
EXPECT_FALSE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
}
+
+TEST_F(DoxmComparisonTests, createMom)
+{
+ DoxmTestParameter param1 =
+ {
+ { "oxmType1" },
+ { OIC_JUST_WORKS },
+ OIC_JUST_WORKS,
+ SYMMETRIC_PAIR_WISE_KEY,
+ false,
+ { 0 }, // m_deviceID
+ false,
+ { 0 }, // m_owner
+ {},
+ OIC_MULTIPLE_OWNER_ENABLE,
+ { 0 } // m_rownerID
+ };
+ GenerateDoxmTestParameterUUIDs(¶m1);
+
+ DoxmTestParameter param2 = param1;
+
+ DoxmBinFromParameters(param1, param2);
+
+ OICFreeAndSetToNull(reinterpret_cast<void**>(&m_doxm2->mom));
+
+ OCStackResult result = DoxmUpdateWriteableProperty(m_doxm1, m_doxm2);
+ EXPECT_TRUE(OC_STACK_OK == result);
+
+ EXPECT_TRUE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+}
+
+TEST_F(DoxmComparisonTests, updateMomEnable)
+{
+ DoxmTestParameter param1 =
+ {
+ { "oxmType1" },
+ { OIC_JUST_WORKS },
+ OIC_JUST_WORKS,
+ SYMMETRIC_PAIR_WISE_KEY,
+ false,
+ { 0 }, // m_deviceID
+ false,
+ { 0 }, // m_owner
+ {},
+ OIC_MULTIPLE_OWNER_DISABLE,
+ { 0 } // m_rownerID
+ };
+ GenerateDoxmTestParameterUUIDs(¶m1);
+
+ DoxmTestParameter param2 = param1;
+
+ DoxmBinFromParameters(param1, param2);
+
+ m_doxm1->mom->mode = OIC_MULTIPLE_OWNER_ENABLE;
+
+ EXPECT_FALSE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+
+ OCStackResult result = DoxmUpdateWriteableProperty(m_doxm1, m_doxm2);
+ EXPECT_TRUE(OC_STACK_OK == result);
+
+ EXPECT_TRUE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+}
+
+TEST_F(DoxmComparisonTests, updateMomDisable)
+{
+ DoxmTestParameter param1 =
+ {
+ { "oxmType1" },
+ { OIC_JUST_WORKS },
+ OIC_JUST_WORKS,
+ SYMMETRIC_PAIR_WISE_KEY,
+ false,
+ { 0 }, // m_deviceID
+ false,
+ { 0 }, // m_owner
+ {},
+ OIC_MULTIPLE_OWNER_ENABLE,
+ { 0 } // m_rownerID
+ };
+ GenerateDoxmTestParameterUUIDs(¶m1);
+
+ DoxmTestParameter param2 = param1;
+
+ DoxmBinFromParameters(param1, param2);
+
+ m_doxm1->mom->mode = OIC_MULTIPLE_OWNER_DISABLE;
+
+ EXPECT_FALSE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+
+ OCStackResult result = DoxmUpdateWriteableProperty(m_doxm1, m_doxm2);
+ EXPECT_TRUE(OC_STACK_OK == result);
+
+ EXPECT_TRUE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+}
+
+TEST_F(DoxmComparisonTests, updateMomEnableDisable)
+{
+ DoxmTestParameter param1 =
+ {
+ { "oxmType1" },
+ { OIC_JUST_WORKS },
+ OIC_JUST_WORKS,
+ SYMMETRIC_PAIR_WISE_KEY,
+ false,
+ { 0 }, // m_deviceID
+ false,
+ { 0 }, // m_owner
+ {},
+ OIC_MULTIPLE_OWNER_DISABLE,
+ { 0 } // m_rownerID
+ };
+ GenerateDoxmTestParameterUUIDs(¶m1);
+
+ DoxmTestParameter param2 = param1;
+
+ DoxmBinFromParameters(param1, param2);
+
+ m_doxm1->mom->mode = OIC_MULTIPLE_OWNER_ENABLE;
+
+ OCStackResult result = DoxmUpdateWriteableProperty(m_doxm1, m_doxm2);
+ EXPECT_TRUE(OC_STACK_OK == result);
+
+ EXPECT_TRUE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+
+ m_doxm1->mom->mode = OIC_MULTIPLE_OWNER_DISABLE;
+
+ result = DoxmUpdateWriteableProperty(m_doxm1, m_doxm2);
+ EXPECT_TRUE(OC_STACK_OK == result);
+
+ EXPECT_TRUE(AreDoxmBinPropertyValuesEqual(m_doxm1, m_doxm2));
+}
#endif // #ifdef MULTIPLE_OWNER