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