##// END OF EJS Templates
test-url: remove trailing whitespace
Augie Fackler -
r12724:66e7ba85 default
parent child Browse files
Show More
@@ -1,48 +1,48 b''
1 1 #!/usr/bin/env python
2 2
3 3 def check(a, b):
4 4 if a != b:
5 5 print (a, b)
6 6
7 7 def cert(cn):
8 8 return dict(subject=((('commonName', cn),),))
9 9
10 10 from mercurial.url import _verifycert
11 11
12 # Test non-wildcard certificates
12 # Test non-wildcard certificates
13 13 check(_verifycert(cert('example.com'), 'example.com'),
14 14 None)
15 15 check(_verifycert(cert('example.com'), 'www.example.com'),
16 16 'certificate is for example.com')
17 17 check(_verifycert(cert('www.example.com'), 'example.com'),
18 18 'certificate is for www.example.com')
19 19
20 20 # Test wildcard certificates
21 21 check(_verifycert(cert('*.example.com'), 'www.example.com'),
22 22 None)
23 23 check(_verifycert(cert('*.example.com'), 'example.com'),
24 24 'certificate is for *.example.com')
25 25 check(_verifycert(cert('*.example.com'), 'w.w.example.com'),
26 26 'certificate is for *.example.com')
27 27
28 28 # Avoid some pitfalls
29 29 check(_verifycert(cert('*.foo'), 'foo'),
30 30 'certificate is for *.foo')
31 31 check(_verifycert(cert('*o'), 'foo'),
32 32 'certificate is for *o')
33 33
34 34 import time
35 35 lastyear = time.gmtime().tm_year - 1
36 36 nextyear = time.gmtime().tm_year + 1
37 37 check(_verifycert({'notAfter': 'May 9 00:00:00 %s GMT' % lastyear},
38 38 'example.com'),
39 39 'certificate expired May 9 00:00:00 %s GMT' % lastyear)
40 40 check(_verifycert({'notBefore': 'May 9 00:00:00 %s GMT' % nextyear},
41 41 'example.com'),
42 42 'certificate not valid before May 9 00:00:00 %s GMT' % nextyear)
43 43 check(_verifycert({'notAfter': 'Sep 29 15:29:48 %s GMT' % nextyear,
44 44 'subject': ()},
45 45 'example.com'),
46 46 'no commonName found in certificate')
47 47 check(_verifycert(None, 'example.com'),
48 48 'no certificate received')
General Comments 0
You need to be logged in to leave comments. Login now