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

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698