| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/test/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 const CertificateValuesEntry kCertificateValuesEntry[] = { | 474 const CertificateValuesEntry kCertificateValuesEntry[] = { |
| 475 {EmbeddedTestServer::CERT_OK, false, "127.0.0.1", "Test Root CA"}, | 475 {EmbeddedTestServer::CERT_OK, false, "127.0.0.1", "Test Root CA"}, |
| 476 {EmbeddedTestServer::CERT_MISMATCHED_NAME, false, "127.0.0.1", | 476 {EmbeddedTestServer::CERT_MISMATCHED_NAME, false, "127.0.0.1", |
| 477 "Test Root CA"}, | 477 "Test Root CA"}, |
| 478 {EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN, false, "localhost", | 478 {EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN, false, "localhost", |
| 479 "Test Root CA"}, | 479 "Test Root CA"}, |
| 480 {EmbeddedTestServer::CERT_EXPIRED, true, "127.0.0.1", "Test Root CA"}, | 480 {EmbeddedTestServer::CERT_EXPIRED, true, "127.0.0.1", "Test Root CA"}, |
| 481 {EmbeddedTestServer::CERT_CHAIN_WRONG_ROOT, false, "127.0.0.1", "B CA"}, | 481 {EmbeddedTestServer::CERT_CHAIN_WRONG_ROOT, false, "127.0.0.1", "B CA"}, |
| 482 #if !defined(OS_WIN) | 482 #if !defined(OS_WIN) && !defined(OS_ANDROID) |
| 483 {EmbeddedTestServer::CERT_BAD_VALIDITY, true, "Leaf Certificate", | 483 {EmbeddedTestServer::CERT_BAD_VALIDITY, true, "Leaf Certificate", |
| 484 "Test Root CA"}, | 484 "Test Root CA"}, |
| 485 #endif | 485 #endif |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 TEST_P(EmbeddedTestServerTest, GetCertificate) { | 488 TEST_P(EmbeddedTestServerTest, GetCertificate) { |
| 489 if (GetParam() != EmbeddedTestServer::TYPE_HTTPS) | 489 if (GetParam() != EmbeddedTestServer::TYPE_HTTPS) |
| 490 return; | 490 return; |
| 491 | 491 |
| 492 for (const auto& certEntry : kCertificateValuesEntry) { | 492 for (const auto& certEntry : kCertificateValuesEntry) { |
| 493 SCOPED_TRACE(certEntry.server_cert); |
| 493 server_->SetSSLConfig(certEntry.server_cert); | 494 server_->SetSSLConfig(certEntry.server_cert); |
| 494 scoped_refptr<X509Certificate> cert = server_->GetCertificate(); | 495 scoped_refptr<X509Certificate> cert = server_->GetCertificate(); |
| 495 DCHECK(cert.get()); | 496 ASSERT_TRUE(cert); |
| 496 EXPECT_EQ(cert->HasExpired(), certEntry.is_expired); | 497 EXPECT_EQ(cert->HasExpired(), certEntry.is_expired); |
| 497 EXPECT_EQ(cert->subject().common_name, certEntry.common_name); | 498 EXPECT_EQ(cert->subject().common_name, certEntry.common_name); |
| 498 EXPECT_EQ(cert->issuer().common_name, certEntry.root); | 499 EXPECT_EQ(cert->issuer().common_name, certEntry.root); |
| 499 } | 500 } |
| 500 } | 501 } |
| 501 | 502 |
| 502 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerTestInstantiation, | 503 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerTestInstantiation, |
| 503 EmbeddedTestServerTest, | 504 EmbeddedTestServerTest, |
| 504 testing::Values(EmbeddedTestServer::TYPE_HTTP, | 505 testing::Values(EmbeddedTestServer::TYPE_HTTP, |
| 505 EmbeddedTestServer::TYPE_HTTPS)); | 506 EmbeddedTestServer::TYPE_HTTPS)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 INSTANTIATE_TEST_CASE_P( | 611 INSTANTIATE_TEST_CASE_P( |
| 611 EmbeddedTestServerThreadingTestInstantiation, | 612 EmbeddedTestServerThreadingTestInstantiation, |
| 612 EmbeddedTestServerThreadingTest, | 613 EmbeddedTestServerThreadingTest, |
| 613 testing::Combine(testing::Bool(), | 614 testing::Combine(testing::Bool(), |
| 614 testing::Bool(), | 615 testing::Bool(), |
| 615 testing::Values(EmbeddedTestServer::TYPE_HTTP, | 616 testing::Values(EmbeddedTestServer::TYPE_HTTP, |
| 616 EmbeddedTestServer::TYPE_HTTPS))); | 617 EmbeddedTestServer::TYPE_HTTPS))); |
| 617 | 618 |
| 618 } // namespace test_server | 619 } // namespace test_server |
| 619 } // namespace net | 620 } // namespace net |
| OLD | NEW |