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