Пример #1
0
    def test_perform_not_stored(self, mock_input):
        mock_input().generic_input.side_effect = [(0, "555"), (1, "000")]
        response = self.rec_token.perform(
            challenge_util.RecTokenChall("example5.com"))
        self.assertEqual(response, {"type": "recoveryToken", "token": "555"})

        response = self.rec_token.perform(
            challenge_util.RecTokenChall("example6.com"))
        self.assertTrue(response is None)
    def test_rec_token2(self):
        token1 = challenge_util.RecTokenChall("0")
        token2 = challenge_util.RecTokenChall("1")

        self.auth.cleanup([token1, token2])

        self.assertEqual(
            self.mock_cleanup.call_args_list,
            [mock.call(token1), mock.call(token2)])
    def test_cleanup(self):
        self.rec_token.store_token("example3.com", 333)
        self.assertFalse(self.rec_token.requires_human("example3.com"))

        self.rec_token.cleanup(challenge_util.RecTokenChall("example3.com"))
        self.assertTrue(self.rec_token.requires_human("example3.com"))

        # Shouldn't throw an error
        self.rec_token.cleanup(challenge_util.RecTokenChall("example4.com"))

        # SHOULD throw an error (OSError other than nonexistent file)
        self.assertRaises(
            OSError, self.rec_token.cleanup,
            challenge_util.RecTokenChall("a" + "r" * 10000 + ".com"))
Пример #4
0
    def _construct_client_chall(self, chall, domain):  # pylint: disable=no-self-use
        """Construct Client Type Challenges.

        :param dict chall: Single challenge
        :param str domain: challenge's domain

        :returns: challenge_util named tuple Chall object
        :rtype: `collections.namedtuple`

        :raises errors.LetsEncryptClientError: If unimplemented challenge exists

        """
        if chall["type"] == "recoveryToken":
            logging.info("  Recovery Token Challenge for name: %s.", domain)
            return challenge_util.RecTokenChall(domain)

        elif chall["type"] == "recoveryContact":
            logging.info("  Recovery Contact Challenge for name: %s.", domain)
            return challenge_util.RecContactChall(
                domain,
                chall.get("activationURL", None),
                chall.get("successURL", None),
                chall.get("contact", None))

        elif chall["type"] == "proofOfPossession":
            logging.info("  Proof-of-Possession Challenge for name: "
                         "%s", domain)
            return challenge_util.PopChall(
                domain, chall["alg"], chall["nonce"], chall["hints"])

        else:
            raise errors.LetsEncryptClientError(
                "Unimplemented Client Challenge: %s" % chall["type"])
    def test_rec_token5(self):
        tokens = []
        for i in xrange(5):
            tokens.append(challenge_util.RecTokenChall(str(i)))

        responses = self.auth.perform(tokens)

        self.assertEqual(len(responses), 5)
        for i in xrange(5):
            self.assertEqual(responses[i], "RecTokenChall%d" % i)
    def test_perform_stored(self):
        self.rec_token.store_token("example4.com", 444)
        response = self.rec_token.perform(
            challenge_util.RecTokenChall("example4.com"))

        self.assertEqual(response, {"type": "recoveryToken", "token": "444"})
    def test_unexpected(self):
        token = challenge_util.RecTokenChall("0")
        unexpected = challenge_util.DvsniChall("0", "rb64", "123", "dummy_key")

        self.assertRaises(errors.LetsEncryptClientAuthError, self.auth.cleanup,
                          [token, unexpected])
 def test_rec_token1(self):
     token = challenge_util.RecTokenChall("0")
     responses = self.auth.perform([token])
     self.assertEqual(responses, ["RecTokenChall0"])