Exemplo n.º 1
0
    def setUp(self):
        from certbot.auth_handler import challb_to_achall
        from certbot.auth_handler import AuthHandler

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

        self.doms = ["0", "1", "2"]
        self.handler.authzr[self.doms[0]] = acme_util.gen_authzr(
            messages.STATUS_PENDING, self.doms[0],
            [acme_util.HTTP01, acme_util.TLSSNI01],
            [messages.STATUS_PENDING] * 2, False)

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

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

        self.chall_update = {}
        for dom in self.doms:
            self.chall_update[dom] = [
                challb_to_achall(challb, mock.Mock(key="dummy_key"), dom)
                for challb in self.handler.authzr[dom].body.challenges
            ]
Exemplo n.º 2
0
    def setUp(self):
        from certbot.auth_handler import challb_to_achall
        from certbot.auth_handler import AuthHandler, AnnotatedAuthzr

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

        self.doms = ["0", "1", "2"]
        self.aauthzrs = [
            AnnotatedAuthzr(
                acme_util.gen_authzr(messages.STATUS_PENDING, self.doms[0],
                                     [acme_util.HTTP01, acme_util.TLSSNI01],
                                     [messages.STATUS_PENDING] * 2, False),
                []),
            AnnotatedAuthzr(
                acme_util.gen_authzr(messages.STATUS_PENDING, self.doms[1],
                                     acme_util.CHALLENGES,
                                     [messages.STATUS_PENDING] * 3, False),
                []),
            AnnotatedAuthzr(
                acme_util.gen_authzr(messages.STATUS_PENDING, self.doms[2],
                                     acme_util.CHALLENGES,
                                     [messages.STATUS_PENDING] * 3, False), [])
        ]

        self.chall_update = {
        }  # type: Dict[int, achallenges.KeyAuthorizationAnnotatedChallenge]
        for i, aauthzr in enumerate(self.aauthzrs):
            self.chall_update[i] = [
                challb_to_achall(challb, mock.Mock(key="dummy_key"),
                                 self.doms[i])
                for challb in aauthzr.authzr.body.challenges
            ]
Exemplo n.º 3
0
    def setUp(self):
        from certbot.auth_handler import challb_to_achall
        from certbot.auth_handler import AuthHandler

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

        self.doms = ["0", "1", "2"]
        self.handler.authzr[self.doms[0]] = acme_util.gen_authzr(
            messages.STATUS_PENDING, self.doms[0],
            [acme_util.HTTP01, acme_util.TLSSNI01],
            [messages.STATUS_PENDING] * 2, False)

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

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

        self.chall_update = {}
        for dom in self.doms:
            self.chall_update[dom] = [
                challb_to_achall(challb, mock.Mock(key="dummy_key"), dom)
                for challb in self.handler.authzr[dom].body.challenges]
Exemplo n.º 4
0
 def test_unable_to_find_challenge_status(self, unused_mock_time):
     from certbot.auth_handler import challb_to_achall
     self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid
     self.chall_update[self.doms[0]].append(
         challb_to_achall(acme_util.DNS01_P, "key", self.doms[0]))
     self.assertRaises(errors.AuthorizationError,
                       self.handler._poll_challenges, self.chall_update,
                       False)
Exemplo n.º 5
0
 def test_unable_to_find_challenge_status(self, unused_mock_time):
     from certbot.auth_handler import challb_to_achall
     self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid
     self.chall_update[self.doms[0]].append(
         challb_to_achall(acme_util.DNS01_P, "key", self.doms[0]))
     self.assertRaises(
         errors.AuthorizationError, self.handler._poll_challenges,
         self.chall_update, False)
Exemplo n.º 6
0
 def _call(self, challb):
     from certbot.auth_handler import challb_to_achall
     return challb_to_achall(challb, "account_key", "domain")
Exemplo n.º 7
0
    if status == messages.STATUS_VALID:
        kwargs.update({"validated": datetime.datetime.now()})

    return messages.ChallengeBody(**kwargs)  # pylint: disable=star-args


# Pending ChallengeBody objects
TLSSNI01_P = chall_to_challb(TLSSNI01, messages.STATUS_PENDING)
HTTP01_P = chall_to_challb(HTTP01, messages.STATUS_PENDING)
DNS01_P = chall_to_challb(DNS01, messages.STATUS_PENDING)
DNS01_P_2 = chall_to_challb(DNS01_2, messages.STATUS_PENDING)

CHALLENGES_P = [HTTP01_P, TLSSNI01_P, DNS01_P]

# AnnotatedChallenge objects
HTTP01_A = auth_handler.challb_to_achall(HTTP01_P, JWK, "example.com")
TLSSNI01_A = auth_handler.challb_to_achall(TLSSNI01_P, JWK, "example.net")
DNS01_A = auth_handler.challb_to_achall(DNS01_P, JWK, "example.org")
DNS01_A_2 = auth_handler.challb_to_achall(DNS01_P_2, JWK,
                                          "esimerkki.example.org")

ACHALLENGES = [HTTP01_A, TLSSNI01_A, DNS01_A]


def gen_authzr(authz_status, domain, challs, statuses, combos=True):
    """Generate an authorization resource.

    :param authz_status: Status object
    :type authz_status: :class:`acme.messages.Status`
    :param list challs: Challenge objects
    :param list statuses: status of each challenge object
Exemplo n.º 8
0
    if status == messages.STATUS_VALID:
        kwargs.update({"validated": datetime.datetime.now()})

    return messages.ChallengeBody(**kwargs)  # pylint: disable=star-args


# Pending ChallengeBody objects
TLSSNI01_P = chall_to_challb(TLSSNI01, messages.STATUS_PENDING)
HTTP01_P = chall_to_challb(HTTP01, messages.STATUS_PENDING)
DNS01_P = chall_to_challb(DNS01, messages.STATUS_PENDING)

CHALLENGES_P = [HTTP01_P, TLSSNI01_P, DNS01_P]


# AnnotatedChallenge objects
HTTP01_A = auth_handler.challb_to_achall(HTTP01_P, JWK, "example.com")
TLSSNI01_A = auth_handler.challb_to_achall(TLSSNI01_P, JWK, "example.net")
DNS01_A = auth_handler.challb_to_achall(DNS01_P, JWK, "example.org")

ACHALLENGES = [HTTP01_A, TLSSNI01_A, DNS01_A]


def gen_authzr(authz_status, domain, challs, statuses, combos=True):
    """Generate an authorization resource.

    :param authz_status: Status object
    :type authz_status: :class:`acme.messages.Status`
    :param list challs: Challenge objects
    :param list statuses: status of each challenge object
    :param bool combos: Whether or not to add combinations