def setUp(self):
        from letsencrypt.client.auth_handler import challb_to_achall
        from letsencrypt.client.auth_handler import AuthHandler

        # Account and network are mocked...
        self.mock_net = mock.MagicMock()
        self.handler = AuthHandler(None, None, self.mock_net,
                                   mock.Mock(key="mock_key"))

        self.doms = ["0", "1", "2"]
        self.handler.authzr[self.doms[0]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[0], acme_util.DV_CHALLENGES,
            [messages2.STATUS_PENDING] * 3, False)

        self.handler.authzr[self.doms[1]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[1], acme_util.DV_CHALLENGES,
            [messages2.STATUS_PENDING] * 3, False)

        self.handler.authzr[self.doms[2]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[2], acme_util.DV_CHALLENGES,
            [messages2.STATUS_PENDING] * 3, False)

        self.chall_update = {}
        for dom in self.doms:
            self.chall_update[dom] = [
                challb_to_achall(challb, "dummy_key", dom)
                for challb in self.handler.authzr[dom].body.challenges
            ]
    def setUp(self):
        from letsencrypt.client.auth_handler import challb_to_achall
        from letsencrypt.client.auth_handler import AuthHandler

        # Account and network are mocked...
        self.mock_net = mock.MagicMock()
        self.handler = AuthHandler(
            None, None, self.mock_net, mock.Mock(key="mock_key"))

        self.doms = ["0", "1", "2"]
        self.handler.authzr[self.doms[0]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[0],
            acme_util.DV_CHALLENGES, [messages2.STATUS_PENDING]*3, False)

        self.handler.authzr[self.doms[1]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[1],
            acme_util.DV_CHALLENGES, [messages2.STATUS_PENDING]*3, False)

        self.handler.authzr[self.doms[2]] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.doms[2],
            acme_util.DV_CHALLENGES, [messages2.STATUS_PENDING]*3, False)

        self.chall_update = {}
        for dom in self.doms:
            self.chall_update[dom] = [
                challb_to_achall(challb, "dummy_key", dom)
                for challb in self.handler.authzr[dom].body.challenges]
    def test_unrecognized(self):
        self.handler.authzr["failure.com"] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, "failure.com",
            [mock.Mock(chall="chall", typ="unrecognized")],
            [messages2.STATUS_PENDING])

        self.assertRaises(errors.LetsEncryptClientError,
                          self.handler._challenge_factory, "failure.com", [0])
    def test_unrecognized(self):
        self.handler.authzr["failure.com"] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, "failure.com",
            [mock.Mock(chall="chall", typ="unrecognized")],
            [messages2.STATUS_PENDING])

        self.assertRaises(errors.LetsEncryptClientError,
                          self.handler._challenge_factory, "failure.com", [0])
 def _validate_all(self, unused_1, unused_2):
     for dom in self.handler.authzr.keys():
         azr = self.handler.authzr[dom]
         self.handler.authzr[dom] = acme_util.gen_authzr(
             messages2.STATUS_VALID, dom,
             [challb.chall for challb in azr.body.challenges],
             [messages2.STATUS_VALID] * len(azr.body.challenges),
             azr.body.combinations)
 def _validate_all(self, unused_1, unused_2):
     for dom in self.handler.authzr.keys():
         azr = self.handler.authzr[dom]
         self.handler.authzr[dom] = acme_util.gen_authzr(
             messages2.STATUS_VALID,
             dom,
             [challb.chall for challb in azr.body.challenges],
             [messages2.STATUS_VALID]*len(azr.body.challenges),
             azr.body.combinations)
    def setUp(self):
        from letsencrypt.client.auth_handler import AuthHandler

        # Account is mocked...
        self.handler = AuthHandler(None, None, None, mock.Mock(key="mock_key"))

        self.dom = "test"
        self.handler.authzr[self.dom] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.dom, acme_util.CHALLENGES,
            [messages2.STATUS_PENDING] * 6, False)
    def setUp(self):
        from letsencrypt.client.auth_handler import AuthHandler

        # Account is mocked...
        self.handler = AuthHandler(
            None, None, None, mock.Mock(key="mock_key"))

        self.dom = "test"
        self.handler.authzr[self.dom] = acme_util.gen_authzr(
            messages2.STATUS_PENDING, self.dom, acme_util.CHALLENGES,
            [messages2.STATUS_PENDING]*6, False)
def gen_dom_authzr(domain, unused_new_authzr_uri, challs):
    """Generates new authzr for domains."""
    return acme_util.gen_authzr(
        messages2.STATUS_PENDING, domain, challs,
        [messages2.STATUS_PENDING]*len(challs))
def gen_dom_authzr(domain, unused_new_authzr_uri, challs):
    """Generates new authzr for domains."""
    return acme_util.gen_authzr(messages2.STATUS_PENDING, domain, challs,
                                [messages2.STATUS_PENDING] * len(challs))