From e8a7c88b6cedbd05b183e85dff74c513bfcd774e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 5 Jan 2023 19:47:05 +0100 Subject: Test config.cpp --- tests/test-auth.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/test-auth.cpp') diff --git a/tests/test-auth.cpp b/tests/test-auth.cpp index 8397b35..37bc02f 100644 --- a/tests/test-auth.cpp +++ b/tests/test-auth.cpp @@ -18,7 +18,16 @@ class AuthFixture public: AuthFixture(){} ~AuthFixture(){} - void setup(){} + void setup() + { + int filedes[2]; + if (pipe(filedes) == -1) + throw std::runtime_error("Pipe error"); + if (close(2) == -1) + throw std::runtime_error("Can't close stderr"); + if (dup(filedes[1]) == -1) + throw std::runtime_error("Replace stdout w/ pipe input"); + } void teardown(){} }; @@ -36,6 +45,7 @@ BOOST_FIXTURE_TEST_CASE(validate, AuthFixture) { BOOST_CHECK(Auth::validate("t5MMkLQXzYkdw", "abc")); + BOOST_CHECK(!Auth::validate("", "")); BOOST_CHECK(!Auth::validate("abc", "abc")); BOOST_CHECK(!Auth::validate("t5MNkLQXzYkdw", "abc")); } -- cgit v1.2.3