diff options
author | Janusz Kozerski <j.kozerski@samsung.com> | 2015-06-26 11:58:59 +0200 |
---|---|---|
committer | Janusz Kozerski <j.kozerski@samsung.com> | 2015-07-10 11:06:57 +0200 |
commit | 1bf0726b3028ddfaae0cdd70e46b416335da39a0 (patch) | |
tree | 3c4fff7b35b783a219f763315d4da94ef88137ad /tests/test_queue.cpp | |
parent | aa31c0517333688b611ba453b08138960b53244e (diff) | |
download | cert-checker-1bf0726b3028ddfaae0cdd70e46b416335da39a0.tar.gz cert-checker-1bf0726b3028ddfaae0cdd70e46b416335da39a0.tar.bz2 cert-checker-1bf0726b3028ddfaae0cdd70e46b416335da39a0.zip |
Refactor DB and app_t structure - preparation for OCSP checking.
New version of DB is needed to keep separately certificates from
each signatrue. Because application can be signed by more than one
signature we need to keep all certificates from all signatures in
separate lists to make building certificates' chains easier.
* Add operators (==, !=, <) for app_t structre
* Add operators (==, !=) for event_t structure
* Add tests for operators
* Remove check_id from app_t structure
Change-Id: I966dd81420618325d1afa55bcbc656291ccb4238
Diffstat (limited to 'tests/test_queue.cpp')
-rw-r--r-- | tests/test_queue.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/tests/test_queue.cpp b/tests/test_queue.cpp index 2fe7f3e..384d6e4 100644 --- a/tests/test_queue.cpp +++ b/tests/test_queue.cpp @@ -24,16 +24,28 @@ #include <string> #include <thread> -#include <cchecker/app.h> #include <cchecker/log.h> -#include <cchecker/queue.h> - #include <queue_test_thread.h> +#include <app_event_operators.h> using namespace CCHECKER; BOOST_FIXTURE_TEST_SUITE(QUEUE_TEST, Queue) +BOOST_AUTO_TEST_CASE(Queue_operators) { + app_t app1("app_id1", "pkg_id1", 1, {}); + app_t app2("app_id2", "pkg_id2", 2, {}); + app_t app3("app_id@", "###", 3, {}); + + event_t ev1(app1, event_t::event_type_t::APP_INSTALL); + event_t ev2(app1, event_t::event_type_t::APP_UNINSTALL); + + BOOST_REQUIRE(ev1 == ev1); + BOOST_REQUIRE(ev1 != ev2); + BOOST_REQUIRE(ev2 != ev1); + BOOST_REQUIRE(ev2 == ev2); +} + BOOST_AUTO_TEST_CASE(Queue) { app_t app1("app_id1", "pkg_id1", 1, {}); @@ -55,12 +67,8 @@ BOOST_AUTO_TEST_CASE(Queue) { BOOST_REQUIRE(empty() == false); BOOST_REQUIRE(pop_event(ev) == true); - BOOST_REQUIRE(ev1.app.app_id == ev.app.app_id); - BOOST_REQUIRE(ev1.app.pkg_id == ev.app.pkg_id); - BOOST_REQUIRE(ev1.app.uid == ev.app.uid); - // Certs and verified flag aren't used in queue, but can be tested - BOOST_REQUIRE(ev1.app.certificates == ev.app.certificates); - BOOST_REQUIRE(ev1.app.verified == ev.app.verified); + BOOST_REQUIRE(ev1 == ev); + BOOST_REQUIRE(empty() == true); push_event(ev2); @@ -68,21 +76,11 @@ BOOST_AUTO_TEST_CASE(Queue) { BOOST_REQUIRE(empty() == false); BOOST_REQUIRE(pop_event(ev) == true); - BOOST_REQUIRE(ev2.app.app_id == ev.app.app_id); - BOOST_REQUIRE(ev2.app.pkg_id == ev.app.pkg_id); - BOOST_REQUIRE(ev2.app.uid == ev.app.uid); - // Certs and verified flag aren't used in queue, but can be tested - BOOST_REQUIRE(ev2.app.certificates == ev.app.certificates); - BOOST_REQUIRE(ev2.app.verified == ev.app.verified); - + BOOST_REQUIRE(ev2 == ev); BOOST_REQUIRE(pop_event(ev) == true); - BOOST_REQUIRE(ev3.app.app_id == ev.app.app_id); - BOOST_REQUIRE(ev3.app.pkg_id == ev.app.pkg_id); - BOOST_REQUIRE(ev3.app.uid == ev.app.uid); - // Certs and verified flag aren't used in queue, but can be tested - BOOST_REQUIRE(ev3.app.certificates == ev.app.certificates); - BOOST_REQUIRE(ev3.app.verified == ev.app.verified); + BOOST_REQUIRE(ev3 == ev); + BOOST_REQUIRE(empty() == true); BOOST_REQUIRE(pop_event(ev) == false); @@ -96,12 +94,8 @@ BOOST_AUTO_TEST_CASE(Queue) { push_event(ev4); BOOST_REQUIRE(pop_event(ev) == true); - BOOST_REQUIRE(ev4.app.app_id == ev.app.app_id); - BOOST_REQUIRE(ev4.app.pkg_id == ev.app.pkg_id); - BOOST_REQUIRE(ev4.app.uid == ev.app.uid); - // Certs and verified flag aren't used in queue, but can be tested - BOOST_REQUIRE(ev4.app.certificates == ev.app.certificates); - BOOST_REQUIRE(ev4.app.verified == ev.app.verified); + BOOST_REQUIRE(ev4 == ev); + BOOST_REQUIRE(pop_event(ev) == false); BOOST_REQUIRE(empty() == true); |