| 1 |
# Copyright (C) 2014 Red Hat, Inc. |
| 2 |
# Author: Petr Spacek <[email protected]> |
| 3 |
# |
| 4 |
# Permission to use, copy, modify, and distribute this software and its |
| 5 |
# documentation for any purpose with or without fee is hereby granted, |
| 6 |
# provided that the above copyright notice and this permission notice |
| 7 |
# appear in all copies. |
| 8 |
# |
| 9 |
# THE SOFTWARE IS PROVIDED 'AS IS' AND RED HAT DISCLAIMS ALL WARRANTIES |
| 10 |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR |
| 12 |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 15 |
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 |
|
| 17 |
import unittest |
| 18 |
|
| 19 |
import dns.rrset |
| 20 |
import dns.rdtypes.ANY.DNSKEY |
| 21 |
|
| 22 |
from typing import Set # pylint: disable=unused-import |
| 23 |
|
| 24 |
|
| 25 |
class RdtypeAnyDnskeyTestCase(unittest.TestCase): |
| 26 |
def testFlagsAll(self): # type: () -> None |
| 27 |
"""Test that all defined flags are recognized.""" |
| 28 |
good_s = {"SEP", "REVOKE", "ZONE"} |
| 29 |
good_f = 0x181 |
| 30 |
self.assertEqual( |
| 31 |
dns.rdtypes.ANY.DNSKEY.SEP |
| 32 |
| dns.rdtypes.ANY.DNSKEY.REVOKE |
| 33 |
| dns.rdtypes.ANY.DNSKEY.ZONE, |
| 34 |
good_f, |
| 35 |
) |
| 36 |
|
| 37 |
def testFlagsRRToText(self): # type: () -> None |
| 38 |
"""Test that RR method returns correct flags.""" |
| 39 |
rr = dns.rrset.from_text("foo", 300, "IN", "DNSKEY", "257 3 8 KEY=")[0] |
| 40 |
self.assertEqual( |
| 41 |
dns.rdtypes.ANY.DNSKEY.ZONE | dns.rdtypes.ANY.DNSKEY.SEP, rr.flags |
| 42 |
) |
| 43 |
|
| 44 |
|
| 45 |
if __name__ == "__main__": |
| 46 |
unittest.main() |