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>
23 #include <api_tests.h>
25 #include <cert-service.h>
27 RUNNER_TEST_GROUP_INIT(DEPRECATED_API)
29 typedef std::unique_ptr<CERT_CONTEXT, std::function<int(CERT_CONTEXT*)>> ScopedCertCtx;
34 * description: Loading *.pem file.
35 * expect: *.pem should load with no error.
37 RUNNER_TEST(deprecated_api_test01_pem_positive)
39 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
40 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR ==
41 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert0.pem"));
47 * description: Loading *.der file.
48 * expect: *.der file should load with no error.
50 RUNNER_TEST(deprecated_api_test02_der_positive)
52 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
53 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR ==
54 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert1.der"));
60 * description: Loading *.pem file.
61 * expect: *.pom file should not load and return error.
63 RUNNER_TEST(deprecated_api_test03_pem_negative)
65 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
66 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR !=
67 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert2fake.pem"));
73 * description: Loading *.der file.
74 * expect: *.der file should not load and return error.
76 RUNNER_TEST(deprecated_api_test03_der_negative)
78 ScopedCertCtx ctx(cert_svc_cert_context_init(), cert_svc_cert_context_final);
79 RUNNER_ASSERT(CERT_SVC_ERR_NO_ERROR !=
80 cert_svc_load_file_to_context(ctx.get(), "/usr/share/cert-svc/cert-type/cert3fake.der"));