Esempio n. 1
0
    def test_constructAuthorityFromHost(self):
        """
        L{SecondaryAuthorityService} can be constructed with a C{str} giving a
        master server address and several domains, causing the creation of a
        secondary authority for each domain and that master server address and
        the default DNS port.
        """
        primary = '192.168.1.2'
        service = SecondaryAuthorityService(primary,
                                            ['example.com', 'example.org'])
        self.assertEqual(service.primary, primary)
        self.assertEqual(service._port, 53)

        self.assertEqual(service.domains[0].primary, primary)
        self.assertEqual(service.domains[0]._port, 53)
        self.assertEqual(service.domains[0].domain, 'example.com')

        self.assertEqual(service.domains[1].primary, primary)
        self.assertEqual(service.domains[1]._port, 53)
        self.assertEqual(service.domains[1].domain, 'example.org')
    def test_constructAuthorityFromBytes(self):
        """
        L{SecondaryAuthorityService.fromServerAddressAndDomains} constructs a
        new L{SecondaryAuthorityService} from a C{bytes} giving a master server
        address and several domains, causing the creation of a secondary
        authority for each domain and that master server address and the given
        DNS port.
        """
        primary = "192.168.1.3"
        service = SecondaryAuthorityService(
            primary.encode(),
            [b"example.net", "example.edu"],  # Coerced to bytes.
        )
        self.assertEqual(service.primary, primary)

        self.assertEqual(service.domains[0].primary, primary)
        self.assertEqual(service.domains[0].domain, b"example.net")

        self.assertEqual(service.domains[1].primary, primary)
        self.assertEqual(service.domains[1].domain, b"example.edu")