From: Krzysztof Jackiewicz Date: Thu, 7 May 2015 15:40:18 +0000 (+0200) Subject: CKM: Tests for algorithm parameters X-Git-Tag: security-manager_5.5_testing~9^2~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df4d3773a6af6fe7939d87c5a3921ce5cf2e63da;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git CKM: Tests for algorithm parameters [Issue#] N/A [Feature/Bug] N/A [Problem] N/A [Cause] N/A [Solution] N/A [Verification] Run ckm-tests --group=ALGO_PARAM_TEST Change-Id: Idd5d5263ead78139efcde882d9829c4b225ab138 --- diff --git a/src/ckm/CMakeLists.txt b/src/ckm/CMakeLists.txt index 669ee1f3..00e55c7a 100644 --- a/src/ckm/CMakeLists.txt +++ b/src/ckm/CMakeLists.txt @@ -50,6 +50,7 @@ SET(CKM_SOURCES ${PROJECT_SOURCE_DIR}/src/ckm/system-db.cpp ${PROJECT_SOURCE_DIR}/src/ckm/clean-env.cpp ${PROJECT_SOURCE_DIR}/src/ckm/test-certs.cpp + ${PROJECT_SOURCE_DIR}/src/ckm/algo-param.cpp ) INCLUDE_DIRECTORIES(SYSTEM ${CKM_DEP_INCLUDE_DIRS}) diff --git a/src/ckm/algo-param.cpp b/src/ckm/algo-param.cpp new file mode 100644 index 00000000..824be6fe --- /dev/null +++ b/src/ckm/algo-param.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +/* + * @file test_algo-param.cpp + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + */ + +#include +#include +#include +#include +#include + +namespace { +unsigned long long LOOONG_INT = 0xffffffffffffffff; +const std::string TEXT("dasfagfshgrethtrtregsdgsgsdgserhse"); +const CKM::RawBuffer BUFFER(TEXT.begin(), TEXT.end()); +} // namespace anonymous + +RUNNER_TEST_GROUP_INIT(ALGO_PARAM_TEST) + +RUNNER_TEST(TAP_0010_IntParam) { + CKM::BaseParamPtr bp = CKM::IntParam::create(LOOONG_INT); + + unsigned long long integer = 0; + CKM::RawBuffer buffer; + RUNNER_ASSERT_MSG(CKM_API_SUCCESS == bp->getInt(integer), "Integer extraction failed"); + RUNNER_ASSERT_MSG(integer == LOOONG_INT, "Unexpected integer value: " << integer); + RUNNER_ASSERT_MSG(CKM_API_ERROR_INVALID_FORMAT == bp->getBuffer(buffer), + "Buffer extraction should fail"); +} + +RUNNER_TEST(TAP_0020_BufferParam) { + CKM::BaseParamPtr bp = CKM::BufferParam::create(BUFFER); + + unsigned long long integer = 0; + CKM::RawBuffer buffer; + RUNNER_ASSERT_MSG(CKM_API_SUCCESS == bp->getBuffer(buffer), "Buffer extraction failed"); + RUNNER_ASSERT_MSG(buffer == BUFFER, "Unexpected buffer value"); + RUNNER_ASSERT_MSG(CKM_API_ERROR_INVALID_FORMAT == bp->getInt(integer), + "Integer extraction should fail"); +} +