Merge test folder of test branch
[iotivity.git] / test / src / tc / cs / gtest / csdk / src / stc / CSCsdkAclTest.cpp
1 /******************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *
20  ******************************************************************/
21 #include "CSCsdkCloudHelper.h"
22 #include "CSCsdkUtilityHelper.h"
23
24 class CSCsdkAclTest_stc: public ::testing::Test
25 {
26 protected:
27
28     CSCsdkCloudHelper m_CloudAclHelper;
29     string m_hostAddress = COAP_HOST_ADDRESS;
30     OCAccountManager::Ptr m_accountMgrControlee = nullptr;
31     uint16_t m_credId = 0;
32     ByteArray_t m_trustCertChainArray =
33     { 0, 0 };
34     OCDevAddr m_endPoint;
35     OicCloud_t* m_pCloud = NULL;
36     cloudAce_t *m_aces = NULL;
37
38     virtual void SetUp()
39     {
40         CommonUtil::copyFile(CLOUD_ACL_CONTROLLER_DAT_BACKUP,
41         CLOUD_ACL_CONTROLLER_DAT);
42
43         CommonUtil::copyFile(ROOT_CERT_FILE_BACKUP, ROOT_CERT_FILE);
44         CommonTestUtil::runCommonTCSetUpPart();
45
46         if (!m_CloudAclHelper.initCloudACLClient())
47         {
48             SET_FAILURE(m_CloudAclHelper.getFailureMessage());
49             return;
50         }
51
52         m_hostAddress = CloudCommonUtil::getDefaultHostAddess();
53         m_endPoint = CloudCommonUtil::getDefaultEndPoint();
54         m_pCloud = CloudCommonUtil::getCloudServer();
55         m_aces = CSCsdkUtilityHelper::createCloudAces();
56
57 #ifdef __TLS_ON__
58         setCoapPrefix(true);
59         CASelectCipherSuite(MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, CA_ADAPTER_TCP);
60 #endif
61
62         CSCsdkCloudHelper::readFile(ROOT_CERT_FILE, (OCByteString *) &m_trustCertChainArray);
63         m_accountMgrControlee = OCPlatform::constructAccountManagerObject(m_hostAddress,
64                 CT_ADAPTER_TCP);
65
66         if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
67                         OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
68         {
69             SET_FAILURE(m_CloudAclHelper.getFailureMessage());
70             return;
71         }
72
73         //CloudCommonUtil::signUp(m_accountMgrControlee);
74
75         if (!CloudCommonUtil::signIn(m_accountMgrControlee))
76         {
77             SET_FAILURE(ERROR_SIGN_IN);
78             return;
79         }
80     }
81
82     virtual void TearDown()
83     {
84         CommonTestUtil::runCommonTCTearDownPart();
85     }
86 };
87
88 /**
89  * @since           2016-10-23
90  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
91  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
92  * @see             void setCoapPrefix(bool secured)
93  * @see             CAResult_t CASelectCipherSuite(const uint16_t cipher, CATransportAdapter_t adapter)
94  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
95  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
96  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
97  * @objective       Test OCCloudGetAclIdByDevice positively with regualr data
98  * @target          OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
99  * @test_data       regualr data
100  * @pre_condition   Run iotivity_cs_server
101  * @procedure       1. call OCRegisterPersistentStorageHandler
102  *                  2. call OCInit
103  *                  3. call setCoapPrefix for TLS MODE enabled
104  *                  4. call CASelectCipherSuite(true)for TLS MODE enabled
105  *                  5. call OCSaveTrustCertChain
106  *                  6. call signIn
107  *                  7. call OCCloudGetAclIdByDevice
108  * @post_condition  none
109  * @expected        OCCloudGetAclIdByDevice will return OC_STACK_OK
110  */
111 #if defined(__LINUX__) || defined(__TIZEN__)
112 TEST_F(CSCsdkAclTest_stc, OCCloudAclIdGetByDevice_SRC_RV_P)
113 {
114     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
115     {
116         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
117     }
118 }
119 #endif
120
121 /**
122  * @since           2016-09-23
123  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
124  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
125  * @see             void setCoapPrefix(bool secured)
126  * @see             CAResult_t CASelectCipherSuite(const uint16_t cipher, CATransportAdapter_t adapter)
127  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
128  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
129  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
130  * @objective       Test OCCloudGetAclIdByDevice positively with OCCloudResponseCB as NULL
131  * @target          OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
132  * @test_data       OCCloudResponseCB as NULL
133  * @pre_condition   Run iotivity_cs_server
134  * @procedure       1. call OCRegisterPersistentStorageHandler
135  *                  2. call OCInit
136  *                  3. call setCoapPrefix for TLS MODE enabled
137  *                  4. call CASelectCipherSuite(true)for TLS MODE enabled
138  *                  5. call OCSaveTrustCertChain
139  *                  6. call signIn
140  *                  7. call OCCloudGetAclIdByDevice
141  * @post_condition  none
142  * @expected        OCCloudGetAclIdByDevice will return OC_STACK_OK
143  */
144 #if defined(__LINUX__) || defined(__TIZEN__)
145 TEST_F(CSCsdkAclTest_stc, OCCloudAclIdGetByDeviceCb_NV_P)
146 {
147     if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
148                     OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
149     {
150         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
151         return;
152     }
153
154     if (!CloudCommonUtil::signIn(m_accountMgrControlee))
155     {
156         SET_FAILURE(ERROR_SIGN_IN);
157         return;
158     }
159
160     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, NULL, CSCsdkCloudHelper::s_aclId, OC_STACK_OK, false))
161     {
162         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
163     }
164 }
165 #endif
166
167
168 /**
169  * @since           2016-09-23
170  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
171  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
172  * @see             void setCoapPrefix(bool secured)
173  * @see             CAResult_t CASelectCipherSuite(const uint16_t cipher, CATransportAdapter_t adapter)
174  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
175  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
176  * @objective       Test OCCloudAclIdCreate positively with regular data
177  * @target          OCStackResult OCCloudAclIdCreate(void* ctx, const char *ownerId, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
178  * @test_data       regular data for target API
179  * @pre_condition   Run iotivity_cs_server
180  * @procedure       1. call OCRegisterPersistentStorageHandler
181  *                  2. call OCInit
182  *                  3. call setCoapPrefix for TLS MODE enabled
183  *                  4. call CASelectCipherSuite(true)for TLS MODE enabled
184  *                  5. call OCSaveTrustCertChain
185  *                  6. call signIn
186  *                  7. call OCCloudAclIdCreate
187  * @post_condition  none
188  * @expected        OCCloudAclIdCreate will return OC_STACK_OK
189  */
190 #if defined(__LINUX__) || defined(__TIZEN__)
191 TEST_F(CSCsdkAclTest_stc, OCCloudAclIdCreate_SRC_RV_P)
192 {
193     if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
194                     OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
195     {
196         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
197         return;
198     }
199
200     if (!CloudCommonUtil::signIn(m_accountMgrControlee))
201     {
202         SET_FAILURE(ERROR_SIGN_IN);
203         return;
204     }
205
206     if (!m_CloudAclHelper.cloudAclIdCreate((void*) CTX_INDIVIDUAL_GET_INFO, DEFAULT_OWNER_ID, DEFAULT_DEV_ID_CS_01, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
207     {
208         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
209     }
210 }
211 #endif
212
213 /**
214  * @since           2016-09-23
215  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
216  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
217  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
218  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
219  * @see             OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
220  * @see             OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
221  * @objective       Test OCCloudAclIndividualGetInfo positively with regular data
222  * @target          OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
223  * @test_data       regular data
224  * @pre_condition   Run iotivity_cs_server
225  * @procedure       1. call OCRegisterPersistentStorageHandler
226  *                  2. call OCInit
227  *                  3. call OCSaveTrustCertChain
228  *                  4. call signIn
229  *                  5. call OCCloudGetAclIdByDevice
230  *                  6. call OCCloudAclIndividualAclUpdate
231  *                  7. call OCCloudAclIndividualGetInfo
232  * @post_condition  none
233  * @expected        OCCloudAclIndividualGetInfo will return OC_STACK_OK
234  */
235 #if defined(__LINUX__) || defined(__TIZEN__)
236 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualGetInfo_SRC_RV_P)
237 {
238     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
239     {
240         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
241     }
242
243     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
244     {
245         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
246     }
247
248     if (!m_CloudAclHelper.cloudAclIndividualGetInfo((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
249     {
250         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
251     }
252 }
253 #endif
254
255 /**
256  * @since           2016-09-23
257  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
258  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
259  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
260  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
261  * @see             OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
262  * @see             OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
263  * @objective       Test OCCloudAclIndividualGetInfo positively with callback as NULL
264  * @target          OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
265  * @test_data       callback as NULL
266  * @pre_condition   Run iotivity_cs_server
267  * @procedure       1. call OCRegisterPersistentStorageHandler
268  *                  2. call OCInit
269  *                  3. call OCSaveTrustCertChain
270  *                  4. call signIn
271  *                  5. call OCCloudGetAclIdByDevice
272  *                  6. call OCCloudAclIndividualAclUpdate
273  *                  7. call OCCloudAclIndividualGetInfo
274  * @post_condition  none
275  * @expected        OCCloudAclIndividualGetInfo will return OC_STACK_OK
276  */
277 #if defined(__LINUX__) || defined(__TIZEN__)
278 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualGetInfoCb_NV_P)
279 {
280     if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
281                     OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
282     {
283         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
284         return;
285     }
286
287     if (!CloudCommonUtil::signIn(m_accountMgrControlee))
288     {
289         SET_FAILURE(ERROR_SIGN_IN);
290         return;
291     }
292
293     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
294     {
295         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
296         return;
297     }
298
299     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
300     {
301         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
302         return;
303     }
304
305     if (!m_CloudAclHelper.cloudAclIndividualGetInfo((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), m_pCloud->cis, NULL, OC_STACK_OK, false))
306     {
307         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
308     }
309 }
310 #endif
311
312 /**
313  * @since           2016-09-23
314  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
315  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
316  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
317  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
318  * @see             OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
319  * @see             OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
320  * @objective       Test OCCloudAclIndividualGetInfo positively with callback as NULL
321  * @target          OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
322  * @test_data       callback as NULL
323  * @pre_condition   Run iotivity_cs_server
324  * @procedure       1. call OCRegisterPersistentStorageHandler
325  *                  2. call OCInit
326  *                  3. call OCSaveTrustCertChain
327  *                  4. call signIn
328  *                  5. call OCCloudGetAclIdByDevice
329  *                  6. call OCCloudAclIndividualAclUpdate
330  *                  7. call OCCloudAclIndividualGetInfo
331  * @post_condition  none
332  * @expected        OCCloudAclIndividualGetInfo will return OC_STACK_OK
333  */
334 #if defined(__LINUX__) || defined(__TIZEN__)
335 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualAclUpdate_SRC_RV_P)
336 {
337     if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
338                     OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
339     {
340         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
341         return;
342     }
343
344     if (!CloudCommonUtil::signIn(m_accountMgrControlee))
345     {
346         SET_FAILURE(ERROR_SIGN_IN);
347         return;
348     }
349
350     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
351     {
352         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
353         return;
354     }
355
356     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
357     {
358         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
359     }
360 }
361 #endif
362
363 /**
364  * @since           2016-09-23
365  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
366  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
367  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
368  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
369  * @see             OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
370  * @objective       Test OCCloudAclIndividualAclUpdate positively with OCCloudResponseCB as NULL
371  * @target          OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
372  * @test_data       OCCloudResponseCB as NULL
373  * @pre_condition   Run iotivity_cs_server
374  * @procedure       1. call OCRegisterPersistentStorageHandler
375  *                  2. call OCInit
376  *                  3. call OCSaveTrustCertChain
377  *                  4. call signIn
378  *                  5. call OCCloudGetAclIdByDevice
379  *                  6. call OCCloudAclIndividualAclUpdate
380  * @post_condition  none
381  * @expected        OCCloudAclIndividualAclUpdate will return OC_STACK_OK
382  */
383 #if defined(__LINUX__) || defined(__TIZEN__)
384 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualAclUpdateCb_NV_P)
385 {
386     if (!m_CloudAclHelper.saveTrustCertChain(m_trustCertChainArray.data, m_trustCertChainArray.len,
387                     OIC_ENCODING_PEM, &m_credId, OC_STACK_OK))
388     {
389         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
390         return;
391     }
392
393     if (!CloudCommonUtil::signIn(m_accountMgrControlee))
394     {
395         SET_FAILURE(ERROR_SIGN_IN);
396         return;
397     }
398
399     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
400     {
401         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
402         return;
403     }
404
405     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, NULL, OC_STACK_OK, false))
406     {
407         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
408     }
409 }
410 #endif
411
412 /**
413  * @since           2016-09-23
414  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
415  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
416  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
417  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
418  * @see             OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
419  * @see             OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
420  * @see             OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
421  * @objective       Test OCCloudAclIndividualAceUpdate positively with regular data
422  * @target          OCStackResult OCCloudAclIndividualAceUpdate(void* ctx, const char *aclId, const char *aceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
423  * @test_data       regular data
424  * @pre_condition   Run iotivity_cs_server
425  * @procedure       1. call OCRegisterPersistentStorageHandler
426  *                  2. call OCInit
427  *                  3. call OCSaveTrustCertChain
428  *                  4. call signIn
429  *                  5. call OCCloudGetAclIdByDevice
430  *                  6. call OCCloudAclIndividualAclUpdate
431  *                  7. call OCCloudAclIndividualGetInfo
432  *                  8. cal OCCloudAclIndividualAceUpdate
433  * @post_condition  none
434  * @expected        OCCloudAclIndividualAceUpdate will return OC_STACK_OK
435  */
436 #if defined(__LINUX__) || defined(__TIZEN__)
437 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualAceUpdate_SRC_RV_P)
438 {
439     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
440     {
441         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
442         return;
443     }
444
445     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
446     {
447         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
448         return;
449     }
450
451     if (!m_CloudAclHelper.cloudAclIndividualGetInfo((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
452     {
453         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
454         return;
455     }
456
457     if (!m_CloudAclHelper.cloudAclIndividualAceUpdate((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), (char*)CSCsdkCloudHelper::s_aceid.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
458     {
459         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
460     }
461
462     if (!m_CloudAclHelper.cloudAclIndividualGetInfo((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
463     {
464         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
465         return;
466     }
467 }
468 #endif
469
470 /**
471  * @since           2016-09-23
472  * @see             OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
473  * @see             OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
474  * @see             OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, OicEncodingType_t encodingType, uint16_t *credId)
475  * @see             OCStackResult signIn(const std::string& userUuid, const std::string& accessToken, PostCallback cloudConnectHandler)
476  * @see             OCStackResult OCCloudGetAclIdByDevice(void* ctx, const char *deviceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
477  * @see             OCStackResult OCCloudAclIndividualAclUpdate(void* ctx, const char *aclId, const cloudAce_t *aces, const OCDevAddr *endPoint, OCCloudResponseCB callback)
478  * @see             OCStackResult OCCloudAclIndividualGetInfo(void* ctx, const char *aclId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
479  * @objective       Test OCCloudAclIndividualAceUpdate positively with callback as NULL
480  * @target          OCStackResult OCCloudAclIndividualAceUpdate(void* ctx, const char *aclId, const char *aceId, const OCDevAddr *endPoint, OCCloudResponseCB callback)
481  * @test_data       callback as NULL
482  * @pre_condition   Run iotivity_cs_server
483  * @procedure       1. call OCRegisterPersistentStorageHandler
484  *                  2. call OCInit
485  *                  3. call OCSaveTrustCertChain
486  *                  4. call signIn
487  *                  5. call OCCloudGetAclIdByDevice
488  *                  6. call OCCloudAclIndividualAclUpdate
489  *                  7. call OCCloudAclIndividualGetInfo
490  *                  8. cal OCCloudAclIndividualAceUpdate
491  * @post_condition  none
492  * @expected        OCCloudAclIndividualAceUpdate will return OC_STACK_OK
493  */
494 #if defined(__LINUX__) || defined(__TIZEN__)
495 TEST_F(CSCsdkAclTest_stc, OCCloudAclIndividualAceUpdateCb_NV_P)
496 {
497     if (!m_CloudAclHelper.cloudGetAclIdByDevice((void*) CTX_GET_ACL_ID_BY_DEV, DEFAULT_DEV_ID, m_pCloud->cis, CSCsdkCloudHelper::aclResponseCB, CSCsdkCloudHelper::s_aclId, OC_STACK_OK))
498     {
499         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
500         return;
501     }
502
503     if (!m_CloudAclHelper.cloudAclIndividualAclUpdate((void*) CTX_INDIVIDUAL_UPDATE_ACE, CSCsdkCloudHelper::s_aclId.c_str(), m_aces, m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
504     {
505         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
506         return;
507     }
508
509     if (!m_CloudAclHelper.cloudAclIndividualGetInfo((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), m_pCloud->cis, CSCsdkCloudHelper::cloudResponseCB, OC_STACK_OK))
510     {
511         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
512         return;
513     }
514
515     if (!m_CloudAclHelper.cloudAclIndividualAceUpdate((void*) CTX_INDIVIDUAL_GET_INFO, CSCsdkCloudHelper::s_aclId.c_str(), (char*)CSCsdkCloudHelper::s_aceid.c_str(), m_aces, m_pCloud->cis, NULL, OC_STACK_OK, false))
516     {
517         SET_FAILURE(m_CloudAclHelper.getFailureMessage());
518     }
519 }
520 #endif