@@ -9,12 +9,22 @@ namespace RTSP.Tests.Authentication
99 public class AuthenticationDigestTests
1010 {
1111 // MD5, no Algorithm specified
12- string authStringPLAY_MD5_noalg = "Digest username=\" user\" , realm=\" SharpRTSPServer\" , nonce=\" 556284985\" , uri=\" rtsp://192.168.26.76:8554/\" , response=\" f3ce799d94cb45e14bf59e57cd41c749\" " ;
13- string authStringPLAY_MD5_with_alg = "Digest username=\" user\" , realm=\" SharpRTSPServer\" , nonce=\" 556284985\" , uri=\" rtsp://192.168.26.76:8554/\" , response=\" f3ce799d94cb45e14bf59e57cd41c749\" , algorithm=\" MD5\" " ;
14- string authStringPLAY_SHA256 = "Digest username=\" user\" , realm=\" SharpRTSPServer\" , nonce=\" 729461183\" , uri=\" rtsp://192.168.26.76:8554/\" , response=\" 9f6d99e827799b23b273aaf62f7eea84a720e25a205284a921f0d9aa14621dcc\" , algorithm=\" SHA-256\" " ;
15- string authStringPLAY_BadAlg = "Digest username=\" user\" , realm=\" SharpRTSPServer\" , nonce=\" 729461183\" , uri=\" rtsp://192.168.26.76:8554/\" , response=\" 9f6d99e827799b23b273aaf62f7eea84a720e25a205284a921f0d9aa14621dcc\" , algorithm=\" BADVALUE\" " ;
16- string realm = "SharpRTSPServer" ;
17- string qop = "" ;
12+ private const string authStringPLAY_MD5_noalg = """
13+ Digest username="user", realm="SharpRTSPServer", nonce="556284985", uri="rtsp://192.168.26.76:8554/", response="f3ce799d94cb45e14bf59e57cd41c749"
14+ """ ;
15+ private const string authStringPLAY_MD5_with_alg = """
16+ Digest username="user", realm="SharpRTSPServer", nonce="556284985", uri="rtsp://192.168.26.76:8554/", response="f3ce799d94cb45e14bf59e57cd41c749", algorithm="MD5"
17+ """ ;
18+ private const string authStringPLAY_SHA256 = """
19+ Digest username="user", realm="SharpRTSPServer", nonce="729461183", uri="rtsp://192.168.26.76:8554/", response="9f6d99e827799b23b273aaf62f7eea84a720e25a205284a921f0d9aa14621dcc", algorithm="SHA-256"
20+ """ ;
21+
22+ private const string authStringPLAY_BadAlg = """
23+ Digest username="user", realm="SharpRTSPServer", nonce="729461183", uri="rtsp://192.168.26.76:8554/", response="9f6d99e827799b23b273aaf62f7eea84a720e25a205284a921f0d9aa14621dcc", algorithm="BADVALUE"
24+ """ ;
25+
26+ private const string realm = "SharpRTSPServer" ;
27+ private const string qop = "" ;
1828
1929 [ Test ]
2030 public void IsValid_MD5_No_Alg_Test1 ( )
@@ -78,7 +88,7 @@ public void GetWWWAuthenticate_MD5()
7888 var testObject = new AuthenticationDigest ( new NetworkCredential ( "user" , "password" , realm ) , realm , nonce , qop , AuthenticationDigest . HashAlgorithm . MD5 ) ;
7989 var result = testObject . GetServerResponse ( ) ;
8090
81- Assert . That ( result . Contains ( "algorithm" ) , Is . False ) ; // We don't add 'algorithm=MD5' as it is not required
91+ Assert . That ( result , Does . Not . Contain ( "algorithm" ) ) ; // We don't add 'algorithm=MD5' as it is not required
8292 }
8393
8494 [ Test ]
@@ -91,7 +101,8 @@ public void GetWWWAuthenticate_SHA256()
91101 var testObject = new AuthenticationDigest ( new NetworkCredential ( "user" , "password" , realm ) , realm , nonce , qop , AuthenticationDigest . HashAlgorithm . SHA256 ) ;
92102 var result = testObject . GetServerResponse ( ) ;
93103
94- Assert . That ( result . Contains ( "algorithm" ) && result . Contains ( "SHA-256" ) , Is . True ) ;
104+ Assert . That ( result , Does . Contain ( "algorithm" ) ) ;
105+ Assert . That ( result , Does . Contain ( "SHA-256" ) ) ;
95106 }
96107
97108 }
0 commit comments