Ejemplo n.º 1
0
    def test_perform_stored(self):
        self.rec_token.store_token("example4.com", 444)
        response = self.rec_token.perform(
            achallenges.RecoveryToken(chall=None, domain="example4.com"))

        self.assertEqual(response,
                         challenges.RecoveryTokenResponse(token="444"))
Ejemplo n.º 2
0
    def test_perform_not_stored(self, mock_input):
        mock_input().input.side_effect = [(0, "555"), (1, "000")]
        response = self.rec_token.perform(
            achallenges.RecoveryToken(chall=None, domain="example5.com"))
        self.assertEqual(response,
                         challenges.RecoveryTokenResponse(token="555"))

        response = self.rec_token.perform(
            achallenges.RecoveryToken(chall=None, domain="example6.com"))
        self.assertTrue(response is None)
Ejemplo n.º 3
0
    def perform(self, chall):
        """Perform the Recovery Token Challenge.

        :param chall: Recovery Token Challenge
        :type chall: :class:`letsencrypt.client.achallenges.RecoveryToken`

        :returns: response
        :rtype: dict

        """
        token_fp = os.path.join(self.token_dir, chall.domain)
        if os.path.isfile(token_fp):
            with open(token_fp) as token_fd:
                return challenges.RecoveryTokenResponse(token=token_fd.read())

        cancel, token = zope.component.getUtility(
            interfaces.IDisplay).input(
                "%s - Input Recovery Token: " % chall.domain)
        if cancel != 1:
            return challenges.RecoveryTokenResponse(token=token)

        return None
    def setUp(self):
        self.responses = (
            challenges.SimpleHTTPSResponse(path='Hf5GrX4Q7EBax9hc2jJnfw'),
            None,  # null
            challenges.RecoveryTokenResponse(token='23029d88d9e123e'),
        )
        self.contact = ("mailto:[email protected]", "tel:+12025551212")
        signature = other.Signature(
            alg=jose.RS256,
            jwk=jose.JWKRSA(key=KEY.publickey()),
            sig='-v\xd8\xc2\xa3\xba0\xd6\x92\x16\xb5.\xbe\xa1[\x04\xbe'
            '\x1b\xa1X\xd2)\x18\x94\x8f\xd7\xd0\xc0\xbbcI`W\xdf v'
            '\xe4\xed\xe8\x03J\xe8\xc8<?\xc8W\x94\x94cj(\xe7\xaa$'
            '\x92\xe9\x96\x11\xc2\xefx\x0bR',
            nonce='\xab?\x08o\xe6\x81$\x9f\xa1\xc9\x025\x1c\x1b\xa5+')

        from letsencrypt.acme.messages import AuthorizationRequest
        self.msg = AuthorizationRequest(
            session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9',
            responses=self.responses,
            signature=signature,
            contact=self.contact,
        )

        self.jmsg_to = {
            'type': 'authorizationRequest',
            'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ',
            'responses': self.responses,
            'signature': signature,
            'contact': self.contact,
        }
        self.jmsg_from = {
            'type':
            'authorizationRequest',
            'sessionID':
            'aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            'nonce':
            '7Nbyb1lI6xPVI3Hg3aKSqQ',
            'responses': [
                None if response is None else response.fully_serialize()
                for response in self.responses
            ],
            'signature':
            signature.fully_serialize(),
            # TODO: schema validation doesn't recognize tuples as
            # arrays :(
            'contact':
            list(self.contact),
        }