replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / unittest / crlresourcetest.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 #ifdef __WITH_DTLS__
21
22 #include "gtest/gtest.h"
23 #include "logger.h"
24 #include "ocpayload.h"
25 #include "ocstack.h"
26 #include "oic_malloc.h"
27 #include "oic_string.h"
28 #include "resourcemanager.h"
29 #include "crlresource.h"
30 #include "securevirtualresourcetypes.h"
31 #include "srmtestcommon.h"
32 #include "srmutility.h"
33 #include "psinterface.h"
34 #include "security_internals.h"
35
36 #define TAG  "SRM-CRL-UT"
37
38  //InitCRLResource Tests
39 TEST(CRLResourceTest, InitCRLResource)
40 {
41     EXPECT_EQ(OC_STACK_INVALID_PARAM, InitCRLResource());
42 }
43
44 //DeInitCredResource Tests
45 TEST(CRLResourceTest, DeInitCRLResource)
46 {
47     EXPECT_EQ(OC_STACK_INVALID_PARAM, DeInitCRLResource());
48 }
49
50 //GetCRLResource Tests
51 TEST(CRLResourceTest, GetCRLResource)
52 {
53     OicSecCrl_t *nullCrl = GetCRLResource();
54     EXPECT_NE((OicSecCrl_t*)NULL, nullCrl);
55     DeleteCrl(nullCrl);
56 }
57
58 //CrlToCBORPayload Tests
59 TEST(CRLResourceTest, CrlToCBORPayload)
60 {
61     uint8_t *payload = NULL;
62     size_t size;
63     OicSecCrl_t *crl = GetCRLResource();
64     ASSERT_TRUE(NULL != crl);
65     size = 0;
66     EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
67     DeleteCrl(crl);
68     OICFree(payload);
69 }
70
71 //CBORPaylodToCrl Tests
72 TEST(CRLResourceTest, CBORPayloadToCrl)
73 {
74     uint8_t *payload = NULL;
75     size_t size;
76     OicSecCrl_t *crl = GetCRLResource();
77     ASSERT_TRUE(NULL != crl);
78     size = 0;
79     EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
80     DeleteCrl(crl);
81     crl = NULL;
82     EXPECT_EQ(OC_STACK_OK, CBORPayloadToCrl(payload, size, &crl));
83     DeleteCrl(crl);
84     OICFree(payload);
85 }
86
87 //GetDerCrl Tests
88 TEST(CRLResourceTest, GetDerCrl)
89 {
90     ByteArray crlArray = {NULL, 0};
91     GetDerCrl(&crlArray);
92     EXPECT_NE(0, crlArray.len);
93 }
94
95 #endif