Merge test folder of test branch
[iotivity.git] / test / src / tc / pm / gtest / csdk / src / btc / PMCsdkMotTest.cpp
1 /******************************************************************
2  *
3  * Copyright 2017 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *
20  ******************************************************************/
21 #include "PMCsdkHelper.h"
22 #include "PMCsdkMotHelper.h"
23 #include "PMCsdkUtilityHelper.h"
24
25 #ifdef __MOT__
26
27 class PMCsdkMotTest_btc: public ::testing::Test
28 {
29 protected:
30     OCProvisionDev_t *m_UnownList, *m_OwnList, *m_motEnabledDevList, *m_motOwnedDevList;
31     OicSecAcl_t *m_Acl, *m_Acl1, *m_Acl2;
32     PMCsdkHelper m_PMHelper;
33     PMCsdkMotHelper m_PMMotHelper;
34     bool isSubowner;
35
36     virtual void SetUp()
37     {
38         CommonUtil::killApp(KILL_SERVERS);
39         CommonUtil::waitInSecond(DELAY_MEDIUM);
40         PMCsdkUtilityHelper::removeAllResFile();
41         CommonUtil::waitInSecond(DELAY_MEDIUM);
42         CommonUtil::copyFile(PRECONFIG_SERVER1_CBOR_BACKUP, PRECONFIG_SERVER1_CBOR);
43         CommonUtil::copyFile(PRECONFIG_SERVER2_CBOR_BACKUP, PRECONFIG_SERVER2_CBOR);
44         CommonUtil::copyFile(RANDOMPIN_SERVER_CBOR_BACKUP, RANDOMPIN_SERVER_CBOR);
45         CommonUtil::copyFile(CLIENT_CBOR_BACKUP, CLIENT_CBOR);
46         CommonUtil::copyFile(JUSTWORKS_SERVER7_CBOR_BACKUP, JUSTWORKS_SERVER7_CBOR);
47         CommonUtil::copyFile(PRECONFIG_SERVER2_CBOR_BACKUP, PRECONFIG_SERVER2_CBOR);
48         CommonUtil::copyFile(MOT_CLIENT_CBOR_BACKUP, MOT_CLIENT_CBOR);
49         m_motEnabledDevList = NULL;
50         m_motOwnedDevList = NULL;
51         m_UnownList = NULL;
52         m_OwnList = NULL;
53     }
54
55     virtual void TearDown()
56     {
57         CommonTestUtil::runCommonTCTearDownPart();
58         CommonUtil::killApp(KILL_SERVERS);
59     }
60 };
61
62 /**
63  * @since           2016-09-10
64  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
65  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
66  * @see             OCStackResult OCInitPM(const char* dbPath)
67  * @objective       Test OCDiscoverMultipleOwnerEnabledDevices positively with waittime = DISCOVERY_TIMEOUT
68  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
69  * @test_data       waittime = DISCOVERY_TIMEOUT
70  * @pre_condition   Start Mot Enabled justworks simulators
71  * @procedure       1. call OCRegisterPersistentStorageHandler
72  *                  2. call OCInit
73  *                  3. call OCInitPM
74  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
75  * @post_condition  none
76  * @expected        OCDiscoverMultipleOwnerEnabledDevices will return OC_STACK_OK
77  */
78 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
79 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledDevices_RV_SRC_P)
80 {
81     CommonUtil::launchApp(JUSTWORKS_SERVER7);
82
83     if (!m_PMMotHelper.initMotClient())
84     {
85         SET_FAILURE(m_PMMotHelper.getFailureMessage());
86         return;
87     }
88
89     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
90                     &m_motEnabledDevList, OC_STACK_OK))
91     {
92         SET_FAILURE(m_PMMotHelper.getFailureMessage());
93     }
94 }
95 #endif
96
97 /**
98  * @since           2016-09-10
99  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
100  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
101  * @see             OCStackResult OCInitPM(const char* dbPath)
102  * @objective       Test OCDiscoverMultipleOwnerEnabledDevices positively with waittime = 1
103  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
104  * @test_data       waittime = 1
105  * @pre_condition   Start Mot Enabled justworks simulators
106  * @procedure       1. call OCRegisterPersistentStorageHandler
107  *                  2. call OCInit
108  *                  3. call OCInitPM
109  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
110  * @post_condition  none
111  * @expected        OCDiscoverMultipleOwnerEnabledDevices will return OC_STACK_OK
112  */
113 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
114 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledDevices_LBV_P)
115 {
116     CommonUtil::launchApp(JUSTWORKS_SERVER7);
117
118     if (!m_PMMotHelper.initMotClient())
119     {
120         SET_FAILURE(m_PMMotHelper.getFailureMessage());
121         return;
122     }
123
124     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT_ONE,
125                     &m_motEnabledDevList, OC_STACK_OK))
126     {
127         SET_FAILURE(m_PMMotHelper.getFailureMessage());
128     }
129 }
130 #endif
131
132 /**
133  * @since           2016-09-10
134  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
135  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
136  * @see             OCStackResult OCInitPM(const char* dbPath)
137  * @objective       Test OCDiscoverMultipleOwnerEnabledDevices negatively with waittime = 0
138  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
139  * @test_data       waittime = 0
140  * @pre_condition   Start Mot Enabled justworks simulators
141  * @procedure       1. call OCRegisterPersistentStorageHandler
142  *                  2. call OCInit
143  *                  3. call OCInitPM
144  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
145  * @post_condition  none
146  * @expected        OCDiscoverMultipleOwnerEnabledDevices will return OC_STACK_INVALID_PARAM
147  */
148 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
149 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledDevices_LOBV_N)
150 {
151     CommonUtil::launchApp(JUSTWORKS_SERVER7);
152
153     if (!m_PMMotHelper.initMotClient())
154     {
155         SET_FAILURE(m_PMMotHelper.getFailureMessage());
156         return;
157     }
158
159     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT_ZERO,
160                     &m_motEnabledDevList, OC_STACK_INVALID_PARAM))
161     {
162         SET_FAILURE(m_PMMotHelper.getFailureMessage());
163     }
164 }
165 #endif
166
167 /**
168  * @since           2016-09-10
169  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
170  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
171  * @see             OCStackResult OCInitPM(const char* dbPath)
172  * @objective       Test OCDiscoverMultipleOwnerEnabledDevices negatively with ppList = NULL
173  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
174  * @test_data       ppList = NULL
175  * @pre_condition   Start Mot Enabled justworks simulators
176  * @procedure       1. call OCRegisterPersistentStorageHandler
177  *                  2. call OCInit
178  *                  3. call OCInitPM
179  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
180  * @post_condition  none
181  * @expected        OCDiscoverMultipleOwnerEnabledDevices will return OC_STACK_INVALID_PARAM
182  */
183 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
184 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledDevicesDevlist_NV_N)
185 {
186     CommonUtil::launchApp(JUSTWORKS_SERVER7);
187
188     if (!m_PMMotHelper.initMotClient())
189     {
190         SET_FAILURE(m_PMMotHelper.getFailureMessage());
191         return;
192     }
193
194     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT_ONE,
195                     NULL, OC_STACK_INVALID_PARAM))
196     {
197         SET_FAILURE(m_PMMotHelper.getFailureMessage());
198     }
199 }
200 #endif
201
202 /**
203  * @since           2017-03-21
204  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
205  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
206  * @see             OCStackResult OCInitPM(const char* dbPath)
207  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
208  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
209  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
210  * @objective       Test OCDiscoverMultipleOwnerEnabledSingleDevice positively with waittime = DISCOVERY_TIMEOUT
211  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds, const OicUuid_t *deviceID, OCProvisionDev_t **ppFoundDevice)
212  * @test_data       waittime = DISCOVERY_TIMEOUT
213  * @pre_condition   Start Mot Enabled justworks simulators
214  * @procedure       1. call OCRegisterPersistentStorageHandler
215  *                  2. call OCInit
216  *                  3. call OCInitPM
217  *                  4. call OCDiscoverUnownedDevices
218  *                  5. call OCDoOwnershipTransfer
219  *                  6. call OCDiscoverOwnedDevices
220  *                  7. call OCChangeMOTMode
221  *                  8. call OCDiscoverMultipleOwnerEnabledSingleDevice
222  * @post_condition  none
223  * @expected        OCDiscoverMultipleOwnerEnabledSingleDevice will return OC_STACK_OK
224  */
225 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
226 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledSingleDevice_RV_SRC_P)
227 {
228     CommonUtil::launchApp(PRECONFIG_SERVER1);
229     CommonUtil::launchApp(PRECONFIG_SERVER2);
230
231     if (!m_PMHelper.initProvisionClient())
232     {
233         SET_FAILURE(m_PMHelper.getFailureMessage());
234         return;
235     }
236
237     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
238                     &m_UnownList, OC_STACK_OK))
239     {
240         SET_FAILURE(m_PMHelper.getFailureMessage());
241         return;
242     }
243
244     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
245                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
246     {
247         SET_FAILURE(m_PMHelper.getFailureMessage());
248         return;
249     }
250
251     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
252     {
253         SET_FAILURE(m_PMHelper.getFailureMessage());
254         return;
255     }
256
257     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
258
259     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
260     {
261         SET_FAILURE(m_PMMotHelper.getFailureMessage());
262         return;
263     }
264
265     OicUuid_t deviceUuid = targetOwnedDev->doxm->deviceID;
266
267     if (!m_PMMotHelper.discoverMultipleOwnerEnabledSingleDevice(DISCOVERY_TIMEOUT,&deviceUuid,
268                     &m_motEnabledDevList, OC_STACK_OK))
269     {
270         SET_FAILURE(m_PMMotHelper.getFailureMessage());
271     }
272 }
273 #endif
274
275 /**
276  * @since           2017-03-21
277  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
278  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
279  * @see             OCStackResult OCInitPM(const char* dbPath)
280  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
281  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
282  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
283  * @objective       Test OCDiscoverMultipleOwnerEnabledSingleDevice positively with waittime = DISCOVERY_TIMEOUT_ONE
284  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds, const OicUuid_t *deviceID, OCProvisionDev_t **ppFoundDevice)
285  * @test_data       waittime = DISCOVERY_TIMEOUT_ONE
286  * @pre_condition   Start Mot Enabled justworks simulators
287  * @procedure       1. call OCRegisterPersistentStorageHandler
288  *                  2. call OCInit
289  *                  3. call OCInitPM
290  *                  4. call OCDiscoverUnownedDevices
291  *                  5. call OCDoOwnershipTransfer
292  *                  6. call OCDiscoverOwnedDevices
293  *                  7. call OCChangeMOTMode
294  *                  8. call OCDiscoverMultipleOwnerEnabledSingleDevice
295  * @post_condition  none
296  * @expected        OCDiscoverMultipleOwnerEnabledSingleDevice will return OC_STACK_OK
297  */
298 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
299 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledSingleDevice_LBV_P)
300 {
301     CommonUtil::launchApp(PRECONFIG_SERVER1);
302     CommonUtil::launchApp(PRECONFIG_SERVER2);
303
304     if (!m_PMHelper.initProvisionClient())
305     {
306         SET_FAILURE(m_PMHelper.getFailureMessage());
307         return;
308     }
309
310     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
311                     &m_UnownList, OC_STACK_OK))
312     {
313         SET_FAILURE(m_PMHelper.getFailureMessage());
314         return;
315     }
316
317     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
318                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
319     {
320         SET_FAILURE(m_PMHelper.getFailureMessage());
321         return;
322     }
323
324     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
325     {
326         SET_FAILURE(m_PMHelper.getFailureMessage());
327         return;
328     }
329
330     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
331
332     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
333     {
334         SET_FAILURE(m_PMMotHelper.getFailureMessage());
335         return;
336     }
337
338     OicUuid_t deviceUuid = targetOwnedDev->doxm->deviceID;
339
340     if (!m_PMMotHelper.discoverMultipleOwnerEnabledSingleDevice(DISCOVERY_TIMEOUT_ONE, &deviceUuid,
341                     &m_motEnabledDevList, OC_STACK_OK))
342     {
343         SET_FAILURE(m_PMMotHelper.getFailureMessage());
344     }
345 }
346 #endif
347
348 /**
349  * @since           2017-03-21
350  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
351  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
352  * @see             OCStackResult OCInitPM(const char* dbPath)
353  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
354  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
355  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
356  * @objective       Test OCDiscoverMultipleOwnerEnabledSingleDevice negatively with waittime = DISCOVERY_TIMEOUT_ZERO
357  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds, const OicUuid_t *deviceID, OCProvisionDev_t **ppFoundDevice)
358  * @test_data       waittime = DISCOVERY_TIMEOUT_ZERO
359  * @pre_condition   Start Mot Enabled justworks simulators
360  * @procedure       1. call OCRegisterPersistentStorageHandler
361  *                  2. call OCInit
362  *                  3. call OCInitPM
363  *                  4. call OCDiscoverUnownedDevices
364  *                  5. call OCDoOwnershipTransfer
365  *                  6. call OCDiscoverOwnedDevices
366  *                  7. call OCChangeMOTMode
367  *                  8. call OCDiscoverMultipleOwnerEnabledSingleDevice
368  * @post_condition  none
369  * @expected        OCDiscoverMultipleOwnerEnabledSingleDevice will return OC_STACK_INVALID_PARAM
370  */
371 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
372 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledSingleDevice_LOBV_N)
373 {
374     CommonUtil::launchApp(PRECONFIG_SERVER1);
375     CommonUtil::launchApp(PRECONFIG_SERVER2);
376
377     if (!m_PMHelper.initProvisionClient())
378     {
379         SET_FAILURE(m_PMHelper.getFailureMessage());
380         return;
381     }
382
383     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
384                     &m_UnownList, OC_STACK_OK))
385     {
386         SET_FAILURE(m_PMHelper.getFailureMessage());
387         return;
388     }
389
390     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
391                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
392     {
393         SET_FAILURE(m_PMHelper.getFailureMessage());
394         return;
395     }
396
397     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
398     {
399         SET_FAILURE(m_PMHelper.getFailureMessage());
400         return;
401     }
402
403     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
404
405     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
406     {
407         SET_FAILURE(m_PMMotHelper.getFailureMessage());
408         return;
409     }
410
411     OicUuid_t deviceUuid = targetOwnedDev->doxm->deviceID;
412
413     if (!m_PMMotHelper.discoverMultipleOwnerEnabledSingleDevice(DISCOVERY_TIMEOUT_ZERO, &deviceUuid,
414                     &m_motEnabledDevList, OC_STACK_INVALID_PARAM))
415     {
416         SET_FAILURE(m_PMMotHelper.getFailureMessage());
417     }
418 }
419 #endif
420
421 /**
422  * @since           2017-03-21
423  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
424  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
425  * @see             OCStackResult OCInitPM(const char* dbPath)
426  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
427  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
428  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
429  * @objective       Test OCDiscoverMultipleOwnerEnabledSingleDevice negatively with deviceID = NULL
430  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds, const OicUuid_t *deviceID, OCProvisionDev_t **ppFoundDevice)
431  * @test_data       deviceID = NULL
432  * @pre_condition   Start Mot Enabled justworks simulators
433  * @procedure       1. call OCRegisterPersistentStorageHandler
434  *                  2. call OCInit
435  *                  3. call OCInitPM
436  *                  4. call OCDiscoverUnownedDevices
437  *                  5. call OCDoOwnershipTransfer
438  *                  6. call OCDiscoverOwnedDevices
439  *                  7. call OCChangeMOTMode
440  *                  8. call OCDiscoverMultipleOwnerEnabledSingleDevice
441  * @post_condition  none
442  * @expected        OCDiscoverMultipleOwnerEnabledSingleDevice will return OC_STACK_INVALID_PARAM
443  */
444 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
445 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledSingleDeviceDeviceID_NV_N)
446 {
447     CommonUtil::launchApp(PRECONFIG_SERVER1);
448     CommonUtil::launchApp(PRECONFIG_SERVER2);
449
450     if (!m_PMHelper.initProvisionClient())
451     {
452         SET_FAILURE(m_PMHelper.getFailureMessage());
453         return;
454     }
455
456     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
457                     &m_UnownList, OC_STACK_OK))
458     {
459         SET_FAILURE(m_PMHelper.getFailureMessage());
460         return;
461     }
462
463     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
464                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
465     {
466         SET_FAILURE(m_PMHelper.getFailureMessage());
467         return;
468     }
469
470     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
471     {
472         SET_FAILURE(m_PMHelper.getFailureMessage());
473         return;
474     }
475
476     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
477
478     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
479     {
480         SET_FAILURE(m_PMMotHelper.getFailureMessage());
481         return;
482     }
483
484     if (!m_PMMotHelper.discoverMultipleOwnerEnabledSingleDevice(DISCOVERY_TIMEOUT, NULL,
485                     &m_motEnabledDevList, OC_STACK_INVALID_PARAM))
486     {
487         SET_FAILURE(m_PMMotHelper.getFailureMessage());
488     }
489 }
490 #endif
491
492 /**
493  * @since           2017-03-21
494  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
495  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
496  * @see             OCStackResult OCInitPM(const char* dbPath)
497  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
498  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
499  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
500  * @objective       Test OCDiscoverMultipleOwnerEnabledSingleDevice negatively with ppFoundDevice = NULL
501  * @target          OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds, const OicUuid_t *deviceID, OCProvisionDev_t **ppFoundDevice)
502  * @test_data       ppFoundDevice = NULL
503  * @pre_condition   Start Mot Enabled justworks simulators
504  * @procedure       1. call OCRegisterPersistentStorageHandler
505  *                  2. call OCInit
506  *                  3. call OCInitPM
507  *                  4. call OCDiscoverUnownedDevices
508  *                  5. call OCDoOwnershipTransfer
509  *                  6. call OCDiscoverOwnedDevices
510  *                  7. call OCChangeMOTMode
511  *                  8. call OCDiscoverMultipleOwnerEnabledSingleDevice
512  * @post_condition  none
513  * @expected        OCDiscoverMultipleOwnerEnabledSingleDevice will return OC_STACK_INVALID_PARAM
514  */
515 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
516 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnerEnabledSingleDevicePpFoundDevice_NV_N)
517 {
518     CommonUtil::launchApp(PRECONFIG_SERVER1);
519     CommonUtil::launchApp(PRECONFIG_SERVER2);
520
521     if (!m_PMHelper.initProvisionClient())
522     {
523         SET_FAILURE(m_PMHelper.getFailureMessage());
524         return;
525     }
526
527     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
528                     &m_UnownList, OC_STACK_OK))
529     {
530         SET_FAILURE(m_PMHelper.getFailureMessage());
531         return;
532     }
533
534     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
535                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
536     {
537         SET_FAILURE(m_PMHelper.getFailureMessage());
538         return;
539     }
540
541     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
542     {
543         SET_FAILURE(m_PMHelper.getFailureMessage());
544         return;
545     }
546
547     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
548
549     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
550     {
551         SET_FAILURE(m_PMMotHelper.getFailureMessage());
552         return;
553     }
554
555     OicUuid_t deviceUuid = targetOwnedDev->doxm->deviceID;
556
557     if (!m_PMMotHelper.discoverMultipleOwnerEnabledSingleDevice(DISCOVERY_TIMEOUT, &deviceUuid,
558                     NULL, OC_STACK_INVALID_PARAM))
559     {
560         SET_FAILURE(m_PMMotHelper.getFailureMessage());
561     }
562 }
563 #endif
564
565 /**
566  * @since           2016-09-10
567  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
568  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
569  * @see             OCStackResult OCInitPM(const char* dbPath)
570  * @objective       Test OCDiscoverMultipleOwnedDevices positively with waittime = DISCOVERY_TIMEOUT
571  * @target          OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
572  * @test_data       waittime = DISCOVERY_TIMEOUT
573  * @pre_condition   Start Mot Enabled justworks simulators
574  * @procedure       1. call OCRegisterPersistentStorageHandler
575  *                  2. call OCInit
576  *                  3. call OCInitPM
577  *                  4. call OCDiscoverMultipleOwnedDevices
578  * @post_condition  none
579  * @expected        OCDiscoverMultipleOwnedDevices will return OC_STACK_OK
580  */
581 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
582 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnedDevices_RV_SRC_P)
583 {
584     CommonUtil::launchApp(JUSTWORKS_SERVER7);
585
586     if (!m_PMMotHelper.initMotClient())
587     {
588         SET_FAILURE(m_PMMotHelper.getFailureMessage());
589         return;
590     }
591
592     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT,
593                     &m_motEnabledDevList, OC_STACK_OK))
594     {
595         SET_FAILURE(m_PMMotHelper.getFailureMessage());
596     }
597 }
598 #endif
599
600 /**
601  * @since           2016-09-10
602  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
603  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
604  * @see             OCStackResult OCInitPM(const char* dbPath)
605  * @objective       Test OCDiscoverMultipleOwnedDevices positively with waittime = 1
606  * @target          OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
607  * @test_data       waittime = 1
608  * @pre_condition   Start Mot Enabled justworks simulators
609  * @procedure       1. call OCRegisterPersistentStorageHandler
610  *                  2. call OCInit
611  *                  3. call OCInitPM
612  *                  4. call OCDiscoverMultipleOwnedDevices
613  * @post_condition  none
614  * @expected        OCDiscoverMultipleOwnedDevices will return OC_STACK_OK
615  */
616 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
617 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnedDevices_LBV_P)
618 {
619     CommonUtil::launchApp(JUSTWORKS_SERVER7);
620
621     if (!m_PMMotHelper.initMotClient())
622     {
623         SET_FAILURE(m_PMMotHelper.getFailureMessage());
624         return;
625     }
626
627     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT_ONE,
628                     &m_motEnabledDevList, OC_STACK_OK))
629     {
630         SET_FAILURE(m_PMMotHelper.getFailureMessage());
631     }
632 }
633 #endif
634
635 /**
636  * @since           2016-09-10
637  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
638  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
639  * @see             OCStackResult OCInitPM(const char* dbPath)
640  * @objective       Test OCDiscoverMultipleOwnedDevices negatively with waittime = 0
641  * @target          OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
642  * @test_data       waittime = 0
643  * @pre_condition   Start Mot Enabled justworks simulators
644  * @procedure       1. call OCRegisterPersistentStorageHandler
645  *                  2. call OCInit
646  *                  3. call OCInitPM
647  *                  4. call OCDiscoverMultipleOwnedDevices
648  * @post_condition  none
649  * @expected        OCDiscoverMultipleOwnedDevices will return OC_STACK_INVALID_PARAM
650  */
651 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
652 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnedDevices_LOBV_N)
653 {
654     CommonUtil::launchApp(JUSTWORKS_SERVER7);
655
656     if (!m_PMMotHelper.initMotClient())
657     {
658         SET_FAILURE(m_PMMotHelper.getFailureMessage());
659         return;
660     }
661
662     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT_ZERO,
663                     &m_motEnabledDevList, OC_STACK_INVALID_PARAM))
664     {
665         SET_FAILURE(m_PMMotHelper.getFailureMessage());
666     }
667 }
668 #endif
669
670 /**
671  * @since           2016-09-10
672  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
673  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
674  * @see             OCStackResult OCInitPM(const char* dbPath)
675  * @objective       Test OCDiscoverMultipleOwnedDevices negatively with ppList = NULL
676  * @target          OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
677  * @test_data       ppList = NULL
678  * @pre_condition   Start Mot Enabled justworks simulators
679  * @procedure       1. call OCRegisterPersistentStorageHandler
680  *                  2. call OCInit
681  *                  3. call OCInitPM
682  *                  4. call OCDiscoverMultipleOwnedDevices
683  * @post_condition  none
684  * @expected        OCDiscoverMultipleOwnedDevices will return OC_STACK_INVALID_PARAM
685  */
686 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
687 TEST_F(PMCsdkMotTest_btc, OCDiscoverMultipleOwnedDevicesDevlist_NV_N)
688 {
689     CommonUtil::launchApp(JUSTWORKS_SERVER7);
690
691     if (!m_PMMotHelper.initMotClient())
692     {
693         SET_FAILURE(m_PMMotHelper.getFailureMessage());
694         return;
695     }
696
697     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT_ONE,
698                     NULL, OC_STACK_INVALID_PARAM))
699     {
700         SET_FAILURE(m_PMMotHelper.getFailureMessage());
701     }
702 }
703 #endif
704
705 /**
706  * @since           2016-09-10
707  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
708  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
709  * @see             OCStackResult OCInitPM(const char* dbPath)
710  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
711  * @objective       Test OCAddPreconfigPin positively with regular data
712  * @target          OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
713  * @test_data       regular data for the API
714  * @pre_condition   Start Mot Enabled justworks simulators
715  * @procedure       1. call OCRegisterPersistentStorageHandler
716  *                  2. call OCInit
717  *                  3. call OCInitPM
718  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
719  *                  5. call OCAddPreconfigPin
720  * @post_condition  none
721  * @expected        OCAddPreconfigPin will return OC_STACK_OK
722  */
723 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
724 TEST_F(PMCsdkMotTest_btc, OCAddPreconfigPin_RV_SRC_P)
725 {
726     CommonUtil::launchApp(JUSTWORKS_SERVER7);
727
728     if (!m_PMMotHelper.initMotClient())
729     {
730         SET_FAILURE(m_PMMotHelper.getFailureMessage());
731         return;
732     }
733
734     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
735                     &m_motEnabledDevList, OC_STACK_OK))
736     {
737         SET_FAILURE(m_PMMotHelper.getFailureMessage());
738         return;
739     }
740
741     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, 1);
742
743     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
744     {
745         SET_FAILURE(m_PMMotHelper.getFailureMessage());
746     }
747 }
748 #endif
749
750 /**
751  * @since           2017-03-10
752  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
753  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
754  * @see             OCStackResult OCInitPM(const char* dbPath)
755  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
756  * @objective       Test OCAddPreconfigPin negatively with targetDeviceInfo=NULL
757  * @target          OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
758  * @test_data       targetDeviceInfo=NULL
759  * @pre_condition   Start Mot Enabled justworks simulators
760  * @procedure       1. call OCRegisterPersistentStorageHandler
761  *                  2. call OCInit
762  *                  3. call OCInitPM
763  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
764  *                  5. call OCAddPreconfigPin
765  * @post_condition  none
766  * @expected        OCAddPreconfigPin will return OC_STACK_INVALID_PARAM
767  */
768 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
769 TEST_F(PMCsdkMotTest_btc, OCAddPreconfigPinTargetDeviceInfo_NV_N)
770 {
771     CommonUtil::launchApp(JUSTWORKS_SERVER7);
772
773     if (!m_PMMotHelper.initMotClient())
774     {
775         SET_FAILURE(m_PMMotHelper.getFailureMessage());
776         return;
777     }
778
779     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
780                     &m_motEnabledDevList, OC_STACK_OK))
781     {
782         SET_FAILURE(m_PMMotHelper.getFailureMessage());
783         return;
784     }
785
786     if (!m_PMMotHelper.addPreconfigPIN(NULL, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_INVALID_PARAM))
787     {
788         SET_FAILURE(m_PMMotHelper.getFailureMessage());
789     }
790 }
791 #endif
792
793 /**
794  * @since           2017-03-10
795  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
796  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
797  * @see             OCStackResult OCInitPM(const char* dbPath)
798  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
799  * @objective       Test OCAddPreconfigPin negatively with preconfPIN=NULL
800  * @target          OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
801  * @test_data       preconfPIN=NULL
802  * @pre_condition   Start Mot Enabled justworks simulators
803  * @procedure       1. call OCRegisterPersistentStorageHandler
804  *                  2. call OCInit
805  *                  3. call OCInitPM
806  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
807  *                  5. call OCAddPreconfigPin
808  * @post_condition  none
809  * @expected        OCAddPreconfigPin will return OC_STACK_INVALID_PARAM
810  */
811 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
812 TEST_F(PMCsdkMotTest_btc, OCAddPreconfigPinPreconfPIN_NV_N)
813 {
814     CommonUtil::launchApp(JUSTWORKS_SERVER7);
815
816     if (!m_PMMotHelper.initMotClient())
817     {
818         SET_FAILURE(m_PMMotHelper.getFailureMessage());
819         return;
820     }
821
822     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
823                     &m_motEnabledDevList, OC_STACK_OK))
824     {
825         SET_FAILURE(m_PMMotHelper.getFailureMessage());
826         return;
827     }
828
829     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, 1);
830
831     if (!m_PMMotHelper.addPreconfigPIN(targetDev, NULL, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_INVALID_PARAM))
832     {
833         SET_FAILURE(m_PMMotHelper.getFailureMessage());
834     }
835 }
836 #endif
837
838 /**
839  * @since           2017-03-10
840  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
841  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
842  * @see             OCStackResult OCInitPM(const char* dbPath)
843  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
844  * @objective       Test OCAddPreconfigPin negatively with preconfPINLen=MOT_PRECONFIG_PIN_ZERO_SIZE
845  * @target          OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
846  * @test_data       preconfPINLen=MOT_PRECONFIG_PIN_ZERO_SIZE
847  * @pre_condition   Start Mot Enabled justworks simulators
848  * @procedure       1. call OCRegisterPersistentStorageHandler
849  *                  2. call OCInit
850  *                  3. call OCInitPM
851  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
852  *                  5. call OCAddPreconfigPin
853  * @post_condition  none
854  * @expected        OCAddPreconfigPin will return OC_STACK_INVALID_PARAM
855  */
856 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
857 TEST_F(PMCsdkMotTest_btc, OCAddPreconfigPinPreconfPINLen_LOBV_N)
858 {
859     CommonUtil::launchApp(JUSTWORKS_SERVER7);
860
861     if (!m_PMMotHelper.initMotClient())
862     {
863         SET_FAILURE(m_PMMotHelper.getFailureMessage());
864         return;
865     }
866
867     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
868                     &m_motEnabledDevList, OC_STACK_OK))
869     {
870         SET_FAILURE(m_PMMotHelper.getFailureMessage());
871         return;
872     }
873
874     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, 1);
875
876     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, MOT_PRECONFIG_PIN_ZERO_SIZE, OC_STACK_INVALID_PARAM))
877     {
878         SET_FAILURE(m_PMMotHelper.getFailureMessage());
879     }
880 }
881 #endif
882
883 /**
884  * @since           2016-09-10
885  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
886  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
887  * @see             OCStackResult OCInitPM(const char* dbPath)
888  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
889  * @see             OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
890  * @objective       Test OCAddPreconfigPin positively with regular data
891  * @target          OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
892  * @test_data       regular data for the API
893  * @pre_condition   Start Mot Enabled justworks simulators
894  * @procedure       1. call OCRegisterPersistentStorageHandler
895  *                  2. call OCInit
896  *                  3. call OCInitPM
897  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
898  *                  5. call OCAddPreconfigPin
899  *                  6. call OCDoMultipleOwnershipTransfer
900  * @post_condition  none
901  * @expected        OCDoMultipleOwnershipTransfer will return OC_STACK_OK
902  */
903 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
904 TEST_F(PMCsdkMotTest_btc, DoMultipleOwnershipTransfer_RV_SRC_P)
905 {
906     CommonUtil::launchApp(JUSTWORKS_SERVER7);
907
908     if (!m_PMMotHelper.initMotClient())
909     {
910         SET_FAILURE(m_PMMotHelper.getFailureMessage());
911         return;
912     }
913
914     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
915                     &m_motEnabledDevList, OC_STACK_OK))
916     {
917         SET_FAILURE(m_PMMotHelper.getFailureMessage());
918         return;
919     }
920
921     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
922
923     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
924     {
925         SET_FAILURE(m_PMMotHelper.getFailureMessage());
926         return;
927     }
928
929     if (!m_PMMotHelper.doMultipleOwnershipTransfer((void*)MOT_CTX, m_motEnabledDevList,
930                     PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
931     {
932         SET_FAILURE(m_PMMotHelper.getFailureMessage());
933     }
934 }
935 #endif
936
937 /**
938  * @since           2016-09-10
939  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
940  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
941  * @see             OCStackResult OCInitPM(const char* dbPath)
942  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
943  * @see             OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
944  * @objective       Test OCAddPreconfigPin negatively with resultCallback as NULL
945  * @target          OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
946  * @test_data       resultCallback = NULL
947  * @pre_condition   Start Mot Enabled justworks simulators
948  * @procedure       1. call OCRegisterPersistentStorageHandler
949  *                  2. call OCInit
950  *                  3. call OCInitPM
951  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
952  *                  5. call OCAddPreconfigPin
953  *                  6. call OCDoMultipleOwnershipTransfer
954  * @post_condition  none
955  * @expected        OCDoMultipleOwnershipTransfer will return OC_STACK_INVALID_CALLBACK
956  */
957 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
958 TEST_F(PMCsdkMotTest_btc, OCDoMultipleOwnershipTransferCB_NV_N)
959 {
960     CommonUtil::launchApp(JUSTWORKS_SERVER7);
961
962     if (!m_PMMotHelper.initMotClient())
963     {
964         SET_FAILURE(m_PMMotHelper.getFailureMessage());
965         return;
966     }
967
968     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
969                     &m_motEnabledDevList, OC_STACK_OK))
970     {
971         SET_FAILURE(m_PMMotHelper.getFailureMessage());
972         return;
973     }
974
975     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
976
977     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
978     {
979         SET_FAILURE(m_PMMotHelper.getFailureMessage());
980         return;
981     }
982
983     if (!m_PMMotHelper.doMultipleOwnershipTransfer((void*)MOT_CTX, m_motEnabledDevList,
984                     NULL, OC_STACK_INVALID_CALLBACK))
985     {
986         SET_FAILURE(m_PMMotHelper.getFailureMessage());
987     }
988 }
989 #endif
990
991 /**
992  * @since           2016-09-10
993  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
994  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
995  * @see             OCStackResult OCInitPM(const char* dbPath)
996  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
997  * @see             OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
998  * @objective       Test OCAddPreconfigPin negatively with targetDevices as NULL
999  * @target          OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1000  * @test_data       targetDevices = NULL
1001  * @pre_condition   Start Mot Enabled justworks simulators
1002  * @procedure       1. call OCRegisterPersistentStorageHandler
1003  *                  2. call OCInit
1004  *                  3. call OCInitPM
1005  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
1006  *                  5. call OCAddPreconfigPin
1007  *                  6. call OCDoMultipleOwnershipTransfer
1008  * @post_condition  none
1009  * @expected        OCDoMultipleOwnershipTransfer will return OC_STACK_INVALID_PARAM
1010  */
1011 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1012 TEST_F(PMCsdkMotTest_btc, OCDoMultipleOwnershipTransfer_NV_N)
1013 {
1014     CommonUtil::launchApp(JUSTWORKS_SERVER7);
1015
1016     if (!m_PMMotHelper.initMotClient())
1017     {
1018         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1019         return;
1020     }
1021
1022     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1023                     &m_motEnabledDevList, OC_STACK_OK))
1024     {
1025         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1026         return;
1027     }
1028
1029     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1030
1031     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
1032     {
1033         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1034         return;
1035     }
1036
1037     if (!m_PMMotHelper.doMultipleOwnershipTransfer((void*)MOT_CTX, NULL,
1038                     PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1039     {
1040         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1041     }
1042 }
1043 #endif
1044
1045 /**
1046  * @since           2016-09-10
1047  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1048  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1049  * @see             OCStackResult OCInitPM(const char* dbPath)
1050  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1051  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1052  * @objective       Test OCChangeMOTMode positively with regular data
1053  * @target          OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1054  * @test_data       regular data for the target API
1055  * @pre_condition   Start two justworks simulators
1056  * @procedure       1. call OCRegisterPersistentStorageHandler
1057  *                  2. call OCInit
1058  *                  3. call OCInitPM
1059  *                  4. call OCDiscoverUnownedDevices
1060  *                  5. call OCDoOwnershipTransfer
1061  *                  6. call OCDiscoverOwnedDevices
1062  *                  7. call OCChangeMOTMode
1063  * @post_condition  None
1064  * @expected        OCChangeMOTMode will return OC_STACK_OK
1065  */
1066 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1067 TEST_F(PMCsdkMotTest_btc, OCChangeMOTMode_RV_SRC_P)
1068 {
1069     CommonUtil::launchApp(PRECONFIG_SERVER1);
1070     CommonUtil::launchApp(PRECONFIG_SERVER2);
1071     CommonUtil::waitInSecond(DELAY_LONG);
1072
1073     if (!m_PMHelper.initProvisionClient())
1074     {
1075         SET_FAILURE(m_PMHelper.getFailureMessage());
1076         return;
1077     }
1078
1079     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1080                     &m_UnownList, OC_STACK_OK))
1081     {
1082         SET_FAILURE(m_PMHelper.getFailureMessage());
1083         return;
1084     }
1085
1086     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1087                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1088     {
1089         SET_FAILURE(m_PMHelper.getFailureMessage());
1090         return;
1091     }
1092
1093     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1094     {
1095         SET_FAILURE(m_PMHelper.getFailureMessage());
1096         return;
1097     }
1098
1099     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1100
1101     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1102     {
1103         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1104     }
1105 }
1106 #endif
1107
1108 /**
1109  * @since           2016-09-10
1110  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1111  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1112  * @see             OCStackResult OCInitPM(const char* dbPath)
1113  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1114  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1115  * @objective       Test OCChangeMOTMode positively with momType = OIC_MULTIPLE_OWNER_DISABLE
1116  * @target          OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1117  * @test_data       momType = OIC_MULTIPLE_OWNER_DISABLE
1118  * @pre_condition   Start two justworks simulators
1119  * @procedure       1. call OCRegisterPersistentStorageHandler
1120  *                  2. call OCInit
1121  *                  3. call OCInitPM
1122  *                  4. call OCDiscoverUnownedDevices
1123  *                  5. call OCDoOwnershipTransfer
1124  *                  6. call OCDiscoverOwnedDevices
1125  *                  7. call OCChangeMOTMode
1126  * @post_condition  None
1127  * @expected        OCChangeMOTMode will return OC_STACK_OK
1128  */
1129 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1130 TEST_F(PMCsdkMotTest_btc, OCChangeMOTMode_CLU_P)
1131 {
1132     CommonUtil::launchApp(PRECONFIG_SERVER1);
1133     CommonUtil::launchApp(PRECONFIG_SERVER2);
1134
1135     if (!m_PMHelper.initProvisionClient())
1136     {
1137         SET_FAILURE(m_PMHelper.getFailureMessage());
1138         return;
1139     }
1140
1141     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1142                     &m_UnownList, OC_STACK_OK))
1143     {
1144         SET_FAILURE(m_PMHelper.getFailureMessage());
1145         return;
1146     }
1147
1148     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1149                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1150     {
1151         SET_FAILURE(m_PMHelper.getFailureMessage());
1152         return;
1153     }
1154
1155     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1156     {
1157         SET_FAILURE(m_PMHelper.getFailureMessage());
1158         return;
1159     }
1160
1161     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1162
1163     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetDev, OIC_MULTIPLE_OWNER_DISABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1164     {
1165         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1166     }
1167 }
1168 #endif
1169
1170 /**
1171  * @since           2016-09-10
1172  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1173  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1174  * @see             OCStackResult OCInitPM(const char* dbPath)
1175  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1176  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1177  * @objective       Test OCChangeMOTMode negatively with momType greater Upper Boundary Value
1178  * @target          OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1179  * @test_data       momType greater Upper Boundary Value
1180  * @pre_condition   Start two justworks simulators
1181  * @procedure       1. call OCRegisterPersistentStorageHandler
1182  *                  2. call OCInit
1183  *                  3. call OCInitPM
1184  *                  4. call OCDiscoverUnownedDevices
1185  *                  5. call OCDoOwnershipTransfer
1186  *                  6. call OCDiscoverOwnedDevices
1187  *                  7. call OCChangeMOTMode
1188  * @post_condition  None
1189  * @expected        OCChangeMOTMode will return OC_STACK_INVALID_PARAM
1190  */
1191 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1192 TEST_F(PMCsdkMotTest_btc, OCChangeMOTMode_CLU_UOBV_N)
1193 {
1194     CommonUtil::launchApp(PRECONFIG_SERVER1);
1195     CommonUtil::launchApp(PRECONFIG_SERVER2);
1196
1197     if (!m_PMHelper.initProvisionClient())
1198     {
1199         SET_FAILURE(m_PMHelper.getFailureMessage());
1200         return;
1201     }
1202
1203     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1204                     &m_UnownList, OC_STACK_OK))
1205     {
1206         SET_FAILURE(m_PMHelper.getFailureMessage());
1207         return;
1208     }
1209
1210     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1211                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1212     {
1213         SET_FAILURE(m_PMHelper.getFailureMessage());
1214         return;
1215     }
1216
1217     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1218     {
1219         SET_FAILURE(m_PMHelper.getFailureMessage());
1220         return;
1221     }
1222
1223     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1224
1225     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetDev, (const OicSecMomType_t) OIC_MULTIPLE_OWNER_UOBV, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1226     {
1227         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1228     }
1229 }
1230 #endif
1231
1232 /**
1233  * @since           2016-09-10
1234  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1235  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1236  * @see             OCStackResult OCInitPM(const char* dbPath)
1237  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1238  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1239  * @objective       Test OCChangeMOTMode negatively with resultCallback = NULL
1240  * @target          OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1241  * @test_data       resultCallback = NULL
1242  * @pre_condition   Start two justworks simulators
1243  * @procedure       1. call OCRegisterPersistentStorageHandler
1244  *                  2. call OCInit
1245  *                  3. call OCInitPM
1246  *                  4. call OCDiscoverUnownedDevices
1247  *                  5. call OCDoOwnershipTransfer
1248  *                  6. call OCDiscoverOwnedDevices
1249  *                  7. call OCChangeMOTMode
1250  * @post_condition  None
1251  * @expected        OCChangeMOTMode will return OC_STACK_INVALID_CALLBACK
1252  */
1253 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1254 TEST_F(PMCsdkMotTest_btc, OCChangeMOTModeCb_NV_N)
1255 {
1256     CommonUtil::launchApp(PRECONFIG_SERVER1);
1257     CommonUtil::launchApp(PRECONFIG_SERVER2);
1258
1259     if (!m_PMHelper.initProvisionClient())
1260     {
1261         SET_FAILURE(m_PMHelper.getFailureMessage());
1262         return;
1263     }
1264
1265     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1266                     &m_UnownList, OC_STACK_OK))
1267     {
1268         SET_FAILURE(m_PMHelper.getFailureMessage());
1269         return;
1270     }
1271
1272     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1273                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1274     {
1275         SET_FAILURE(m_PMHelper.getFailureMessage());
1276         return;
1277     }
1278
1279     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1280     {
1281         SET_FAILURE(m_PMHelper.getFailureMessage());
1282         return;
1283     }
1284
1285     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1286
1287     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetDev, OIC_MULTIPLE_OWNER_ENABLE, NULL, OC_STACK_INVALID_CALLBACK))
1288     {
1289         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1290     }
1291 }
1292 #endif
1293
1294 /**
1295  * @since           2016-09-10
1296  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1297  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1298  * @see             OCStackResult OCInitPM(const char* dbPath)
1299  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1300  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1301  * @objective       Test OCChangeMOTMode negatively with targetDeviceInfo = NULL
1302  * @target          OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1303  * @test_data       targetDeviceInfo = NULL
1304  * @pre_condition   Start two justworks simulators
1305  * @procedure       1. call OCRegisterPersistentStorageHandler
1306  *                  2. call OCInit
1307  *                  3. call OCInitPM
1308  *                  4. call OCDiscoverUnownedDevices
1309  *                  5. call OCDoOwnershipTransfer
1310  *                  6. call OCDiscoverOwnedDevices
1311  *                  7. call OCChangeMOTMode
1312  * @post_condition  None
1313  * @expected        OCChangeMOTMode will return OC_STACK_INVALID_PARAM
1314  */
1315 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1316 TEST_F(PMCsdkMotTest_btc, OCChangeMOTModeDev_NV_N)
1317 {
1318     CommonUtil::launchApp(PRECONFIG_SERVER1);
1319     CommonUtil::launchApp(PRECONFIG_SERVER2);
1320
1321     if (!m_PMHelper.initProvisionClient())
1322     {
1323         SET_FAILURE(m_PMHelper.getFailureMessage());
1324         return;
1325     }
1326
1327     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1328                     &m_UnownList, OC_STACK_OK))
1329     {
1330         SET_FAILURE(m_PMHelper.getFailureMessage());
1331         return;
1332     }
1333
1334     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1335                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1336     {
1337         SET_FAILURE(m_PMHelper.getFailureMessage());
1338         return;
1339     }
1340
1341     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1342     {
1343         SET_FAILURE(m_PMHelper.getFailureMessage());
1344         return;
1345     }
1346
1347     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, NULL, OIC_MULTIPLE_OWNER_DISABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1348     {
1349         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1350     }
1351 }
1352 #endif
1353
1354 /**
1355  * @since           2016-09-10
1356  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1357  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1358  * @see             OCStackResult OCInitPM(const char* dbPath)
1359  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1360  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1361  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1362  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1363  * @objective       Test OCProvisionPreconfPin positively with regular data
1364  * @target          OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1365  * @test_data       regular data for the target API
1366  * @pre_condition   Start two justworks simulators
1367  * @procedure       1. call OCRegisterPersistentStorageHandler
1368  *                  2. call OCInit
1369  *                  3. call OCInitPM
1370  *                  4. call OCDiscoverUnownedDevices
1371  *                  5. call OCDoOwnershipTransfer
1372  *                  6. call OCDiscoverOwnedDevices
1373  *                  7. call OCChangeMOTMode
1374  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1375  *                  9. call OCProvisionPreconfPin
1376  * @post_condition  None
1377  * @expected        OCProvisionPreconfPin will return OC_STACK_OK
1378  */
1379 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1380 TEST_F(PMCsdkMotTest_btc, OCProvisionPreconfPin_RV_SRC_P)
1381 {
1382     CommonUtil::launchApp(PRECONFIG_SERVER1);
1383     CommonUtil::launchApp(PRECONFIG_SERVER2);
1384
1385     if (!m_PMHelper.initProvisionClient())
1386     {
1387         SET_FAILURE(m_PMHelper.getFailureMessage());
1388         return;
1389     }
1390
1391     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1392                     &m_UnownList, OC_STACK_OK))
1393     {
1394         SET_FAILURE(m_PMHelper.getFailureMessage());
1395         return;
1396     }
1397
1398     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1399                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1400     {
1401         SET_FAILURE(m_PMHelper.getFailureMessage());
1402         return;
1403     }
1404
1405     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1406     {
1407         SET_FAILURE(m_PMHelper.getFailureMessage());
1408         return;
1409     }
1410
1411     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1412
1413     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1414     {
1415         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1416         return;
1417     }
1418
1419     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1420                     &m_motEnabledDevList, OC_STACK_OK))
1421     {
1422         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1423         return;
1424     }
1425
1426     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1427
1428     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1429     {
1430         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1431     }
1432 }
1433 #endif
1434
1435 /**
1436  * @since           2017-03-10
1437  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1438  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1439  * @see             OCStackResult OCInitPM(const char* dbPath)
1440  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1441  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1442  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1443  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1444  * @objective       Test OCProvisionPreconfPin negatively with targetDeviceInfo=NULL
1445  * @target          OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1446  * @test_data       targetDeviceInfo=NULL
1447  * @pre_condition   Start two justworks simulators
1448  * @procedure       1. call OCRegisterPersistentStorageHandler
1449  *                  2. call OCInit
1450  *                  3. call OCInitPM
1451  *                  4. call OCDiscoverUnownedDevices
1452  *                  5. call OCDoOwnershipTransfer
1453  *                  6. call OCDiscoverOwnedDevices
1454  *                  7. call OCChangeMOTMode
1455  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1456  *                  9. call OCProvisionPreconfPin
1457  * @post_condition  None
1458  * @expected        OCProvisionPreconfPin will return OC_STACK_INVALID_PARAM
1459  */
1460 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1461 TEST_F(PMCsdkMotTest_btc, OCProvisionPreconfPinTargetDeviceInfo_NV_N)
1462 {
1463     CommonUtil::launchApp(PRECONFIG_SERVER1);
1464     CommonUtil::launchApp(PRECONFIG_SERVER2);
1465
1466     if (!m_PMHelper.initProvisionClient())
1467     {
1468         SET_FAILURE(m_PMHelper.getFailureMessage());
1469         return;
1470     }
1471
1472     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1473                     &m_UnownList, OC_STACK_OK))
1474     {
1475         SET_FAILURE(m_PMHelper.getFailureMessage());
1476         return;
1477     }
1478
1479     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1480                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1481     {
1482         SET_FAILURE(m_PMHelper.getFailureMessage());
1483         return;
1484     }
1485
1486     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1487     {
1488         SET_FAILURE(m_PMHelper.getFailureMessage());
1489         return;
1490     }
1491
1492     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1493
1494     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1495     {
1496         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1497         return;
1498     }
1499
1500     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1501                     &m_motEnabledDevList, OC_STACK_OK))
1502     {
1503         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1504         return;
1505     }
1506
1507     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, NULL, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1508     {
1509         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1510     }
1511 }
1512 #endif
1513
1514 /**
1515  * @since           2017-03-10
1516  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1517  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1518  * @see             OCStackResult OCInitPM(const char* dbPath)
1519  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1520  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1521  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1522  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1523  * @objective       Test OCProvisionPreconfPin negatively with preconfPin=NULL
1524  * @target          OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1525  * @test_data       preconfPin=NULL
1526  * @pre_condition   Start two justworks simulators
1527  * @procedure       1. call OCRegisterPersistentStorageHandler
1528  *                  2. call OCInit
1529  *                  3. call OCInitPM
1530  *                  4. call OCDiscoverUnownedDevices
1531  *                  5. call OCDoOwnershipTransfer
1532  *                  6. call OCDiscoverOwnedDevices
1533  *                  7. call OCChangeMOTMode
1534  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1535  *                  9. call OCProvisionPreconfPin
1536  * @post_condition  None
1537  * @expected        OCProvisionPreconfPin will return OC_STACK_INVALID_PARAM
1538  */
1539 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1540 TEST_F(PMCsdkMotTest_btc, OCProvisionPreconfPinPreconfPin_NV_N)
1541 {
1542     CommonUtil::launchApp(PRECONFIG_SERVER1);
1543     CommonUtil::launchApp(PRECONFIG_SERVER2);
1544
1545     if (!m_PMHelper.initProvisionClient())
1546     {
1547         SET_FAILURE(m_PMHelper.getFailureMessage());
1548         return;
1549     }
1550
1551     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1552                     &m_UnownList, OC_STACK_OK))
1553     {
1554         SET_FAILURE(m_PMHelper.getFailureMessage());
1555         return;
1556     }
1557
1558     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1559                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1560     {
1561         SET_FAILURE(m_PMHelper.getFailureMessage());
1562         return;
1563     }
1564
1565     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1566     {
1567         SET_FAILURE(m_PMHelper.getFailureMessage());
1568         return;
1569     }
1570
1571     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1572
1573     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1574     {
1575         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1576         return;
1577     }
1578
1579     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1580                     &m_motEnabledDevList, OC_STACK_OK))
1581     {
1582         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1583         return;
1584     }
1585
1586     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1587
1588     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, NULL, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1589     {
1590         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1591     }
1592 }
1593 #endif
1594
1595 /**
1596  * @since           2017-03-10
1597  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1598  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1599  * @see             OCStackResult OCInitPM(const char* dbPath)
1600  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1601  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1602  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1603  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1604  * @objective       Test OCProvisionPreconfPin negatively with preconfPinLen=MOT_PRECONFIG_PIN_ZERO_SIZE
1605  * @target          OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1606  * @test_data       preconfPin=MOT_PRECONFIG_PIN_ZERO_SIZE
1607  * @pre_condition   Start two justworks simulators
1608  * @procedure       1. call OCRegisterPersistentStorageHandler
1609  *                  2. call OCInit
1610  *                  3. call OCInitPM
1611  *                  4. call OCDiscoverUnownedDevices
1612  *                  5. call OCDoOwnershipTransfer
1613  *                  6. call OCDiscoverOwnedDevices
1614  *                  7. call OCChangeMOTMode
1615  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1616  *                  9. call OCProvisionPreconfPin
1617  * @post_condition  None
1618  * @expected        OCProvisionPreconfPin will return OC_STACK_INVALID_PARAM
1619  */
1620 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1621 TEST_F(PMCsdkMotTest_btc, OCProvisionPreconfPinPreconfPinLen_LOBV_N)
1622 {
1623     CommonUtil::launchApp(PRECONFIG_SERVER1);
1624     CommonUtil::launchApp(PRECONFIG_SERVER2);
1625
1626     if (!m_PMHelper.initProvisionClient())
1627     {
1628         SET_FAILURE(m_PMHelper.getFailureMessage());
1629         return;
1630     }
1631
1632     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1633                     &m_UnownList, OC_STACK_OK))
1634     {
1635         SET_FAILURE(m_PMHelper.getFailureMessage());
1636         return;
1637     }
1638
1639     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1640                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1641     {
1642         SET_FAILURE(m_PMHelper.getFailureMessage());
1643         return;
1644     }
1645
1646     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1647     {
1648         SET_FAILURE(m_PMHelper.getFailureMessage());
1649         return;
1650     }
1651
1652     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1653
1654     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1655     {
1656         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1657         return;
1658     }
1659
1660     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1661                     &m_motEnabledDevList, OC_STACK_OK))
1662     {
1663         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1664         return;
1665     }
1666
1667     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1668
1669     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, MOT_PRECONFIG_PIN_ZERO_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1670     {
1671         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1672     }
1673 }
1674 #endif
1675
1676 /**
1677  * @since           2017-03-10
1678  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1679  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1680  * @see             OCStackResult OCInitPM(const char* dbPath)
1681  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1682  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1683  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1684  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1685  * @objective       Test OCProvisionPreconfPin negatively with resultCallback=NULL
1686  * @target          OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1687  * @test_data       resultCallback=NULL
1688  * @pre_condition   Start two justworks simulators
1689  * @procedure       1. call OCRegisterPersistentStorageHandler
1690  *                  2. call OCInit
1691  *                  3. call OCInitPM
1692  *                  4. call OCDiscoverUnownedDevices
1693  *                  5. call OCDoOwnershipTransfer
1694  *                  6. call OCDiscoverOwnedDevices
1695  *                  7. call OCChangeMOTMode
1696  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1697  *                  9. call OCProvisionPreconfPin
1698  * @post_condition  None
1699  * @expected        OCProvisionPreconfPin will return OC_STACK_INVALID_CALLBACK
1700  */
1701 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1702 TEST_F(PMCsdkMotTest_btc, OCProvisionPreconfPinResultCallback_NV_N)
1703 {
1704     CommonUtil::launchApp(PRECONFIG_SERVER1);
1705     CommonUtil::launchApp(PRECONFIG_SERVER2);
1706
1707     if (!m_PMHelper.initProvisionClient())
1708     {
1709         SET_FAILURE(m_PMHelper.getFailureMessage());
1710         return;
1711     }
1712
1713     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1714                     &m_UnownList, OC_STACK_OK))
1715     {
1716         SET_FAILURE(m_PMHelper.getFailureMessage());
1717         return;
1718     }
1719
1720     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1721                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1722     {
1723         SET_FAILURE(m_PMHelper.getFailureMessage());
1724         return;
1725     }
1726
1727     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1728     {
1729         SET_FAILURE(m_PMHelper.getFailureMessage());
1730         return;
1731     }
1732
1733     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1734
1735     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1736     {
1737         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1738         return;
1739     }
1740
1741     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1742                     &m_motEnabledDevList, OC_STACK_OK))
1743     {
1744         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1745         return;
1746     }
1747
1748     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1749
1750     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, NULL, OC_STACK_INVALID_CALLBACK))
1751     {
1752         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1753     }
1754 }
1755 #endif
1756
1757 /**
1758  * @since           2016-09-10
1759  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1760  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1761  * @see             OCStackResult OCInitPM(const char* dbPath)
1762  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1763  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1764  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1765  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1766  * @see             OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1767  * @objective       Test OCSelectMOTMethod positively with regular data
1768  * @target          OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback)
1769  * @test_data       regular data for the target API
1770  * @pre_condition   Start two justworks simulators
1771  * @procedure       1. call OCRegisterPersistentStorageHandler
1772  *                  2. call OCInit
1773  *                  3. call OCInitPM
1774  *                  4. call OCDiscoverUnownedDevices
1775  *                  5. call OCDoOwnershipTransfer
1776  *                  6. call OCDiscoverOwnedDevices
1777  *                  7. call OCChangeMOTMode
1778  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1779  *                  9. call OCProvisionPreconfPin
1780  *                 10. call OCSelectMOTMethod
1781  * @post_condition  None
1782  * @expected        OCSelectMOTMethod will return OC_STACK_OK
1783  */
1784 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1785 TEST_F(PMCsdkMotTest_btc, OCSelectMOTMethod_RV_SRC_P)
1786 {
1787     CommonUtil::launchApp(PRECONFIG_SERVER1);
1788     CommonUtil::launchApp(PRECONFIG_SERVER2);
1789     CommonUtil::waitInSecond(DELAY_LONG);
1790
1791     if (!m_PMHelper.initProvisionClient())
1792     {
1793         SET_FAILURE(m_PMHelper.getFailureMessage());
1794         return;
1795     }
1796
1797     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1798                     &m_UnownList, OC_STACK_OK))
1799     {
1800         SET_FAILURE(m_PMHelper.getFailureMessage());
1801         return;
1802     }
1803
1804     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1805                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1806     {
1807         SET_FAILURE(m_PMHelper.getFailureMessage());
1808         return;
1809     }
1810
1811     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1812     {
1813         SET_FAILURE(m_PMHelper.getFailureMessage());
1814         return;
1815     }
1816
1817     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1818
1819     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1820     {
1821         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1822         return;
1823     }
1824
1825     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1826                     &m_motEnabledDevList, OC_STACK_OK))
1827     {
1828         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1829         return;
1830     }
1831
1832     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1833
1834     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1835     {
1836         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1837         return;
1838     }
1839
1840     if (!m_PMMotHelper.selectMOTMethod((void*)ctxSelectMOTMethod, targetMotDev, OIC_PRECONFIG_PIN, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1841     {
1842         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1843     }
1844 }
1845 #endif
1846
1847 /**
1848  * @since           2016-09-10
1849  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1850  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1851  * @see             OCStackResult OCInitPM(const char* dbPath)
1852  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1853  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1854  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1855  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1856  * @see             OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1857  * @objective       Test OCSelectMOTMethod negatively with targetDeviceInfo as NULL
1858  * @target          OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback)
1859  * @test_data       targetDeviceInfo = NULL
1860  * @pre_condition   Start two justworks simulators
1861  * @procedure       1. call OCRegisterPersistentStorageHandler
1862  *                  2. call OCInit
1863  *                  3. call OCInitPM
1864  *                  4. call OCDiscoverUnownedDevices
1865  *                  5. call OCDoOwnershipTransfer
1866  *                  6. call OCDiscoverOwnedDevices
1867  *                  7. call OCChangeMOTMode
1868  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1869  *                  9. call OCProvisionPreconfPin
1870  *                 10. call OCSelectMOTMethod
1871  * @post_condition  None
1872  * @expected        OCSelectMOTMethod will return OC_STACK_INVALID_PARAM
1873  */
1874 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1875 TEST_F(PMCsdkMotTest_btc, OCSelectMOTMethodDev_NV_N)
1876 {
1877     CommonUtil::launchApp(PRECONFIG_SERVER1);
1878     CommonUtil::launchApp(PRECONFIG_SERVER2);
1879
1880     if (!m_PMHelper.initProvisionClient())
1881     {
1882         SET_FAILURE(m_PMHelper.getFailureMessage());
1883         return;
1884     }
1885
1886     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1887                     &m_UnownList, OC_STACK_OK))
1888     {
1889         SET_FAILURE(m_PMHelper.getFailureMessage());
1890         return;
1891     }
1892
1893     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1894                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1895     {
1896         SET_FAILURE(m_PMHelper.getFailureMessage());
1897         return;
1898     }
1899
1900     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1901     {
1902         SET_FAILURE(m_PMHelper.getFailureMessage());
1903         return;
1904     }
1905
1906     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1907
1908     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1909     {
1910         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1911         return;
1912     }
1913
1914     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
1915                     &m_motEnabledDevList, OC_STACK_OK))
1916     {
1917         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1918         return;
1919     }
1920
1921     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
1922
1923     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1924     {
1925         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1926         return;
1927     }
1928
1929     if (!m_PMMotHelper.selectMOTMethod((void*)ctxSelectMOTMethod, NULL, OIC_PRECONFIG_PIN, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_INVALID_PARAM))
1930     {
1931         SET_FAILURE(m_PMMotHelper.getFailureMessage());
1932     }
1933 }
1934 #endif
1935
1936 /**
1937  * @since           2016-09-10
1938  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
1939  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
1940  * @see             OCStackResult OCInitPM(const char* dbPath)
1941  * @see             OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
1942  * @see             OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1943  * @see             OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecMomType_t momType, OCProvisionResultCB resultCallback)
1944  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
1945  * @see             OCStackResult OCProvisionPreconfPin(void* ctx, OCProvisionDev_t *targetDeviceInfo, const char * preconfPin, size_t preconfPinLen, OCProvisionResultCB resultCallback)
1946  * @objective       Test OCSelectMOTMethod negatively with resultCallback = NULL
1947  * @target          OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo, const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback)
1948  * @test_data       resultCallback = NULL
1949  * @pre_condition   Start two justworks simulators
1950  * @procedure       1. call OCRegisterPersistentStorageHandler
1951  *                  2. call OCInit
1952  *                  3. call OCInitPM
1953  *                  4. call OCDiscoverUnownedDevices
1954  *                  5. call OCDoOwnershipTransfer
1955  *                  6. call OCDiscoverOwnedDevices
1956  *                  7. call OCChangeMOTMode
1957  *                  8. call OCDiscoverMultipleOwnerEnabledDevices
1958  *                  9. call OCProvisionPreconfPin
1959  *                 10. call OCSelectMOTMethod
1960  * @post_condition  None
1961  * @expected        OCSelectMOTMethod will return OC_STACK_INVALID_CALLBACK
1962  */
1963 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
1964 TEST_F(PMCsdkMotTest_btc, OCSelectMOTMethodCb_NV_N)
1965 {
1966     CommonUtil::launchApp(PRECONFIG_SERVER1);
1967     CommonUtil::launchApp(PRECONFIG_SERVER2);
1968
1969     if (!m_PMHelper.initProvisionClient())
1970     {
1971         SET_FAILURE(m_PMHelper.getFailureMessage());
1972         return;
1973     }
1974
1975     if (!m_PMHelper.discoverUnownedDevices(DISCOVERY_TIMEOUT,
1976                     &m_UnownList, OC_STACK_OK))
1977     {
1978         SET_FAILURE(m_PMHelper.getFailureMessage());
1979         return;
1980     }
1981
1982     if (!m_PMHelper.doOwnerShipTransfer((void*)g_ctx, &m_UnownList,
1983                     PMCsdkHelper::ownershipTransferCB, OC_STACK_OK))
1984     {
1985         SET_FAILURE(m_PMHelper.getFailureMessage());
1986         return;
1987     }
1988
1989     if(!m_PMHelper.discoverOwnedDevices(DISCOVERY_TIMEOUT, &m_OwnList, OC_STACK_OK))
1990     {
1991         SET_FAILURE(m_PMHelper.getFailureMessage());
1992         return;
1993     }
1994
1995     OCProvisionDev_t* targetOwnedDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_OwnList, DEVICE_INDEX_ONE);
1996
1997     if (!m_PMMotHelper.changeMOTMode((void*)ctxChangeMOTMode, targetOwnedDev, OIC_MULTIPLE_OWNER_ENABLE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
1998     {
1999         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2000         return;
2001     }
2002
2003     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
2004                     &m_motEnabledDevList, OC_STACK_OK))
2005     {
2006         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2007         return;
2008     }
2009
2010     OCProvisionDev_t* targetMotDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
2011
2012     if (!m_PMMotHelper.provisionPreconfPin((void*)ctxProvisionPreconfPin, targetMotDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
2013     {
2014         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2015         return;
2016     }
2017
2018     if (!m_PMMotHelper.selectMOTMethod((void*)ctxSelectMOTMethod, targetMotDev, OIC_PRECONFIG_PIN, NULL, OC_STACK_INVALID_CALLBACK))
2019     {
2020         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2021     }
2022 }
2023 #endif
2024
2025 /**
2026  * @since           2017-03-30
2027  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
2028  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
2029  * @see             OCStackResult OCInitPM(const char* dbPath)
2030  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
2031  * @see             OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
2032  * @see             OCDoMultipleOwnershipTransfer(void* ctx,OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
2033  * @objective       Test provision ACL  positively with MOT device
2034  * @target          OCStackResult OCProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecAcl_t *acl, OCProvisionResultCB resultCallback)
2035  * @test_data       regular data for the API
2036  * @pre_condition   Start Mot Enabled justworks simulators
2037  * @procedure       1. call OCRegisterPersistentStorageHandler
2038  *                  2. call OCInit
2039  *                  3. call OCInitPM
2040  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
2041  *                  5. call OCAddPreconfigPin
2042  *                  6. call OCDoMultipleOwnershipTransfer
2043  *                  7. call OCProvisionACL
2044  * @post_condition  none
2045  * @expected        OCProvisionACL will return OC_STACK_OK
2046  */
2047 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
2048 TEST_F(PMCsdkMotTest_btc, ProvisionACLForMultipleOwnedDevices_RV_SRC_P)
2049 {
2050     CommonUtil::launchApp(JUSTWORKS_SERVER7);
2051     CommonUtil::waitInSecond(DELAY_LONG);
2052
2053     if (!m_PMMotHelper.initMotClient())
2054     {
2055         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2056         return;
2057     }
2058
2059     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
2060                     &m_motEnabledDevList, OC_STACK_OK))
2061     {
2062         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2063         return;
2064     }
2065
2066     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
2067
2068     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
2069     {
2070         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2071         return;
2072     }
2073
2074     if (!m_PMMotHelper.doMultipleOwnershipTransfer((void*)MOT_CTX, m_motEnabledDevList,
2075                     PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
2076     {
2077         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2078         return;
2079     }
2080
2081     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT,
2082                     &m_motOwnedDevList, OC_STACK_OK))
2083     {
2084         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2085         return;
2086     }
2087
2088     OCProvisionDev_t* targetMOTDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motOwnedDevList, DEVICE_INDEX_ONE);
2089     OicUuid_t deviceUuid = targetMOTDev->doxm->subOwners->uuid;
2090
2091     m_Acl = createAclForLEDAccess(&deviceUuid);
2092
2093     if (!m_PMHelper.provisionACL((void*)g_ctx, m_motOwnedDevList, m_Acl,
2094                     m_PMHelper.provisionAclCB, OC_STACK_OK))
2095     {
2096         SET_FAILURE(m_PMHelper.getFailureMessage());
2097         return;
2098     }
2099
2100     if (!m_PMHelper.deleteACLList(m_Acl))
2101     {
2102         SET_FAILURE(m_PMHelper.getFailureMessage());
2103         return;
2104     }
2105 }
2106 #endif
2107
2108 /**
2109  * @since           2016-09-10
2110  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
2111  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
2112  * @see             OCStackResult OCInitPM(const char* dbPath)
2113  * @see             OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList)
2114  * @see             OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, const char* preconfPIN, size_t preconfPINLen)
2115  * @see             OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback)
2116  * @see             OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
2117  * @objective       Test OCIsSubownerOfDevice positively with regular data
2118  * @target          OCStackResult OCIsSubownerOfDevice(OCProvisionDev_t *device, bool *isSubowner)
2119  * @test_data       regular data for the API
2120  * @pre_condition   Start Mot Enabled justworks simulators
2121  * @procedure       1. call OCRegisterPersistentStorageHandler
2122  *                  2. call OCInit
2123  *                  3. call OCInitPM
2124  *                  4. call OCDiscoverMultipleOwnerEnabledDevices
2125  *                  5. call OCAddPreconfigPin
2126  *                  6. call OCDoMultipleOwnershipTransfer
2127  *                  7. call OCDiscoverMultipleOwnedDevices
2128  *                  8. call OCIsSubownerOfDevice
2129  * @post_condition  none
2130  * @expected        OCIsSubownerOfDevice will return OC_STACK_OK
2131  */
2132 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
2133 TEST_F(PMCsdkMotTest_btc, OCIsSubownerOfDevice_RV_SRC_P)
2134 {
2135     CommonUtil::launchApp(JUSTWORKS_SERVER7);
2136
2137     if (!m_PMMotHelper.initMotClient())
2138     {
2139         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2140         return;
2141     }
2142
2143     if (!m_PMMotHelper.discoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
2144                     &m_motEnabledDevList, OC_STACK_OK))
2145     {
2146         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2147         return;
2148     }
2149
2150     OCProvisionDev_t* targetDev = PMCsdkUtilityHelper::getDevInst((OCProvisionDev_t*) m_motEnabledDevList, DEVICE_INDEX_ONE);
2151
2152     if (!m_PMMotHelper.addPreconfigPIN(targetDev, MOT_DEFAULT_PRE_CONFIG_PIN, OXM_PRECONFIG_PIN_MAX_SIZE, OC_STACK_OK))
2153     {
2154         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2155         return;
2156     }
2157
2158     if (!m_PMMotHelper.doMultipleOwnershipTransfer((void*)MOT_CTX, m_motEnabledDevList,
2159                     PMCsdkCallbackHelper::provisionPostCB, OC_STACK_OK))
2160     {
2161         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2162         return;
2163     }
2164
2165     if (!m_PMMotHelper.discoverMultipleOwnedDevices(DISCOVERY_TIMEOUT,
2166                     &m_motOwnedDevList, OC_STACK_OK))
2167     {
2168         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2169         return;
2170     }
2171
2172     if (!m_PMMotHelper.isSubownerOfDevice(m_motOwnedDevList, &isSubowner, OC_STACK_OK,true))
2173     {
2174         SET_FAILURE(m_PMMotHelper.getFailureMessage());
2175         return;
2176     }
2177 }
2178 #endif
2179
2180 #endif /*__MOT__*/