@@ -1962,10 +1962,28 @@ def test_parse_proxy(self):
19621962
19631963 self .assertRaises (ValueError , _parse_proxy , 'file:/ftp.example.com' ),
19641964
1965- def test_unsupported_algorithm (self ):
1966- handler = AbstractDigestAuthHandler ()
1965+ class TestDigestAlgorithms (unittest .TestCase ):
1966+ def setUp (self ):
1967+ self .handler = AbstractDigestAuthHandler ()
1968+
1969+ def test_md5_algorithm (self ):
1970+ H , KD = self .handler .get_algorithm_impls ('MD5' )
1971+ self .assertEqual (H ("foo" ), "acbd18db4cc2f85cedef654fccc4a4d8" )
1972+ self .assertEqual (KD ("foo" , "bar" ), "4e99e8c12de7e01535248d2bac85e732" )
1973+
1974+ def test_sha_algorithm (self ):
1975+ H , KD = self .handler .get_algorithm_impls ('SHA' )
1976+ self .assertEqual (H ("foo" ), "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" )
1977+ self .assertEqual (KD ("foo" , "bar" ), "54dcbe67d21d5eb39493d46d89ae1f412d3bd6de" )
1978+
1979+ def test_sha256_algorithm (self ):
1980+ H , KD = self .handler .get_algorithm_impls ('SHA-256' )
1981+ self .assertEqual (H ("foo" ), "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" )
1982+ self .assertEqual (KD ("foo" , "bar" ), "a765a8beaa9d561d4c5cbed29d8f4e30870297fdfa9cb7d6e9848a95fec9f937" )
1983+
1984+ def test_invalid_algorithm (self ):
19671985 with self .assertRaises (ValueError ) as exc :
1968- handler .get_algorithm_impls ('invalid' )
1986+ self . handler .get_algorithm_impls ('invalid' )
19691987 self .assertEqual (
19701988 str (exc .exception ),
19711989 "Unsupported digest authentication algorithm 'invalid'"
0 commit comments