Dont force http server implementation to have cert copy in vector
BUG:24267885
Change-Id: Ic9d0ffecb9ea6b4caf0836372fae6565637c289c
Reviewed-on: https://weave-review.googlesource.com/1272
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/libweave/examples/ubuntu/event_http_server.cc b/libweave/examples/ubuntu/event_http_server.cc
index 4a7156a..8129c4f 100644
--- a/libweave/examples/ubuntu/event_http_server.cc
+++ b/libweave/examples/ubuntu/event_http_server.cc
@@ -212,8 +212,7 @@
return 7781;
}
-const std::vector<uint8_t>& HttpServerImpl::GetHttpsCertificateFingerprint()
- const {
+std::vector<uint8_t> HttpServerImpl::GetHttpsCertificateFingerprint() const {
return cert_fingerprint_;
}
diff --git a/libweave/examples/ubuntu/event_http_server.h b/libweave/examples/ubuntu/event_http_server.h
index 82c51dd..8be3716 100644
--- a/libweave/examples/ubuntu/event_http_server.h
+++ b/libweave/examples/ubuntu/event_http_server.h
@@ -32,7 +32,7 @@
const OnRequestCallback& callback) override;
uint16_t GetHttpPort() const override;
uint16_t GetHttpsPort() const override;
- const std::vector<uint8_t>& GetHttpsCertificateFingerprint() const override;
+ std::vector<uint8_t> GetHttpsCertificateFingerprint() const override;
private:
void GenerateX509();
diff --git a/libweave/include/weave/provider/http_server.h b/libweave/include/weave/provider/http_server.h
index 44c3e1d..e1eb30d 100644
--- a/libweave/include/weave/provider/http_server.h
+++ b/libweave/include/weave/provider/http_server.h
@@ -41,8 +41,7 @@
virtual uint16_t GetHttpPort() const = 0;
virtual uint16_t GetHttpsPort() const = 0;
- virtual const std::vector<uint8_t>& GetHttpsCertificateFingerprint()
- const = 0;
+ virtual std::vector<uint8_t> GetHttpsCertificateFingerprint() const = 0;
protected:
virtual ~HttpServer() = default;
diff --git a/libweave/include/weave/provider/test/mock_http_server.h b/libweave/include/weave/provider/test/mock_http_server.h
index c6fc755..95988ac 100644
--- a/libweave/include/weave/provider/test/mock_http_server.h
+++ b/libweave/include/weave/provider/test/mock_http_server.h
@@ -23,7 +23,7 @@
MOCK_CONST_METHOD0(GetHttpPort, uint16_t());
MOCK_CONST_METHOD0(GetHttpsPort, uint16_t());
- MOCK_CONST_METHOD0(GetHttpsCertificateFingerprint, std::vector<uint8_t>&());
+ MOCK_CONST_METHOD0(GetHttpsCertificateFingerprint, std::vector<uint8_t>());
};
} // namespace test
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc
index b6f9207..4eef7d4 100644
--- a/libweave/src/weave_unittest.cc
+++ b/libweave/src/weave_unittest.cc
@@ -200,7 +200,7 @@
EXPECT_CALL(http_server_, GetHttpPort()).WillRepeatedly(Return(11));
EXPECT_CALL(http_server_, GetHttpsPort()).WillRepeatedly(Return(12));
EXPECT_CALL(http_server_, GetHttpsCertificateFingerprint())
- .WillRepeatedly(ReturnRefOfCopy(std::vector<uint8_t>{1, 2, 3}));
+ .WillRepeatedly(Return(std::vector<uint8_t>{1, 2, 3}));
EXPECT_CALL(http_server_, AddRequestHandler(_, _))
.WillRepeatedly(
Invoke([this](const std::string& path_prefix,