Example #1
0
    def test_cancellation(self, server_name):
        """
        Cancelling the deferred returned by ``issue_cert`` cancels the actual
        issuing process.
        """
        with AcmeFixture() as fixture:
            fixture.service.startService()
            self.assertThat(
                fixture.cert_store.as_dict(),
                succeeded(
                    Not(Contains(server_name))))

            fixture.controller.pause()
            d1 = fixture.service.issue_cert(server_name)
            self.assertThat(d1, has_no_result())
            d2 = fixture.service.issue_cert(server_name)
            self.assertThat(d2, has_no_result())
            self.assertThat(fixture.controller.count(), Equals(1))
            d2.cancel()

            fixture.controller.resume()
            self.assertThat(d1, failed_with(IsInstance(CancelledError)))
            self.assertThat(d2, failed_with(IsInstance(CancelledError)))
            self.assertThat(
                fixture.cert_store.as_dict(),
                succeeded(
                    Not(Contains(server_name))))
Example #2
0
    def test_cancellation(self, server_name):
        """
        Cancelling the deferred returned by ``issue_cert`` cancels the actual
        issuing process.
        """
        with AcmeFixture() as fixture:
            fixture.service.startService()
            self.assertThat(
                fixture.cert_store.as_dict(),
                succeeded(
                    Not(Contains(server_name))))

            fixture.controller.pause()
            d1 = fixture.service.issue_cert(server_name)
            self.assertThat(d1, has_no_result())
            d2 = fixture.service.issue_cert(server_name)
            self.assertThat(d2, has_no_result())
            self.assertThat(fixture.controller.count(), Equals(1))
            d2.cancel()

            fixture.controller.resume()
            self.assertThat(d1, failed_with(IsInstance(CancelledError)))
            self.assertThat(d2, failed_with(IsInstance(CancelledError)))
            self.assertThat(
                fixture.cert_store.as_dict(),
                succeeded(
                    Not(Contains(server_name))))
Example #3
0
 def test_get_missing(self, server_name):
     """
     Getting a non-existent entry results in `KeyError`.
     """
     self.assertThat(
         self.cert_store.get(server_name),
         failed_with(IsInstance(KeyError)))
Example #4
0
 def test_missing_zone(self, token, subdomain, zone_name):
     """
     `.ZoneNotFound` is raised if the configured zone cannot be found at the
     configured provider.
     """
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=zone_name)
     server_name = u'{}.{}'.format(subdomain, zone_name)
     for zone in responder._driver.list_zones():
         zone.delete()
     d = maybeDeferred(responder.start_responding, server_name, challenge,
                       response)
     self._perform()
     self.assertThat(
         d,
         failed_with(
             MatchesAll(IsInstance(ZoneNotFound),
                        MatchesStructure(zone_name=Equals(zone_name)))))
Example #5
0
 def test_wrong_zone(self, token, subdomain, zone_name):
     """
     Trying to respond for a domain not in the configured zone results in a
     `.NotInZone` exception.
     """
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=zone_name)
     server_name = u'{}.{}.junk'.format(subdomain, zone_name)
     d = maybeDeferred(responder.start_responding, server_name, challenge,
                       response)
     self._perform()
     self.assertThat(
         d,
         failed_with(
             MatchesAll(
                 IsInstance(NotInZone),
                 MatchesStructure(server_name=EndsWith(u'.' + server_name),
                                  zone_name=Equals(zone_name)))))
Example #6
0
 def test_wrong_zone(self, token, subdomain, zone_name):
     """
     Trying to respond for a domain not in the configured zone results in a
     `.NotInZone` exception.
     """
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=zone_name)
     server_name = u'{}.{}.junk'.format(subdomain, zone_name)
     d = maybeDeferred(
         responder.start_responding, server_name, challenge, response)
     self._perform()
     self.assertThat(
         d,
         failed_with(MatchesAll(
             IsInstance(NotInZone),
             MatchesStructure(
                 server_name=EndsWith(u'.' + server_name),
                 zone_name=Equals(zone_name)))))
Example #7
0
 def test_missing_zone(self, token, subdomain, zone_name):
     """
     `.ZoneNotFound` is raised if the configured zone cannot be found at the
     configured provider.
     """
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=zone_name)
     server_name = u'{}.{}'.format(subdomain, zone_name)
     for zone in responder._driver.list_zones():
         zone.delete()
     d = maybeDeferred(
         responder.start_responding, server_name, challenge, response)
     self._perform()
     self.assertThat(
         d,
         failed_with(MatchesAll(
             IsInstance(ZoneNotFound),
             MatchesStructure(
                 zone_name=Equals(zone_name)))))
Example #8
0
 def test_auto_zone_missing(self, token, subdomain, zone_name1, zone_name2):
     """
     If the configured zone_name is ``None``, and no matching zone is found,
     ``NotInZone`` is raised.
     """
     server_name = u'{}.{}'.format(subdomain, zone_name1)
     assume(not server_name.endswith(zone_name2))
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=None)
     zone = responder._driver.create_zone(zone_name2)
     self.assertThat(zone.list_records(), HasLength(0))
     d = maybeDeferred(responder.start_responding, server_name, challenge,
                       response)
     self._perform()
     self.assertThat(
         d,
         failed_with(
             MatchesAll(
                 IsInstance(NotInZone),
                 MatchesStructure(server_name=EndsWith(u'.' + server_name),
                                  zone_name=Is(None)))))
Example #9
0
 def test_auto_zone_missing(self, token, subdomain, zone_name1, zone_name2):
     """
     If the configured zone_name is ``None``, and no matching zone is found,
     ``NotInZone`` is raised.
     """
     server_name = u'{}.{}'.format(subdomain, zone_name1)
     assume(not server_name.endswith(zone_name2))
     challenge = self._challenge_factory(token=token)
     response = challenge.response(RSA_KEY_512)
     responder = self._responder_factory(zone_name=None)
     zone = responder._driver.create_zone(zone_name2)
     self.assertThat(zone.list_records(), HasLength(0))
     d = maybeDeferred(
         responder.start_responding, server_name, challenge, response)
     self._perform()
     self.assertThat(
         d,
         failed_with(MatchesAll(
             IsInstance(NotInZone),
             MatchesStructure(
                 server_name=EndsWith(u'.' + server_name),
                 zone_name=Is(None)))))
Example #10
0
 def test_get_missing(self, server_name):
     """
     Getting a non-existent entry results in `KeyError`.
     """
     self.assertThat(self.cert_store.get(server_name),
                     failed_with(IsInstance(KeyError)))