1 /******************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
22 #include "gtest/gtest.h"
24 #include "ocpayload.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"
37 #define TAG "SRM-CRL-UT"
39 void DeleteCrl(OicSecCrl_t *crl)
44 OICFree(crl->ThisUpdate.data);
45 crl->ThisUpdate.data = NULL;
47 OICFree(crl->CrlData.data);
48 crl->CrlData.data = NULL;
55 //InitCRLResource Tests
56 TEST(CRLResourceTest, InitCRLResource)
58 EXPECT_EQ(OC_STACK_INVALID_PARAM, InitCRLResource());
61 //DeInitCredResource Tests
62 TEST(CRLResourceTest, DeInitCRLResource)
64 EXPECT_EQ(OC_STACK_INVALID_PARAM, DeInitCRLResource());
67 //GetCRLResource Tests
68 TEST(CRLResourceTest, GetCRLResource)
70 OicSecCrl_t *nullCrl = GetCRLResource();
71 EXPECT_NE((OicSecCrl_t*)NULL, nullCrl);
75 //CrlToCBORPayload Tests
76 TEST(CRLResourceTest, CrlToCBORPayload)
78 uint8_t *payload = NULL;
80 OicSecCrl_t *crl = GetCRLResource();
81 ASSERT_TRUE(NULL != crl);
82 size = crl->CrlData.len;
83 EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size));
88 //CBORPaylodToCrl Tests
89 TEST(CRLResourceTest, CBORPayloadToCrl)
91 uint8_t *payload = NULL;
93 OicSecCrl_t *crl = GetCRLResource();
94 ASSERT_TRUE(NULL != crl);
95 size = crl->CrlData.len;
96 EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size));
99 EXPECT_EQ(OC_STACK_OK, CBORPayloadToCrl(payload, size, &crl));
105 TEST(CRLResourceTest, GetDerCrl)
107 uint8_t crlData[CRL_MAX_LEN] = {0};
108 ByteArray crlArray = {crlData, CRL_MAX_LEN};
109 GetDerCrl(&crlArray);
110 EXPECT_NE(0, crlArray.len);