diff options
author | Jack Lloyd <[email protected]> | 2017-11-24 16:58:41 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-24 17:04:24 -0500 |
commit | e39593993e28019edc09724705adc04ecd9671cb (patch) | |
tree | 9bd6727b376387f8124389545282d68114e939e7 /src/tests | |
parent | d36213c9af8aa575a1a805a105e7bb3ddb647689 (diff) |
Add Pipe::append_filter
Similar to append but it only allows modfication before start_msg.
See GH #1306
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_filters.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp index 26d13e0bc..b8a4ee9f0 100644 --- a/src/tests/test_filters.cpp +++ b/src/tests/test_filters.cpp @@ -198,6 +198,7 @@ class Filter_Tests final : public Test Botan::Pipe pipe; + pipe.append_filter(nullptr); // ignored pipe.append(nullptr); // ignored pipe.prepend(nullptr); // ignored pipe.pop(); // empty pipe, so ignored @@ -213,11 +214,19 @@ class Filter_Tests final : public Test "Invalid argument Pipe::prepend: SecureQueue cannot be used", [&]() { pipe.prepend(queue_filter.get()); }); + pipe.append_filter(new Botan::BitBucket); // succeeds + pipe.pop(); + pipe.start_msg(); std::unique_ptr<Botan::Filter> filter(new Botan::BitBucket); // now inside a message, cannot modify pipe structure + + result.test_throws("pipe error", + "Cannot call Pipe::append_filter after start_msg", + [&]() { pipe.append_filter(filter.get()); }); + result.test_throws("pipe error", "Cannot append to a Pipe while it is processing", [&]() { pipe.append(filter.get()); }); @@ -233,6 +242,10 @@ class Filter_Tests final : public Test pipe.end_msg(); result.test_throws("pipe error", + "Cannot call Pipe::append_filter after start_msg", + [&]() { pipe.append_filter(filter.get()); }); + + result.test_throws("pipe error", "Invalid argument Pipe::read: Invalid message number 100", [&]() { uint8_t b; size_t got = pipe.read(&b, 1, 100); BOTAN_UNUSED(got); }); |