Reland "Add test for StunMessage::ValidateMessageIntegrity"
This reverts commit 3d992bf47f8253788c76f76b4e5087d7e9b66783. Reason for revert: Added counter reset at the right place. Original change's description: > Revert "Add test for StunMessage::ValidateMessageIntegrity" > > This reverts commit 1f4f672687861cae29259dd0c652d58de373dcac. > > Reason for revert: Breaks downstream test. > > Original change's description: > > Add test for StunMessage::ValidateMessageIntegrity > > > > This also tests the UMA stats newly added to it. > > > > Bug: chromium:1177125 > > Change-Id: I89bb17c1897565cd91ea5bbd92062018317738ca > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278600 > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#38345} > > Bug: chromium:1177125 > Change-Id: I2490f2f740db8282ab293583013a50d03ead9141 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278801 > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> > Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#38349} Bug: chromium:1177125 Change-Id: I38212aeff3a366d4b8beb9c822f709b9fcbb7146 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278802 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38353}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
15dfc5a567
commit
ac7577854f
@ -146,6 +146,7 @@ if (rtc_include_tests) {
|
||||
"../../rtc_base:byte_order",
|
||||
"../../rtc_base:macromagic",
|
||||
"../../rtc_base:socket_address",
|
||||
"../../system_wrappers:metrics",
|
||||
"../../test:test_support",
|
||||
"//testing/gtest",
|
||||
]
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "rtc_base/byte_buffer.h"
|
||||
#include "rtc_base/byte_order.h"
|
||||
#include "rtc_base/socket_address.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace cricket {
|
||||
@ -1855,4 +1856,27 @@ TEST_F(StunTest, SizeRestrictionOnAttributes) {
|
||||
ASSERT_FALSE(msg.Write(&out));
|
||||
}
|
||||
|
||||
TEST_F(StunTest, ValidateMessageIntegrityWithParser) {
|
||||
webrtc::metrics::Reset(); // Ensure counters start from zero.
|
||||
// Try the messages from RFC 5769.
|
||||
StunMessage message;
|
||||
rtc::ByteBufferReader reader(
|
||||
reinterpret_cast<const char*>(kRfc5769SampleRequest),
|
||||
sizeof(kRfc5769SampleRequest));
|
||||
EXPECT_TRUE(message.Read(&reader));
|
||||
EXPECT_EQ(message.ValidateMessageIntegrity(kRfc5769SampleMsgPassword),
|
||||
StunMessage::IntegrityStatus::kIntegrityOk);
|
||||
EXPECT_EQ(webrtc::metrics::NumEvents(
|
||||
"WebRTC.Stun.Integrity.Request",
|
||||
static_cast<int>(StunMessage::IntegrityStatus::kIntegrityOk)),
|
||||
1);
|
||||
EXPECT_EQ(message.ValidateMessageIntegrity("Invalid password"),
|
||||
StunMessage::IntegrityStatus::kIntegrityBad);
|
||||
EXPECT_EQ(webrtc::metrics::NumEvents(
|
||||
"WebRTC.Stun.Integrity.Request",
|
||||
static_cast<int>(StunMessage::IntegrityStatus::kIntegrityBad)),
|
||||
1);
|
||||
EXPECT_EQ(webrtc::metrics::NumSamples("WebRTC.Stun.Integrity.Request"), 2);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
Reference in New Issue
Block a user