Fix provisioning unit tests
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / unittest / secureresourceprovider.cpp
1 /* *****************************************************************
2  *
3  * Copyright 2015 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 #include "gtest/gtest.h"
21 #include "secureresourceprovider.h"
22
23 static OicSecAcl_t acl;
24 static OCProvisionDev_t pDev1;
25 static OCProvisionDev_t pDev2;
26 static OicSecCredType_t credType = SYMMETRIC_PAIR_WISE_KEY;
27 static OCProvisionDev_t selectedDeviceInfo;
28 static OicSecPconf_t pconf;
29 static OicSecOxm_t oicSecDoxmJustWorks = OIC_JUST_WORKS;
30 static OicSecOxm_t oicSecDoxmRandomPin = OIC_RANDOM_DEVICE_PIN;
31 static unsigned short timeout = 60;
32 static OicSecDoxm_t defaultDoxm1 =
33 {
34     &oicSecDoxmJustWorks,   /* uint16_t *oxm */
35     1,                      /* size_t oxmLen */
36     OIC_JUST_WORKS,         /* uint16_t oxmSel */
37     SYMMETRIC_PAIR_WISE_KEY,/* OicSecCredType_t sct */
38     false,                  /* bool owned */
39     {{0}},                  /* OicUuid_t deviceID */
40     false,                  /* bool dpc */
41     {{0}},                  /* OicUuid_t owner */
42 #ifdef MULTIPLE_OWNER
43     NULL,                   /* OicSecSubOwner_t* subOwners */
44     NULL,                   /* OicSecMom_t *mom */
45 #endif //MULTIPLE_OWNER
46     {{0}}                   /* rownerID */
47 };
48
49 static OicSecDoxm_t defaultDoxm2 =
50 {
51     &oicSecDoxmRandomPin,   /* uint16_t *oxm */
52     1,                      /* size_t oxmLen */
53     OIC_RANDOM_DEVICE_PIN,  /* uint16_t oxmSel */
54     SYMMETRIC_PAIR_WISE_KEY,/* OicSecCredType_t sct */
55     false,                  /* bool owned */
56     {{0}},                  /* OicUuid_t deviceID */
57     false,                  /* bool dpc */
58     {{0}},                  /* OicUuid_t owner */
59 #ifdef MULTIPLE_OWNER
60     NULL,                   /* OicSecSubOwner_t* subOwners */
61     NULL,                   /* OicSecMom_t *mom */
62 #endif //MULTIPLE_OWNER
63     {{0}}                   /* rownerID */
64 };
65
66 static void provisioningCB (void* UNUSED1, size_t UNUSED2, OCProvisionResult_t *UNUSED3, bool UNUSED4)
67 {
68     //dummy callback
69     (void) UNUSED1;
70     (void) UNUSED2;
71     (void) UNUSED3;
72     (void) UNUSED4;
73 }
74
75 TEST(SRPProvisionACLTest, NullDeviceInfo)
76 {
77     pDev1.doxm = &defaultDoxm1;
78     uint8_t deviceId1[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64};
79     memcpy(pDev1.doxm->deviceID.id, deviceId1, sizeof(deviceId1));
80
81     pDev2.doxm = &defaultDoxm2;
82     uint8_t deviceId2[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x63};
83     memcpy(pDev2.doxm->deviceID.id, deviceId2, sizeof(deviceId2));
84
85     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionACL(NULL, NULL, &acl, OIC_SEC_ACL_V2, &provisioningCB));
86 }
87
88 TEST(SRPProvisionACLTest, NullCallback)
89 {
90     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPProvisionACL(NULL, &pDev1, &acl, OIC_SEC_ACL_V2, NULL));
91 }
92
93 TEST(SRPProvisionACLTest, NullACL)
94 {
95     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionACL(NULL, &pDev1, NULL, OIC_SEC_ACL_V2, &provisioningCB));
96 }
97
98 TEST(SRPProvisionACLTest, InvalidVersion)
99 {
100     EXPECT_EQ(OC_STACK_ERROR, SRPProvisionACL(NULL, &pDev1, &acl, OIC_SEC_ACL_UNKNOWN, &provisioningCB));
101 }
102
103 TEST(SRPProvisionCredentialsTest, NullDevice1)
104 {
105     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionCredentials(NULL, credType,
106                                                               OWNER_PSK_LENGTH_128, NULL,
107                                                               &pDev2, NULL, NULL, NULL, &provisioningCB));
108 }
109
110 TEST(SRPProvisionCredentialsTest, SamelDeviceId)
111 {
112     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionCredentials(NULL, credType,
113                                                               OWNER_PSK_LENGTH_128, &pDev1,
114                                                               &pDev1, NULL, NULL, NULL, &provisioningCB));
115 }
116
117 TEST(SRPProvisionCredentialsTest, NullCallback)
118 {
119     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPProvisionCredentials(NULL, credType,
120                                                                  OWNER_PSK_LENGTH_128,
121                                                                  &pDev1, &pDev2, NULL, NULL, NULL, NULL));
122 }
123
124 TEST(SRPProvisionCredentialsTest, InvalidKeySize)
125 {
126     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionCredentials(NULL, credType,
127                                                                 0, &pDev1, &pDev2, NULL, NULL, NULL, 
128                                                                 &provisioningCB));
129 }
130
131 TEST(SRPUnlinkDevicesTest, NullDevice1)
132 {
133     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPUnlinkDevices(NULL, NULL, &pDev2, provisioningCB));
134 }
135
136 TEST(SRPUnlinkDevicesTest, SamelDeviceId)
137 {
138     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPUnlinkDevices(NULL, &pDev1, &pDev1, provisioningCB));
139 }
140
141 TEST(SRPUnlinkDevicesTest, NullCallback)
142 {
143     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPUnlinkDevices(NULL, &pDev1, &pDev2, NULL));
144 }
145
146 TEST(SRPRemoveDeviceTest, NullTargetDevice)
147 {
148     unsigned short waitTime = 10 ;
149     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPRemoveDevice(NULL, waitTime, NULL, provisioningCB));
150 }
151
152 TEST(SRPRemoveDeviceTest, NullResultCallback)
153 {
154     unsigned short waitTime = 10;
155     OCProvisionDev_t dev1;
156     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPRemoveDevice(NULL, waitTime, &dev1, NULL));
157 }
158
159 TEST(SRPRemoveDeviceTest, ZeroWaitTime)
160 {
161     OCProvisionDev_t dev1;
162     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPRemoveDevice(NULL, 0, &dev1, NULL));
163 }
164
165 TEST(SRPProvisionDirectPairingTest, NullselectedDeviceInfo)
166 {
167     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionDirectPairing(NULL, NULL, &pconf, &provisioningCB));
168 }
169
170 TEST(SRPProvisionDirectPairingTest, Nullpconf)
171 {
172     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionDirectPairing(NULL, &selectedDeviceInfo, NULL, &provisioningCB));
173 }
174
175 TEST(SRPProvisionDirectPairingTest, Nullcallback)
176 {
177     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPProvisionDirectPairing(NULL, &selectedDeviceInfo, &pconf, NULL));
178 }
179
180 const char *SECURE_RESOURCE_PROVIDER_TEST_FILE_NAME = "secureresourceprovider.dat";
181 OCPersistentStorage ps = { NULL, NULL, NULL, NULL, NULL};
182
183 static FILE* TestFopen(const char *path, const char *mode)
184 {
185     if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))
186     {
187         return fopen(SECURE_RESOURCE_PROVIDER_TEST_FILE_NAME, mode);
188     }
189     else
190     {
191         return fopen(path, mode);
192     }
193 }
194
195 void SetPersistentHandler(OCPersistentStorage *persistentStorage)
196 {
197     if(persistentStorage)
198     {
199         persistentStorage->open = TestFopen;
200         persistentStorage->read = fread;
201         persistentStorage->write = fwrite;
202         persistentStorage->close = fclose;
203         persistentStorage->unlink = remove;
204     }
205 }
206
207 class SRPTest : public ::testing::Test
208 {
209 public:
210     static void SetUpTestCase()
211     {
212         SetPersistentHandler(&ps);
213         OCStackResult res = OCRegisterPersistentStorageHandler(&ps);
214         ASSERT_TRUE(res == OC_STACK_OK);
215         res = OCInit(NULL, 0, OC_SERVER);
216         ASSERT_TRUE(res == OC_STACK_OK);
217     }
218
219     static void TearDownTestCase()
220     {
221         OCStackResult res = OCStop();
222         ASSERT_TRUE(res == OC_STACK_OK);
223     }
224
225     static const ByteArray g_caPublicKey;
226
227     static const ByteArray g_derCode ;
228
229     static ByteArray g_serNum;
230 };
231
232 static uint8_t certData[] = {
233         0x30, 0x82, 0x02, 0x39, 0x30, 0x82, 0x01, 0xdf, 0x02, 0x01, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a,
234         0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x7c, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
235         0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c,
236         0x09, 0x53, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03,
237         0x55, 0x04, 0x07, 0x0c, 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x63, 0x69, 0x74, 0x79, 0x31, 0x0b, 0x30,
238         0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x42, 0x42, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03,
239         0x55, 0x04, 0x0b, 0x0c, 0x0d, 0x53, 0x65, 0x71, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x50, 0x61,
240         0x72, 0x74, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x02, 0x6f, 0x62, 0x31,
241         0x14, 0x30, 0x12, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x05,
242         0x6f, 0x62, 0x40, 0x62, 0x62, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x38, 0x31, 0x35, 0x31,
243         0x33, 0x31, 0x31, 0x31, 0x37, 0x5a, 0x17, 0x0d, 0x31, 0x39, 0x30, 0x35, 0x31, 0x32, 0x31, 0x33,
244         0x31, 0x31, 0x31, 0x37, 0x5a, 0x30, 0x81, 0xd4, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
245         0x06, 0x13, 0x02, 0x55, 0x41, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x03,
246         0x41, 0x73, 0x64, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x06, 0x47, 0x6f,
247         0x74, 0x68, 0x61, 0x6d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x5a,
248         0x5a, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x08, 0x42, 0x65, 0x61, 0x6d,
249         0x54, 0x65, 0x61, 0x6d, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
250         0x01, 0x09, 0x01, 0x16, 0x0d, 0x72, 0x61, 0x69, 0x6c, 0x40, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x63,
251         0x6f, 0x6d, 0x31, 0x32, 0x30, 0x30, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x29, 0x75, 0x75, 0x69,
252         0x64, 0x3a, 0x33, 0x32, 0x33, 0x32, 0x33, 0x32, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x33, 0x32, 0x2d,
253         0x33, 0x32, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x33, 0x32, 0x33, 0x32,
254         0x33, 0x32, 0x33, 0x32, 0x33, 0x32, 0x31, 0x34, 0x30, 0x32, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x0c,
255         0x2b, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x3a, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37,
256         0x2d, 0x36, 0x37, 0x36, 0x37, 0x2d, 0x36, 0x37, 0x36, 0x37, 0x2d, 0x36, 0x37, 0x36, 0x37, 0x2d,
257         0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x30, 0x59, 0x30, 0x13,
258         0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
259         0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xf7, 0x13, 0x5c, 0x73, 0x72, 0xce, 0x10, 0xe5, 0x09,
260         0x97, 0x9a, 0xf8, 0xf2, 0x70, 0xa6, 0x3d, 0x89, 0xf5, 0xc5, 0xe4, 0x44, 0xe2, 0x4a, 0xb6, 0x61,
261         0xa8, 0x12, 0x8d, 0xb4, 0xdc, 0x2b, 0x47, 0x84, 0x60, 0x0c, 0x25, 0x66, 0xe9, 0xe0, 0xe5, 0xac,
262         0x22, 0xbf, 0x15, 0xdc, 0x71, 0xb1, 0x88, 0x4f, 0x16, 0xbf, 0xc2, 0x77, 0x37, 0x76, 0x3f, 0xe0,
263         0x67, 0xc6, 0x1d, 0x23, 0xfe, 0x7c, 0x8b, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
264         0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x47, 0xcc, 0x41, 0x8a, 0x27, 0xc7,
265         0xd0, 0xaa, 0xb4, 0xab, 0x85, 0xbf, 0x09, 0x4d, 0x06, 0xd7, 0x7e, 0x0d, 0x39, 0xf9, 0x36, 0xa1,
266         0x3d, 0x96, 0x23, 0xe2, 0x24, 0x64, 0x98, 0x63, 0x21, 0xba, 0x02, 0x21, 0x00, 0xe5, 0x8f, 0x7f,
267         0xf1, 0xa6, 0x82, 0x03, 0x6a, 0x18, 0x7a, 0x54, 0xe7, 0x0e, 0x25, 0x77, 0xd8, 0x46, 0xfa, 0x96,
268         0x8a, 0x7e, 0x14, 0xc4, 0xcb, 0x21, 0x32, 0x3e, 0x89, 0xd9, 0xba, 0x8c, 0x3f
269     };
270
271 static uint8_t keyData[] = {
272             0x67, 0xc6, 0x1d, 0x23, 0xfe, 0x7c, 0x8b, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
273         0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x47, 0xcc, 0x41, 0x8a, 0x27, 0xc7,
274         0xd0, 0xaa, 0xb4, 0xab, 0x85, 0xbf, 0x09, 0x4d, 0x06, 0xd7, 0x7e, 0x0d, 0x39, 0xf9, 0x36, 0xa1,
275         0x3d, 0x96, 0x23, 0xe2, 0x24, 0x64, 0x98, 0x63, 0x21, 0xba, 0x02, 0x21
276     };
277
278 TEST_F(SRPTest, SRPSaveTrustCertChainDER)
279 {
280     int result;
281     uint16_t credId;
282
283     result = SRPSaveTrustCertChain(certData, sizeof(certData), OIC_ENCODING_DER, &credId);
284     EXPECT_EQ(OC_STACK_OK, result);
285 }
286
287 TEST_F(SRPTest, SRPSaveTrustCertChainPEM)
288 {
289     int result;
290     uint16_t credId;
291
292     result = SRPSaveTrustCertChain(certData, sizeof(certData), OIC_ENCODING_PEM, &credId);
293     EXPECT_EQ(OC_STACK_OK, result);
294 }
295
296 TEST_F(SRPTest, SRPSaveTrustCertChainNullCertData)
297 {
298     int result;
299     uint16_t credId;
300
301     result = SRPSaveTrustCertChain(NULL, sizeof(certData), OIC_ENCODING_DER, &credId);
302
303     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
304 }
305
306 TEST_F(SRPTest, SRPSaveTrustCertChainNullCredId)
307 {
308     int result;
309
310     result = SRPSaveTrustCertChain(certData, sizeof(certData), OIC_ENCODING_DER, NULL);
311
312     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
313 }
314
315 TEST_F(SRPTest, SRPSaveOwnCertChainTest)
316 {
317     int result;
318     uint16_t credId;
319     OicSecKey_t cert;
320     OicSecKey_t key;
321
322     cert.data = certData;
323     cert.len = sizeof(certData);
324     cert.encoding = OIC_ENCODING_DER;
325
326     key.data = keyData;
327     key.len = sizeof(keyData);
328     key.encoding = OIC_ENCODING_DER;
329
330     result = SRPSaveOwnCertChain(&cert, &key, &credId);
331
332     EXPECT_EQ(OC_STACK_OK, result);
333 }
334
335 TEST_F(SRPTest, SRPSaveOwnCertChainTestNullCert)
336 {
337     int result;
338     uint16_t credId;
339     OicSecKey_t key;
340
341     key.data = keyData;
342     key.len = sizeof(keyData);
343
344     result = SRPSaveOwnCertChain(NULL, &key, &credId);
345
346     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
347 }
348
349 TEST_F(SRPTest, SRPSaveOwnCertChainTestNullCertData)
350 {
351     int result;
352     uint16_t credId;
353     OicSecKey_t cert;
354     OicSecKey_t key;
355
356     cert.data = NULL;
357     cert.len = sizeof(certData);
358     key.data = keyData;
359     key.len = sizeof(keyData);
360
361     result = SRPSaveOwnCertChain(&cert, &key, &credId);
362
363     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
364 }
365
366 TEST_F(SRPTest, SRPSaveOwnCertChainTestNullKey)
367 {
368     int result;
369     uint16_t credId;
370     OicSecKey_t cert;
371
372     cert.data = certData;
373     cert.len = sizeof(certData);
374
375     result = SRPSaveOwnCertChain(&cert, NULL, &credId);
376
377     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
378 }
379
380 TEST_F(SRPTest, SRPSaveOwnCertChainTestNullKeyData)
381 {
382     int result;
383     uint16_t credId;
384     OicSecKey_t cert;
385     OicSecKey_t key;
386
387     cert.data = certData;
388     cert.len = sizeof(certData);
389     key.data = NULL;
390     key.len = sizeof(keyData);
391
392     result = SRPSaveOwnCertChain(&cert, &key, &credId);
393
394     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
395 }
396
397 TEST_F(SRPTest, SRPSaveOwnCertChainTestNullCredId)
398 {
399     int result;
400     OicSecKey_t cert;
401     OicSecKey_t key;
402
403     cert.data = certData;
404     cert.len = sizeof(certData);
405     key.data = keyData;
406     key.len = sizeof(keyData);
407
408     result = SRPSaveOwnCertChain(&cert, &key, NULL);
409
410     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
411 }
412
413
414 TEST(SRPProvisionTrustCertChainTest, SRPProvisionTrustCertChainNullSelectedDeviceInfo)
415 {
416     int result;
417     int ctx;
418     OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
419     uint16_t credId = 0;
420
421     result = SRPProvisionTrustCertChain(&ctx, type, credId, NULL, provisioningCB);
422     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
423 }
424
425 TEST(SRPProvisionTrustCertChainTest, SRPProvisionTrustCertChainNullResultCallback)
426 {
427     int result;
428     int ctx;
429     OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
430     uint16_t credId = 0;
431     OCProvisionDev_t deviceInfo;
432
433     result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, NULL);
434     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, result);
435 }
436
437 TEST(SRPProvisionTrustCertChainTest, SRPProvisionTrustCertChainInvalidOicSecCredType)
438 {
439     int result;
440     int ctx;
441     OicSecCredType_t type = PIN_PASSWORD;
442     uint16_t credId = 0;
443     OCProvisionDev_t deviceInfo;
444
445     result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, provisioningCB);
446     EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
447 }
448
449 TEST_F(SRPTest, SRPProvisionTrustCertChainNoResource)
450 {
451     int result;
452     int ctx;
453     OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
454     uint16_t credId = 0;
455     OCProvisionDev_t deviceInfo;
456
457     result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, provisioningCB);
458     EXPECT_EQ(OC_STACK_ERROR, result);
459 }
460
461 TEST(SRPProvisionTrustCertChainTest, SRPGetACLResourceNoCallback)
462 {
463     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPGetACLResource(NULL, &pDev1, OIC_SEC_ACL_V2, NULL));
464 }
465
466 TEST(SRPProvisionTrustCertChainTest, SRPGetACLResourceNoDevice)
467 {
468     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPGetACLResource(NULL, NULL, OIC_SEC_ACL_V2, provisioningCB));
469 }
470
471 TEST(SRPProvisionTrustCertChainTest, SRPGetCredResourceNoCallback)
472 {
473     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPGetCredResource(NULL, &pDev1, NULL));
474 }
475
476 TEST(SRPProvisionTrustCertChainTest, SRPGetCredResourceNoDevice)
477 {
478     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPGetCredResource(NULL, NULL, provisioningCB));
479 }
480
481 TEST(SRPProvisionTrustCertChainTest, SRPResetDeviceNoCallback)
482 {
483     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPResetDevice(&pDev1, NULL));
484 }
485
486 TEST(SRPProvisionTrustCertChainTest, SRPResetDeviceNoDevice)
487 {
488     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPResetDevice(NULL, provisioningCB));
489 }
490
491 TEST(SRPProvisionTrustCertChainTest, SRPSyncDeviceNoCallback)
492 {
493     EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPSyncDevice(NULL, timeout, &pDev1, NULL));
494 }
495
496 TEST(SRPProvisionTrustCertChainTest, SRPSyncDeviceNoDevice)
497 {
498     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPSyncDevice(NULL, timeout, NULL, provisioningCB));
499 }
500
501 TEST(SRPProvisionTrustCertChainTest, SRPSyncDeviceZeroWaitTime)
502 {
503     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPSyncDevice(NULL, 0, &pDev1, provisioningCB));
504 }
505
506 TEST(SRPProvisionTrustCertChainTest, SRPRemoveDeviceWithoutDiscoveryNoCallback)
507 {
508     EXPECT_EQ(OC_STACK_INVALID_CALLBACK,
509               SRPRemoveDeviceWithoutDiscovery(NULL, &pDev1, &pDev2, NULL));
510 }
511
512 TEST(SRPProvisionTrustCertChainTest, SRPRemoveDeviceWithoutDiscoveryNoDevice)
513 {
514     EXPECT_EQ(OC_STACK_INVALID_PARAM,
515               SRPRemoveDeviceWithoutDiscovery(NULL, &pDev1, NULL, provisioningCB));
516 }
517
518 TEST(SRPProvisionTrustCertChainTest, SRPRemoveDeviceWithoutDiscoveryNoDeviceList)
519 {
520     EXPECT_EQ(OC_STACK_CONTINUE,
521               SRPRemoveDeviceWithoutDiscovery(NULL, NULL, &pDev2, provisioningCB));
522 }
523