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"
36 #define TAG "SRM-CRL-UT"
38 //InitCRLResource Tests
39 TEST(CRLResourceTest, InitCRLResource)
41 EXPECT_EQ(OC_STACK_INVALID_PARAM, InitCRLResource());
44 //DeInitCredResource Tests
45 TEST(CRLResourceTest, DeInitCRLResource)
47 EXPECT_EQ(OC_STACK_INVALID_PARAM, DeInitCRLResource());
50 //GetCRLResource Tests
51 TEST(CRLResourceTest, GetCRLResource)
53 OicSecCrl_t *nullCrl = GetCRLResource();
54 EXPECT_NE((OicSecCrl_t*)NULL, nullCrl);
58 //CrlToCBORPayload Tests
59 TEST(CRLResourceTest, CrlToCBORPayload)
61 uint8_t *payload = NULL;
63 OicSecCrl_t *crl = GetCRLResource();
64 ASSERT_TRUE(NULL != crl);
66 EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
71 //CBORPaylodToCrl Tests
72 TEST(CRLResourceTest, CBORPayloadToCrl)
74 uint8_t *payload = NULL;
76 OicSecCrl_t *crl = GetCRLResource();
77 ASSERT_TRUE(NULL != crl);
79 EXPECT_EQ(OC_STACK_OK, CrlToCBORPayload(crl, &payload, &size, NULL));
82 EXPECT_EQ(OC_STACK_OK, CBORPayloadToCrl(payload, size, &crl));
88 TEST(CRLResourceTest, GetDerCrl)
90 ByteArray crlArray = {NULL, 0};
92 EXPECT_NE(0, crlArray.len);