304369a308908841caaffc7582b160b75a3a9f3e
[platform/upstream/iotivity.git] / resource / provisioning / unittests / OCCloudProvisioningTest.cpp
1 /* *****************************************************************
2  *
3  * Copyright 2016 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 <ocstack.h>
22 #include <oic_malloc.h>
23 #include <OCApi.h>
24 #include <OCPlatform_impl.h>
25 #include <oxmjustworks.h>
26 #include <oxmrandompin.h>
27 #include <OCProvisioningManager.h>
28 #include <gtest/gtest.h>
29
30 #define TIMEOUT 5
31 static std::string IP("127.0.0.1");
32 static uint16_t PORT = 5683;
33
34 namespace OCCloudProvisioningTest
35 {
36     using namespace OC;
37
38     void resultCallback(OCStackResult result, void *data)
39     {
40         (void)result;
41         (void)data;
42     }
43
44     TEST(RequestCertTest, TestNullCallback)
45     {
46         OCCloudProvisioning cloud(IP, PORT);
47         EXPECT_EQ(OC_STACK_INVALID_CALLBACK, cloud.requestCertificate(NULL));
48     }
49
50     TEST(AclIdByDeviceTest, AclIdNullCallback)
51     {
52         OCCloudProvisioning cloud(IP, PORT);
53         std::string devId("");
54         EXPECT_EQ(OC_STACK_INVALID_CALLBACK, cloud.getAclIdByDevice(devId, NULL));
55     }
56
57     TEST(AclInfoTest, AclInfoNullCallback)
58     {
59         OCCloudProvisioning cloud(IP, PORT);
60         std::string aclId("");
61         EXPECT_EQ(OC_STACK_INVALID_CALLBACK, cloud.getIndividualAclInfo(aclId, NULL));
62     }
63
64     TEST(GetCRLTest, GetCrlNullCallback)
65     {
66         OCCloudProvisioning cloud(IP, PORT);
67         EXPECT_EQ(OC_STACK_INVALID_CALLBACK, cloud.getCRL(NULL));
68     }
69
70     TEST(PostCRLTest, PostCrlNullCallback)
71     {
72         std::string thisUpdate("");
73         std::string nextUpdate("");
74         OCByteString crl;
75         stringArray_t serials;
76         OCCloudProvisioning cloud(IP, PORT);
77         EXPECT_EQ(OC_STACK_INVALID_CALLBACK, cloud.postCRL(thisUpdate,
78                                                     nextUpdate,
79                                                     &crl, &serials, NULL));
80     }
81 }