Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: webrtc/base/sslidentity_unittest.cc

Issue 1468273004: Provide method for returning certificate expiration timestamp. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Move most new code from opensslidentity.cc to timeutils.cc and sslidentity.cc Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/sslidentity_unittest.cc
diff --git a/webrtc/base/sslidentity_unittest.cc b/webrtc/base/sslidentity_unittest.cc
index e8df41506ba90383e9ca89969e75b5b20fe38eeb..cc0f7f8a3cb1cf6c3b1db0a983e042d635bd519b 100644
--- a/webrtc/base/sslidentity_unittest.cc
+++ b/webrtc/base/sslidentity_unittest.cc
@@ -11,6 +11,7 @@
#include <string>
#include "webrtc/base/gunit.h"
+#include "webrtc/base/helpers.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslidentity.h"
@@ -295,3 +296,33 @@ TEST_F(SSLIdentityTest, PemDerConversion) {
TEST_F(SSLIdentityTest, GetSignatureDigestAlgorithm) {
TestGetSignatureDigestAlgorithm();
}
+
+class SSLIdentityExpirationTest : public testing::Test {
+ public:
+ SSLIdentityExpirationTest() {}
+ ~SSLIdentityExpirationTest() {}
+
+ void TestExpireTime(int times) {
+ for (int i = 0; i < times; i++) {
+ rtc::SSLIdentityParams params;
+ params.common_name = "";
+ params.not_before = 0;
+ // We limit the time to < 2^31 here, i.e., we stay before 2038, since else
+ // we hit time offset limitations in OpenSSL on some 32-bit systems.
+ params.not_after = rtc::CreateRandomId() % 0x80000000;
+ // We test just ECDSA here since what we're out to exercise here is the
+ // code for expiration setting and reading.
+ params.key_params = rtc::KeyParams::ECDSA(rtc::EC_NIST_P256);
+ SSLIdentity* identity = rtc::SSLIdentity::GenerateForTest(params);
+ EXPECT_EQ(params.not_after,
+ identity->certificate().CertificateExpirationTime());
+ delete identity;
+ }
+ }
+};
+
+TEST_F(SSLIdentityExpirationTest, Test) {
+ rtc::SetRandomTestMode(true);
+ TestExpireTime(500);
hbos 2015/11/26 16:43:37 If TestExpireTime(500) fails, will the effects of
+ rtc::SetRandomTestMode(false);
+}

Powered by Google App Engine
This is Rietveld 408576698