| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // Create two channels without DTLS, and transfer SRTP data. | 686 // Create two channels without DTLS, and transfer SRTP data. |
| 687 TEST_F(DtlsTransportChannelTest, TestTransferSrtpTwoChannels) { | 687 TEST_F(DtlsTransportChannelTest, TestTransferSrtpTwoChannels) { |
| 688 SetChannelCount(2); | 688 SetChannelCount(2); |
| 689 ASSERT_TRUE(Connect()); | 689 ASSERT_TRUE(Connect()); |
| 690 TestTransfer(0, 1000, 100, true); | 690 TestTransfer(0, 1000, 100, true); |
| 691 TestTransfer(1, 1000, 100, true); | 691 TestTransfer(1, 1000, 100, true); |
| 692 } | 692 } |
| 693 | 693 |
| 694 // Connect with DTLS, and transfer some data. | 694 // Connect with DTLS, and transfer some data. |
| 695 TEST_F(DtlsTransportChannelTest, TestTransferDtls) { | 695 TEST_F(DtlsTransportChannelTest, TestTransferDtls) { |
| 696 MAYBE_SKIP_TEST(HaveDtls); |
| 696 PrepareDtls(true, true, rtc::KT_DEFAULT); | 697 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 697 ASSERT_TRUE(Connect()); | 698 ASSERT_TRUE(Connect()); |
| 698 TestTransfer(0, 1000, 100, false); | 699 TestTransfer(0, 1000, 100, false); |
| 699 } | 700 } |
| 700 | 701 |
| 701 // Create two channels with DTLS, and transfer some data. | 702 // Create two channels with DTLS, and transfer some data. |
| 702 TEST_F(DtlsTransportChannelTest, TestTransferDtlsTwoChannels) { | 703 TEST_F(DtlsTransportChannelTest, TestTransferDtlsTwoChannels) { |
| 704 MAYBE_SKIP_TEST(HaveDtls); |
| 703 SetChannelCount(2); | 705 SetChannelCount(2); |
| 704 PrepareDtls(true, true, rtc::KT_DEFAULT); | 706 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 705 ASSERT_TRUE(Connect()); | 707 ASSERT_TRUE(Connect()); |
| 706 TestTransfer(0, 1000, 100, false); | 708 TestTransfer(0, 1000, 100, false); |
| 707 TestTransfer(1, 1000, 100, false); | 709 TestTransfer(1, 1000, 100, false); |
| 708 } | 710 } |
| 709 | 711 |
| 710 // Connect with A doing DTLS and B not, and transfer some data. | 712 // Connect with A doing DTLS and B not, and transfer some data. |
| 711 TEST_F(DtlsTransportChannelTest, TestTransferDtlsRejected) { | 713 TEST_F(DtlsTransportChannelTest, TestTransferDtlsRejected) { |
| 712 PrepareDtls(true, false, rtc::KT_DEFAULT); | 714 PrepareDtls(true, false, rtc::KT_DEFAULT); |
| 713 ASSERT_TRUE(Connect()); | 715 ASSERT_TRUE(Connect()); |
| 714 TestTransfer(0, 1000, 100, false); | 716 TestTransfer(0, 1000, 100, false); |
| 715 } | 717 } |
| 716 | 718 |
| 717 // Connect with B doing DTLS and A not, and transfer some data. | 719 // Connect with B doing DTLS and A not, and transfer some data. |
| 718 TEST_F(DtlsTransportChannelTest, TestTransferDtlsNotOffered) { | 720 TEST_F(DtlsTransportChannelTest, TestTransferDtlsNotOffered) { |
| 719 PrepareDtls(false, true, rtc::KT_DEFAULT); | 721 PrepareDtls(false, true, rtc::KT_DEFAULT); |
| 720 ASSERT_TRUE(Connect()); | 722 ASSERT_TRUE(Connect()); |
| 721 TestTransfer(0, 1000, 100, false); | 723 TestTransfer(0, 1000, 100, false); |
| 722 } | 724 } |
| 723 | 725 |
| 724 // Create two channels with DTLS 1.0 and check ciphers. | 726 // Create two channels with DTLS 1.0 and check ciphers. |
| 725 TEST_F(DtlsTransportChannelTest, TestDtls12None) { | 727 TEST_F(DtlsTransportChannelTest, TestDtls12None) { |
| 728 MAYBE_SKIP_TEST(HaveDtls); |
| 726 SetChannelCount(2); | 729 SetChannelCount(2); |
| 727 PrepareDtls(true, true, rtc::KT_DEFAULT); | 730 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 728 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); | 731 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); |
| 729 ASSERT_TRUE(Connect()); | 732 ASSERT_TRUE(Connect()); |
| 730 } | 733 } |
| 731 | 734 |
| 732 // Create two channels with DTLS 1.2 and check ciphers. | 735 // Create two channels with DTLS 1.2 and check ciphers. |
| 733 TEST_F(DtlsTransportChannelTest, TestDtls12Both) { | 736 TEST_F(DtlsTransportChannelTest, TestDtls12Both) { |
| 737 MAYBE_SKIP_TEST(HaveDtls); |
| 734 SetChannelCount(2); | 738 SetChannelCount(2); |
| 735 PrepareDtls(true, true, rtc::KT_DEFAULT); | 739 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 736 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); | 740 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); |
| 737 ASSERT_TRUE(Connect()); | 741 ASSERT_TRUE(Connect()); |
| 738 } | 742 } |
| 739 | 743 |
| 740 // Create two channels with DTLS 1.0 / DTLS 1.2 and check ciphers. | 744 // Create two channels with DTLS 1.0 / DTLS 1.2 and check ciphers. |
| 741 TEST_F(DtlsTransportChannelTest, TestDtls12Client1) { | 745 TEST_F(DtlsTransportChannelTest, TestDtls12Client1) { |
| 746 MAYBE_SKIP_TEST(HaveDtls); |
| 742 SetChannelCount(2); | 747 SetChannelCount(2); |
| 743 PrepareDtls(true, true, rtc::KT_DEFAULT); | 748 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 744 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); | 749 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); |
| 745 ASSERT_TRUE(Connect()); | 750 ASSERT_TRUE(Connect()); |
| 746 } | 751 } |
| 747 | 752 |
| 748 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers. | 753 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers. |
| 749 TEST_F(DtlsTransportChannelTest, TestDtls12Client2) { | 754 TEST_F(DtlsTransportChannelTest, TestDtls12Client2) { |
| 755 MAYBE_SKIP_TEST(HaveDtls); |
| 750 SetChannelCount(2); | 756 SetChannelCount(2); |
| 751 PrepareDtls(true, true, rtc::KT_DEFAULT); | 757 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 752 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); | 758 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); |
| 753 ASSERT_TRUE(Connect()); | 759 ASSERT_TRUE(Connect()); |
| 754 } | 760 } |
| 755 | 761 |
| 756 // Connect with DTLS, negotiate DTLS-SRTP, and transfer SRTP using bypass. | 762 // Connect with DTLS, negotiate DTLS-SRTP, and transfer SRTP using bypass. |
| 757 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { | 763 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { |
| 764 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 758 PrepareDtls(true, true, rtc::KT_DEFAULT); | 765 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 759 PrepareDtlsSrtp(true, true); | 766 PrepareDtlsSrtp(true, true); |
| 760 ASSERT_TRUE(Connect()); | 767 ASSERT_TRUE(Connect()); |
| 761 TestTransfer(0, 1000, 100, true); | 768 TestTransfer(0, 1000, 100, true); |
| 762 } | 769 } |
| 763 | 770 |
| 764 // Connect with DTLS-SRTP, transfer an invalid SRTP packet, and expects -1 | 771 // Connect with DTLS-SRTP, transfer an invalid SRTP packet, and expects -1 |
| 765 // returned. | 772 // returned. |
| 766 TEST_F(DtlsTransportChannelTest, TestTransferDtlsInvalidSrtpPacket) { | 773 TEST_F(DtlsTransportChannelTest, TestTransferDtlsInvalidSrtpPacket) { |
| 774 MAYBE_SKIP_TEST(HaveDtls); |
| 767 PrepareDtls(true, true, rtc::KT_DEFAULT); | 775 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 768 PrepareDtlsSrtp(true, true); | 776 PrepareDtlsSrtp(true, true); |
| 769 ASSERT_TRUE(Connect()); | 777 ASSERT_TRUE(Connect()); |
| 770 int result = client1_.SendInvalidSrtpPacket(0, 100); | 778 int result = client1_.SendInvalidSrtpPacket(0, 100); |
| 771 ASSERT_EQ(-1, result); | 779 ASSERT_EQ(-1, result); |
| 772 } | 780 } |
| 773 | 781 |
| 774 // Connect with DTLS. A does DTLS-SRTP but B does not. | 782 // Connect with DTLS. A does DTLS-SRTP but B does not. |
| 775 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpRejected) { | 783 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpRejected) { |
| 784 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 776 PrepareDtls(true, true, rtc::KT_DEFAULT); | 785 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 777 PrepareDtlsSrtp(true, false); | 786 PrepareDtlsSrtp(true, false); |
| 778 ASSERT_TRUE(Connect()); | 787 ASSERT_TRUE(Connect()); |
| 779 } | 788 } |
| 780 | 789 |
| 781 // Connect with DTLS. B does DTLS-SRTP but A does not. | 790 // Connect with DTLS. B does DTLS-SRTP but A does not. |
| 782 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpNotOffered) { | 791 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpNotOffered) { |
| 792 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 783 PrepareDtls(true, true, rtc::KT_DEFAULT); | 793 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 784 PrepareDtlsSrtp(false, true); | 794 PrepareDtlsSrtp(false, true); |
| 785 ASSERT_TRUE(Connect()); | 795 ASSERT_TRUE(Connect()); |
| 786 } | 796 } |
| 787 | 797 |
| 788 // Create two channels with DTLS, negotiate DTLS-SRTP, and transfer bypass SRTP. | 798 // Create two channels with DTLS, negotiate DTLS-SRTP, and transfer bypass SRTP. |
| 789 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpTwoChannels) { | 799 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpTwoChannels) { |
| 800 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 790 SetChannelCount(2); | 801 SetChannelCount(2); |
| 791 PrepareDtls(true, true, rtc::KT_DEFAULT); | 802 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 792 PrepareDtlsSrtp(true, true); | 803 PrepareDtlsSrtp(true, true); |
| 793 ASSERT_TRUE(Connect()); | 804 ASSERT_TRUE(Connect()); |
| 794 TestTransfer(0, 1000, 100, true); | 805 TestTransfer(0, 1000, 100, true); |
| 795 TestTransfer(1, 1000, 100, true); | 806 TestTransfer(1, 1000, 100, true); |
| 796 } | 807 } |
| 797 | 808 |
| 798 // Create a single channel with DTLS, and send normal data and SRTP data on it. | 809 // Create a single channel with DTLS, and send normal data and SRTP data on it. |
| 799 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpDemux) { | 810 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpDemux) { |
| 811 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 800 PrepareDtls(true, true, rtc::KT_DEFAULT); | 812 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 801 PrepareDtlsSrtp(true, true); | 813 PrepareDtlsSrtp(true, true); |
| 802 ASSERT_TRUE(Connect()); | 814 ASSERT_TRUE(Connect()); |
| 803 TestTransfer(0, 1000, 100, false); | 815 TestTransfer(0, 1000, 100, false); |
| 804 TestTransfer(0, 1000, 100, true); | 816 TestTransfer(0, 1000, 100, true); |
| 805 } | 817 } |
| 806 | 818 |
| 807 // Testing when the remote is passive. | 819 // Testing when the remote is passive. |
| 808 TEST_F(DtlsTransportChannelTest, TestTransferDtlsAnswererIsPassive) { | 820 TEST_F(DtlsTransportChannelTest, TestTransferDtlsAnswererIsPassive) { |
| 821 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 809 SetChannelCount(2); | 822 SetChannelCount(2); |
| 810 PrepareDtls(true, true, rtc::KT_DEFAULT); | 823 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 811 PrepareDtlsSrtp(true, true); | 824 PrepareDtlsSrtp(true, true); |
| 812 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 825 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 813 cricket::CONNECTIONROLE_PASSIVE)); | 826 cricket::CONNECTIONROLE_PASSIVE)); |
| 814 TestTransfer(0, 1000, 100, true); | 827 TestTransfer(0, 1000, 100, true); |
| 815 TestTransfer(1, 1000, 100, true); | 828 TestTransfer(1, 1000, 100, true); |
| 816 } | 829 } |
| 817 | 830 |
| 818 // Testing with the legacy DTLS client which doesn't use setup attribute. | 831 // Testing with the legacy DTLS client which doesn't use setup attribute. |
| 819 // In this case legacy is the answerer. | 832 // In this case legacy is the answerer. |
| 820 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) { | 833 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) { |
| 834 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 821 PrepareDtls(true, true, rtc::KT_DEFAULT); | 835 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 822 NegotiateWithLegacy(); | 836 NegotiateWithLegacy(); |
| 823 rtc::SSLRole channel1_role; | 837 rtc::SSLRole channel1_role; |
| 824 rtc::SSLRole channel2_role; | 838 rtc::SSLRole channel2_role; |
| 825 client1_.transport()->GetSslRole(&channel1_role); | 839 client1_.transport()->GetSslRole(&channel1_role); |
| 826 client2_.transport()->GetSslRole(&channel2_role); | 840 client2_.transport()->GetSslRole(&channel2_role); |
| 827 EXPECT_EQ(rtc::SSL_SERVER, channel1_role); | 841 EXPECT_EQ(rtc::SSL_SERVER, channel1_role); |
| 828 EXPECT_EQ(rtc::SSL_CLIENT, channel2_role); | 842 EXPECT_EQ(rtc::SSL_CLIENT, channel2_role); |
| 829 } | 843 } |
| 830 | 844 |
| 831 // Testing re offer/answer after the session is estbalished. Roles will be | 845 // Testing re offer/answer after the session is estbalished. Roles will be |
| 832 // kept same as of the previous negotiation. | 846 // kept same as of the previous negotiation. |
| 833 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) { | 847 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) { |
| 848 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 834 SetChannelCount(2); | 849 SetChannelCount(2); |
| 835 PrepareDtls(true, true, rtc::KT_DEFAULT); | 850 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 836 PrepareDtlsSrtp(true, true); | 851 PrepareDtlsSrtp(true, true); |
| 837 // Initial role for client1 is ACTPASS and client2 is ACTIVE. | 852 // Initial role for client1 is ACTPASS and client2 is ACTIVE. |
| 838 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 853 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 839 cricket::CONNECTIONROLE_ACTIVE)); | 854 cricket::CONNECTIONROLE_ACTIVE)); |
| 840 TestTransfer(0, 1000, 100, true); | 855 TestTransfer(0, 1000, 100, true); |
| 841 TestTransfer(1, 1000, 100, true); | 856 TestTransfer(1, 1000, 100, true); |
| 842 // Using input roles for the re-offer. | 857 // Using input roles for the re-offer. |
| 843 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, | 858 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, |
| 844 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); | 859 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); |
| 845 TestTransfer(0, 1000, 100, true); | 860 TestTransfer(0, 1000, 100, true); |
| 846 TestTransfer(1, 1000, 100, true); | 861 TestTransfer(1, 1000, 100, true); |
| 847 } | 862 } |
| 848 | 863 |
| 849 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromAnswerer) { | 864 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromAnswerer) { |
| 865 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 850 SetChannelCount(2); | 866 SetChannelCount(2); |
| 851 PrepareDtls(true, true, rtc::KT_DEFAULT); | 867 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 852 PrepareDtlsSrtp(true, true); | 868 PrepareDtlsSrtp(true, true); |
| 853 // Initial role for client1 is ACTPASS and client2 is ACTIVE. | 869 // Initial role for client1 is ACTPASS and client2 is ACTIVE. |
| 854 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 870 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 855 cricket::CONNECTIONROLE_ACTIVE)); | 871 cricket::CONNECTIONROLE_ACTIVE)); |
| 856 TestTransfer(0, 1000, 100, true); | 872 TestTransfer(0, 1000, 100, true); |
| 857 TestTransfer(1, 1000, 100, true); | 873 TestTransfer(1, 1000, 100, true); |
| 858 // Using input roles for the re-offer. | 874 // Using input roles for the re-offer. |
| 859 Renegotiate(&client2_, cricket::CONNECTIONROLE_PASSIVE, | 875 Renegotiate(&client2_, cricket::CONNECTIONROLE_PASSIVE, |
| 860 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); | 876 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); |
| 861 TestTransfer(0, 1000, 100, true); | 877 TestTransfer(0, 1000, 100, true); |
| 862 TestTransfer(1, 1000, 100, true); | 878 TestTransfer(1, 1000, 100, true); |
| 863 } | 879 } |
| 864 | 880 |
| 865 // Test that any change in role after the intial setup will result in failure. | 881 // Test that any change in role after the intial setup will result in failure. |
| 866 TEST_F(DtlsTransportChannelTest, TestDtlsRoleReversal) { | 882 TEST_F(DtlsTransportChannelTest, TestDtlsRoleReversal) { |
| 883 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 867 SetChannelCount(2); | 884 SetChannelCount(2); |
| 868 PrepareDtls(true, true, rtc::KT_DEFAULT); | 885 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 869 PrepareDtlsSrtp(true, true); | 886 PrepareDtlsSrtp(true, true); |
| 870 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 887 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 871 cricket::CONNECTIONROLE_PASSIVE)); | 888 cricket::CONNECTIONROLE_PASSIVE)); |
| 872 | 889 |
| 873 // Renegotiate from client2 with actpass and client1 as active. | 890 // Renegotiate from client2 with actpass and client1 as active. |
| 874 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTPASS, | 891 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTPASS, |
| 875 cricket::CONNECTIONROLE_ACTIVE, | 892 cricket::CONNECTIONROLE_ACTIVE, |
| 876 NF_REOFFER | NF_EXPECT_FAILURE); | 893 NF_REOFFER | NF_EXPECT_FAILURE); |
| 877 } | 894 } |
| 878 | 895 |
| 879 // Test that using different setup attributes which results in similar ssl | 896 // Test that using different setup attributes which results in similar ssl |
| 880 // role as the initial negotiation will result in success. | 897 // role as the initial negotiation will result in success. |
| 881 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferWithDifferentSetupAttr) { | 898 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferWithDifferentSetupAttr) { |
| 899 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 882 SetChannelCount(2); | 900 SetChannelCount(2); |
| 883 PrepareDtls(true, true, rtc::KT_DEFAULT); | 901 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 884 PrepareDtlsSrtp(true, true); | 902 PrepareDtlsSrtp(true, true); |
| 885 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 903 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 886 cricket::CONNECTIONROLE_PASSIVE)); | 904 cricket::CONNECTIONROLE_PASSIVE)); |
| 887 // Renegotiate from client2 with actpass and client1 as active. | 905 // Renegotiate from client2 with actpass and client1 as active. |
| 888 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTIVE, | 906 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTIVE, |
| 889 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); | 907 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); |
| 890 TestTransfer(0, 1000, 100, true); | 908 TestTransfer(0, 1000, 100, true); |
| 891 TestTransfer(1, 1000, 100, true); | 909 TestTransfer(1, 1000, 100, true); |
| 892 } | 910 } |
| 893 | 911 |
| 894 // Test that re-negotiation can be started before the clients become connected | 912 // Test that re-negotiation can be started before the clients become connected |
| 895 // in the first negotiation. | 913 // in the first negotiation. |
| 896 TEST_F(DtlsTransportChannelTest, TestRenegotiateBeforeConnect) { | 914 TEST_F(DtlsTransportChannelTest, TestRenegotiateBeforeConnect) { |
| 915 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 897 SetChannelCount(2); | 916 SetChannelCount(2); |
| 898 PrepareDtls(true, true, rtc::KT_DEFAULT); | 917 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 899 PrepareDtlsSrtp(true, true); | 918 PrepareDtlsSrtp(true, true); |
| 900 Negotiate(); | 919 Negotiate(); |
| 901 | 920 |
| 902 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, | 921 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, |
| 903 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); | 922 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); |
| 904 bool rv = client1_.Connect(&client2_, false); | 923 bool rv = client1_.Connect(&client2_, false); |
| 905 EXPECT_TRUE(rv); | 924 EXPECT_TRUE(rv); |
| 906 EXPECT_TRUE_SIMULATED_WAIT(client1_.all_dtls_transports_writable() && | 925 EXPECT_TRUE_SIMULATED_WAIT(client1_.all_dtls_transports_writable() && |
| 907 client2_.all_dtls_transports_writable(), | 926 client2_.all_dtls_transports_writable(), |
| 908 kTimeout, fake_clock_); | 927 kTimeout, fake_clock_); |
| 909 | 928 |
| 910 TestTransfer(0, 1000, 100, true); | 929 TestTransfer(0, 1000, 100, true); |
| 911 TestTransfer(1, 1000, 100, true); | 930 TestTransfer(1, 1000, 100, true); |
| 912 } | 931 } |
| 913 | 932 |
| 914 // Test Certificates state after negotiation but before connection. | 933 // Test Certificates state after negotiation but before connection. |
| 915 TEST_F(DtlsTransportChannelTest, TestCertificatesBeforeConnect) { | 934 TEST_F(DtlsTransportChannelTest, TestCertificatesBeforeConnect) { |
| 935 MAYBE_SKIP_TEST(HaveDtls); |
| 916 PrepareDtls(true, true, rtc::KT_DEFAULT); | 936 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 917 Negotiate(); | 937 Negotiate(); |
| 918 | 938 |
| 919 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; | 939 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; |
| 920 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; | 940 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; |
| 921 std::unique_ptr<rtc::SSLCertificate> remote_cert1; | 941 std::unique_ptr<rtc::SSLCertificate> remote_cert1; |
| 922 std::unique_ptr<rtc::SSLCertificate> remote_cert2; | 942 std::unique_ptr<rtc::SSLCertificate> remote_cert2; |
| 923 | 943 |
| 924 // After negotiation, each side has a distinct local certificate, but still no | 944 // After negotiation, each side has a distinct local certificate, but still no |
| 925 // remote certificate, because connection has not yet occurred. | 945 // remote certificate, because connection has not yet occurred. |
| 926 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); | 946 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); |
| 927 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); | 947 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); |
| 928 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), | 948 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), |
| 929 certificate2->ssl_certificate().ToPEMString()); | 949 certificate2->ssl_certificate().ToPEMString()); |
| 930 ASSERT_FALSE(client1_.GetDtlsTransport(0)->GetRemoteSSLCertificate()); | 950 ASSERT_FALSE(client1_.GetDtlsTransport(0)->GetRemoteSSLCertificate()); |
| 931 ASSERT_FALSE(client2_.GetDtlsTransport(0)->GetRemoteSSLCertificate()); | 951 ASSERT_FALSE(client2_.GetDtlsTransport(0)->GetRemoteSSLCertificate()); |
| 932 } | 952 } |
| 933 | 953 |
| 934 // Test Certificates state after connection. | 954 // Test Certificates state after connection. |
| 935 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) { | 955 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) { |
| 956 MAYBE_SKIP_TEST(HaveDtls); |
| 936 PrepareDtls(true, true, rtc::KT_DEFAULT); | 957 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 937 ASSERT_TRUE(Connect()); | 958 ASSERT_TRUE(Connect()); |
| 938 | 959 |
| 939 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; | 960 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; |
| 940 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; | 961 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; |
| 941 | 962 |
| 942 // After connection, each side has a distinct local certificate. | 963 // After connection, each side has a distinct local certificate. |
| 943 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); | 964 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); |
| 944 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); | 965 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); |
| 945 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), | 966 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 956 ASSERT_TRUE(remote_cert2); | 977 ASSERT_TRUE(remote_cert2); |
| 957 ASSERT_EQ(remote_cert2->ToPEMString(), | 978 ASSERT_EQ(remote_cert2->ToPEMString(), |
| 958 certificate1->ssl_certificate().ToPEMString()); | 979 certificate1->ssl_certificate().ToPEMString()); |
| 959 } | 980 } |
| 960 | 981 |
| 961 // Test that packets are retransmitted according to the expected schedule. | 982 // Test that packets are retransmitted according to the expected schedule. |
| 962 // Each time a timeout occurs, the retransmission timer should be doubled up to | 983 // Each time a timeout occurs, the retransmission timer should be doubled up to |
| 963 // 60 seconds. The timer defaults to 1 second, but for WebRTC we should be | 984 // 60 seconds. The timer defaults to 1 second, but for WebRTC we should be |
| 964 // initializing it to 50ms. | 985 // initializing it to 50ms. |
| 965 TEST_F(DtlsTransportChannelTest, TestRetransmissionSchedule) { | 986 TEST_F(DtlsTransportChannelTest, TestRetransmissionSchedule) { |
| 987 MAYBE_SKIP_TEST(HaveDtls); |
| 966 // We can only change the retransmission schedule with a recently-added | 988 // We can only change the retransmission schedule with a recently-added |
| 967 // BoringSSL API. Skip the test if not built with BoringSSL. | 989 // BoringSSL API. Skip the test if not built with BoringSSL. |
| 968 MAYBE_SKIP_TEST(IsBoringSsl); | 990 MAYBE_SKIP_TEST(IsBoringSsl); |
| 969 | 991 |
| 970 PrepareDtls(true, true, rtc::KT_DEFAULT); | 992 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 971 // Exchange transport descriptions. | 993 // Exchange transport descriptions. |
| 972 Negotiate(cricket::CONNECTIONROLE_ACTPASS, cricket::CONNECTIONROLE_ACTIVE); | 994 Negotiate(cricket::CONNECTIONROLE_ACTPASS, cricket::CONNECTIONROLE_ACTIVE); |
| 973 | 995 |
| 974 // Make client2_ writable, but not client1_. | 996 // Make client2_ writable, but not client1_. |
| 975 // This means client1_ will send DTLS client hellos but get no response. | 997 // This means client1_ will send DTLS client hellos but get no response. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 996 rtc::TimeDelta::FromMilliseconds(timeout_schedule_ms[i] - 1)); | 1018 rtc::TimeDelta::FromMilliseconds(timeout_schedule_ms[i] - 1)); |
| 997 EXPECT_EQ(expected_hellos, client1_.received_dtls_client_hellos()); | 1019 EXPECT_EQ(expected_hellos, client1_.received_dtls_client_hellos()); |
| 998 fake_clock_.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); | 1020 fake_clock_.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); |
| 999 EXPECT_EQ(++expected_hellos, client1_.received_dtls_client_hellos()); | 1021 EXPECT_EQ(++expected_hellos, client1_.received_dtls_client_hellos()); |
| 1000 } | 1022 } |
| 1001 } | 1023 } |
| 1002 | 1024 |
| 1003 // Test that a DTLS connection can be made even if the underlying transport | 1025 // Test that a DTLS connection can be made even if the underlying transport |
| 1004 // is connected before DTLS fingerprints/roles have been negotiated. | 1026 // is connected before DTLS fingerprints/roles have been negotiated. |
| 1005 TEST_F(DtlsTransportChannelTest, TestConnectBeforeNegotiate) { | 1027 TEST_F(DtlsTransportChannelTest, TestConnectBeforeNegotiate) { |
| 1028 MAYBE_SKIP_TEST(HaveDtls); |
| 1006 PrepareDtls(true, true, rtc::KT_DEFAULT); | 1029 PrepareDtls(true, true, rtc::KT_DEFAULT); |
| 1007 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 1030 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
| 1008 cricket::CONNECTIONROLE_ACTIVE, | 1031 cricket::CONNECTIONROLE_ACTIVE, |
| 1009 CONNECT_BEFORE_NEGOTIATE)); | 1032 CONNECT_BEFORE_NEGOTIATE)); |
| 1010 TestTransfer(0, 1000, 100, false); | 1033 TestTransfer(0, 1000, 100, false); |
| 1011 } | 1034 } |
| 1012 | 1035 |
| 1013 // The following events can occur in many different orders: | 1036 // The following events can occur in many different orders: |
| 1014 // 1. Caller receives remote fingerprint. | 1037 // 1. Caller receives remote fingerprint. |
| 1015 // 2. Caller is writable. | 1038 // 2. Caller is writable. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 EXPECT_EQ(1, client1_.received_dtls_client_hellos()); | 1151 EXPECT_EQ(1, client1_.received_dtls_client_hellos()); |
| 1129 EXPECT_EQ(1, client2_.received_dtls_server_hellos()); | 1152 EXPECT_EQ(1, client2_.received_dtls_server_hellos()); |
| 1130 | 1153 |
| 1131 if (valid_fingerprint) { | 1154 if (valid_fingerprint) { |
| 1132 TestTransfer(0, 1000, 100, false); | 1155 TestTransfer(0, 1000, 100, false); |
| 1133 } | 1156 } |
| 1134 } | 1157 } |
| 1135 }; | 1158 }; |
| 1136 | 1159 |
| 1137 TEST_P(DtlsEventOrderingTest, TestEventOrdering) { | 1160 TEST_P(DtlsEventOrderingTest, TestEventOrdering) { |
| 1161 MAYBE_SKIP_TEST(HaveDtls); |
| 1138 TestEventOrdering(::testing::get<0>(GetParam()), | 1162 TestEventOrdering(::testing::get<0>(GetParam()), |
| 1139 ::testing::get<1>(GetParam())); | 1163 ::testing::get<1>(GetParam())); |
| 1140 } | 1164 } |
| 1141 | 1165 |
| 1142 INSTANTIATE_TEST_CASE_P( | 1166 INSTANTIATE_TEST_CASE_P( |
| 1143 TestEventOrdering, | 1167 TestEventOrdering, |
| 1144 DtlsEventOrderingTest, | 1168 DtlsEventOrderingTest, |
| 1145 ::testing::Combine( | 1169 ::testing::Combine( |
| 1146 ::testing::Values( | 1170 ::testing::Values( |
| 1147 std::vector<DtlsTransportEvent>{ | 1171 std::vector<DtlsTransportEvent>{ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1162 std::vector<DtlsTransportEvent>{ | 1186 std::vector<DtlsTransportEvent>{ |
| 1163 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, | 1187 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, |
| 1164 CALLER_WRITABLE, HANDSHAKE_FINISHES}, | 1188 CALLER_WRITABLE, HANDSHAKE_FINISHES}, |
| 1165 std::vector<DtlsTransportEvent>{ | 1189 std::vector<DtlsTransportEvent>{ |
| 1166 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, | 1190 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, |
| 1167 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, | 1191 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, |
| 1168 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, | 1192 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, |
| 1169 CALLER_WRITABLE, HANDSHAKE_FINISHES, | 1193 CALLER_WRITABLE, HANDSHAKE_FINISHES, |
| 1170 CALLER_RECEIVES_FINGERPRINT}), | 1194 CALLER_RECEIVES_FINGERPRINT}), |
| 1171 ::testing::Bool())); | 1195 ::testing::Bool())); |
| OLD | NEW |