~ar-python-hackers/authentication-results-python/trunk

« back to all changes in this revision

Viewing changes to authres/tests

  • Committer: Scott Kitterman
  • Date: 2013-04-04 05:17:15 UTC
  • Revision ID: scott@kitterman.com-20130404051715-wc9q5ju4a9uq3lwl
Finish fixing up authres/dmarc.py and add tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# coding: utf-8
2
2
 
3
3
# Copyright © 2011-2012 Julian Mehnle <julian@mehnle.net>,
4
 
# Copyright © 2011-2012 Scott Kitterman <scott@kitterman.com>
 
4
# Copyright © 2011-2013 Scott Kitterman <scott@kitterman.com>
5
5
#
6
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
7
# you may not use this file except in compliance with the License.
17
17
 
18
18
"""
19
19
Package for parsing ``Authentication-Results`` headers as defined in RFC 5451.
20
 
Optional support for authentication methods defined in RFCs 5617, 6008, and 6212.
 
20
Optional support for authentication methods defined in RFCs 5617, 6008, 6212,
 
21
and draft-kucherawy-dmarc-base-00.
21
22
>>> import authres
22
23
>>> str(authres.AuthenticationResultsHeader('test.example.org', version=1))
23
24
'Authentication-Results: test.example.org 1; none'
421
422
>>> str(arobj.results[1].properties[1].value)
422
423
'voucher.example.org'
423
424
 
 
425
draft-kucherawy-dmarc-base-00 example from opendnmarc
 
426
>>> import authres
 
427
>>> import authres.dmarc
 
428
>>> new_context = authres.FeatureContext(authres.dmarc)
 
429
>>> str(new_context.header(authserv_id = 'mail-router.example.net',
 
430
... results = [authres.dmarc.DMARCAuthenticationResult(result = 'pass',
 
431
... header_from = 'example.com')]))
 
432
'Authentication-Results: mail-router.example.net; dmarc=pass header.from=example.com'
 
433
 
 
434
# Missing parsing header comment.
 
435
#FIXME
 
436
>>> newarobj = new_context.parse('Authentication-Results: mail-router.example.net; dmarc=pass header.from=example.com')
 
437
>>> str(newarobj.results[0])
 
438
'dmarc=pass header.from=example.com'
 
439
>>> str(newarobj.results[0].method)
 
440
'dmarc'
 
441
>>> str(newarobj.results[0].result)
 
442
'pass'
 
443
>>> str(newarobj.results[0].header_from)
 
444
'example.com'
 
445
>>> str(newarobj.results[0].properties[0].type)
 
446
'header'
 
447
>>> str(newarobj.results[0].properties[0].name)
 
448
'from'
 
449
>>> str(newarobj.results[0].properties[0].value)
 
450
'example.com'
 
451
 
424
452
"""
425
453
 
426
454
# vim:sw=4 sts=4