Convert default version tests in ssl_test. BUG=129 Change-Id: Ie6950ebf8eac82f876cb185a025418d43ea752f6 Reviewed-on: https://boringssl-review.googlesource.com/15467 Reviewed-by: Steven Valdez <svaldez@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc index caa25b7..80465ce 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc
@@ -711,18 +711,23 @@ return true; } -static bool TestDefaultVersion(uint16_t min_version, uint16_t max_version, - const SSL_METHOD *(*method)(void)) { +static void ExpectDefaultVersion(uint16_t min_version, uint16_t max_version, + const SSL_METHOD *(*method)(void)) { bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(method())); - if (!ctx) { - return false; - } - if (ctx->min_version != min_version || ctx->max_version != max_version) { - fprintf(stderr, "Got min %04x, max %04x; wanted min %04x, max %04x\n", - ctx->min_version, ctx->max_version, min_version, max_version); - return false; - } - return true; + ASSERT_TRUE(ctx); + EXPECT_EQ(min_version, ctx->min_version); + EXPECT_EQ(max_version, ctx->max_version); +} + +TEST(SSLTest, DefaultVersion) { + // TODO(svaldez): Update this when TLS 1.3 is enabled by default. + ExpectDefaultVersion(TLS1_VERSION, TLS1_2_VERSION, &TLS_method); + ExpectDefaultVersion(TLS1_VERSION, TLS1_VERSION, &TLSv1_method); + ExpectDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &TLSv1_1_method); + ExpectDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &TLSv1_2_method); + ExpectDefaultVersion(TLS1_1_VERSION, TLS1_2_VERSION, &DTLS_method); + ExpectDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &DTLSv1_method); + ExpectDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &DTLSv1_2_method); } typedef struct { @@ -3457,14 +3462,6 @@ !TestBadSSL_SESSIONEncoding(kBadSessionExtraField) || !TestBadSSL_SESSIONEncoding(kBadSessionVersion) || !TestBadSSL_SESSIONEncoding(kBadSessionTrailingData) || - // TODO(svaldez): Update this when TLS 1.3 is enabled by default. - !TestDefaultVersion(TLS1_VERSION, TLS1_2_VERSION, &TLS_method) || - !TestDefaultVersion(TLS1_VERSION, TLS1_VERSION, &TLSv1_method) || - !TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &TLSv1_1_method) || - !TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &TLSv1_2_method) || - !TestDefaultVersion(TLS1_1_VERSION, TLS1_2_VERSION, &DTLS_method) || - !TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &DTLSv1_method) || - !TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &DTLSv1_2_method) || // Test the padding extension at TLS 1.2. !TestPaddingExtension(TLS1_2_VERSION, TLS1_2_VERSION) || // Test the padding extension at TLS 1.3 with a TLS 1.2 session, so there