2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <openssl/x509.h>
20 #include <dpl/test/test_runner.h>
21 #include <dpl/log/log.h>
24 #include <api_tests.h>
26 #include <cert-service.h>
28 RUNNER_TEST_GROUP_INIT(DEPRECATED_API)
30 typedef std::unique_ptr<CERT_CONTEXT, std::function<int(CERT_CONTEXT*)>> ScopedCertCtx;
35 * description: Loading *.pem file.
36 * expect: *.pem should load with no error.
38 RUNNER_TEST(deprecated_api_test01_pem_positive)
40 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
41 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR ==
42 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert0.pem"));
48 * description: Loading *.der file.
49 * expect: *.der file should load with no error.
51 RUNNER_TEST(deprecated_api_test02_der_positive)
53 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
54 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR ==
55 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert1.der"));
61 * description: Loading *.pem file.
62 * expect: *.pom file should not load and return error.
64 RUNNER_TEST(deprecated_api_test03_pem_negative)
66 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
67 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR !=
68 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert2fake.pem"));
74 * description: Loading *.der file.
75 * expect: *.der file should not load and return error.
77 RUNNER_TEST(deprecated_api_test03_der_negative)
79 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
80 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR !=
81 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert3fake.der"));