CKM: Tests for algorithm parameters 58/39058/4
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 7 May 2015 15:40:18 +0000 (17:40 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 15 May 2015 15:43:59 +0000 (08:43 -0700)
[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

src/ckm/CMakeLists.txt
src/ckm/algo-param.cpp [new file with mode: 0644]

index 669ee1f..00e55c7 100644 (file)
@@ -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 (file)
index 0000000..824be6f
--- /dev/null
@@ -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 <string>
+#include <memory>
+#include <ckm/ckm-type.h>
+#include <ckm/ckm-error.h>
+#include <dpl/test/test_runner.h>
+
+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");
+}
+