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