aboutsummaryrefslogtreecommitdiff
path: root/cast/sender/channel/cast_auth_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cast/sender/channel/cast_auth_util.cc')
-rw-r--r--cast/sender/channel/cast_auth_util.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/cast/sender/channel/cast_auth_util.cc b/cast/sender/channel/cast_auth_util.cc
index 6e9cf626..f0e1c36f 100644
--- a/cast/sender/channel/cast_auth_util.cc
+++ b/cast/sender/channel/cast_auth_util.cc
@@ -184,6 +184,21 @@ AuthContext AuthContext::Create() {
return AuthContext(CastNonce::Get());
}
+// static
+AuthContext AuthContext::CreateForTest(const std::string& nonce_data) {
+ std::string nonce;
+ if (nonce_data.empty()) {
+ nonce = std::string(kNonceSizeInBytes, '0');
+ } else {
+ while (nonce.size() < kNonceSizeInBytes) {
+ nonce += nonce_data;
+ }
+ nonce.erase(kNonceSizeInBytes);
+ }
+ OSP_DCHECK_EQ(nonce.size(), kNonceSizeInBytes);
+ return AuthContext(nonce);
+}
+
AuthContext::AuthContext(const std::string& nonce) : nonce_(nonce) {}
AuthContext::~AuthContext() {}