2 * Copyright (c) 2017 - 2020 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
16 #include <generic-backend/gobj.h>
17 #include <generic-backend/gstore.h>
18 #include <generic-backend/algo-validation.h>
19 #include <generic-backend/encryption-params.h>
21 #include <boost_macros_wrapper.h>
27 class GObjTest : public Crypto::GObj {
29 GObjTest() : Crypto::GObj(CryptoBackend::None) {}
32 struct TestException : public std::exception {};
34 class ThrowingHandlerTest {
36 static void Handle(const std::string &)
38 throw TestException();
42 } // namespace anonymous
44 BOOST_AUTO_TEST_SUITE(GENERIC_BACKEND_TEST)
46 NEGATIVE_TEST_CASE(gobj)
50 BOOST_REQUIRE_THROW(obj.getBinary(), Exc::Crypto::OperationNotSupported);
51 BOOST_REQUIRE_THROW(obj.encrypt(CryptoAlgorithm(), RawBuffer()),
52 Exc::Crypto::OperationNotSupported);
53 BOOST_REQUIRE_THROW(obj.decrypt(CryptoAlgorithm(), RawBuffer()),
54 Exc::Crypto::OperationNotSupported);
55 BOOST_REQUIRE_THROW(obj.sign(CryptoAlgorithm(), RawBuffer()),
56 Exc::Crypto::OperationNotSupported);
57 BOOST_REQUIRE_THROW(obj.verify(CryptoAlgorithm(), RawBuffer(), RawBuffer()),
58 Exc::Crypto::OperationNotSupported);
61 BOOST_AUTO_TEST_SUITE_END()