aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYecheng Zhao <zyecheng@google.com>2021-08-23 12:53:31 -0700
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-08-24 18:48:30 +0000
commitf15b206f3330a8adebf987098c828b534a6f9c5b (patch)
treece1c1a463dad487b7a6ecbfceee7315282380454
parent85e787b0ee93e429e0ee412997186ff4d291d544 (diff)
downloadpigweed-f15b206f3330a8adebf987098c828b534a6f9c5b.tar.gz
pw_tls_client: Align with new pw_stream
Use NonSeekableReaderWriter to replace ReaderWriter as base class for various classes such as Session and TLS test server class. Change-Id: Id7bc6835f8e8abe8559237326aab31d3f207dcae Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/57982 Reviewed-by: Wyatt Hepler <hepler@google.com> Reviewed-by: Ali Zhang <alizhang@google.com> Commit-Queue: Yecheng Zhao <zyecheng@google.com>
-rw-r--r--pw_tls_client/public/pw_tls_client/session.h2
-rw-r--r--pw_tls_client/public/pw_tls_client/test/test_server.h4
-rw-r--r--pw_tls_client_mbedtls/tls_client_mbedtls_test.cc19
3 files changed, 6 insertions, 19 deletions
diff --git a/pw_tls_client/public/pw_tls_client/session.h b/pw_tls_client/public/pw_tls_client/session.h
index 14388b5a0..a84d1330a 100644
--- a/pw_tls_client/public/pw_tls_client/session.h
+++ b/pw_tls_client/public/pw_tls_client/session.h
@@ -27,7 +27,7 @@
namespace pw::tls_client {
// Session provides APIs for performing TLS communication.
-class Session : public stream::ReaderWriter {
+class Session : public stream::NonSeekableReaderWriter {
public:
// Resources allocated during Session::Create() will be released in the
// destructor. For example, backend may choose to allocate Session from a pool
diff --git a/pw_tls_client/public/pw_tls_client/test/test_server.h b/pw_tls_client/public/pw_tls_client/test/test_server.h
index 9e8e5ff13..b5dc2997a 100644
--- a/pw_tls_client/public/pw_tls_client/test/test_server.h
+++ b/pw_tls_client/public/pw_tls_client/test/test_server.h
@@ -25,7 +25,7 @@
namespace pw::tls_client::test {
-class FixedSizeFIFOBuffer : public stream::ReaderWriter {
+class FixedSizeFIFOBuffer : public stream::NonSeekableReaderWriter {
public:
FixedSizeFIFOBuffer() = delete;
FixedSizeFIFOBuffer(const FixedSizeFIFOBuffer&) = delete;
@@ -47,7 +47,7 @@ class FixedSizeFIFOBuffer : public stream::ReaderWriter {
// Reading from the server is equivalent to receiving data from the server.
//
// The server accepts is only for one client and echo messages it sends.
-class InMemoryTestServer : public stream::ReaderWriter {
+class InMemoryTestServer : public stream::NonSeekableReaderWriter {
public:
InMemoryTestServer() = delete;
InMemoryTestServer(const InMemoryTestServer&) = delete;
diff --git a/pw_tls_client_mbedtls/tls_client_mbedtls_test.cc b/pw_tls_client_mbedtls/tls_client_mbedtls_test.cc
index 35e17e776..66242e8ad 100644
--- a/pw_tls_client_mbedtls/tls_client_mbedtls_test.cc
+++ b/pw_tls_client_mbedtls/tls_client_mbedtls_test.cc
@@ -13,25 +13,13 @@
// the License.
#include "gtest/gtest.h"
-#include "pw_stream/stream.h"
+#include "pw_stream/null_stream.h"
#include "pw_tls_client/session.h"
-namespace {
-
-class NoopTransport : public pw::stream::ReaderWriter {
- private:
- pw::StatusWithSize DoRead(pw::ByteSpan dest) { return pw::StatusWithSize(0); }
-
- pw::Status DoWrite(pw::ConstByteSpan data) { return pw::OkStatus(); }
-};
-
-} // namespace
-
namespace pw::tls_client {
TEST(TLSClientMbedTLS, CreateSucceed) {
- NoopTransport transport;
- auto options = SessionOptions().set_transport(transport);
+ auto options = SessionOptions().set_transport(stream::NullStream::Instance());
auto res = Session::Create(options);
ASSERT_EQ(res.status(), OkStatus());
ASSERT_NE(res.value(), nullptr);
@@ -45,8 +33,7 @@ TEST(TLSClientMbedTLS, CreateFailOnMissingTransport) {
TEST(TLSClientMbedTLS, EntropySourceFail) {
backend::SessionImplementation::SetEntropySourceStatus(Status::Internal());
- NoopTransport transport;
- auto options = SessionOptions().set_transport(transport);
+ auto options = SessionOptions().set_transport(stream::NullStream::Instance());
auto res = Session::Create(options);
ASSERT_NE(res.status(), OkStatus());
}