예제 #1
0
 def test_resolved_combinations(self):
     self.assertEqual(
         self.msg.resolved_combinations,
         ((challenges.SimpleHTTP(token='IlirfxKKXAsHtmzK29Pj8A'),
           challenges.RecoveryToken()), (
               challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'),
               challenges.RecoveryToken(),
           )))
예제 #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(challb=challenges.RecoveryToken(),
                                      domain="example5.com"))
        self.assertEqual(response,
                         challenges.RecoveryTokenResponse(token="555"))

        response = self.rec_token.perform(
            achallenges.RecoveryToken(challb=challenges.RecoveryToken(),
                                      domain="example6.com"))
        self.assertTrue(response is None)
예제 #3
0
    def setUp(self):
        challs = (
            challenges.SimpleHTTP(token='IlirfxKKXAsHtmzK29Pj8A'),
            challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA'),
            challenges.RecoveryToken(),
        )
        combinations = ((0, 2), (1, 2))

        from acme.messages import Challenge
        self.msg = Challenge(
            session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9',
            challenges=challs,
            combinations=combinations)

        self.jmsg_to = {
            'type': 'challenge',
            'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ',
            'challenges': challs,
            'combinations': combinations,
        }

        self.jmsg_from = {
            'type': 'challenge',
            'sessionID': 'aefoGaavieG9Wihuk2aufai3aeZ5EeW4',
            'nonce': '7Nbyb1lI6xPVI3Hg3aKSqQ',
            'challenges': [chall.to_json() for chall in challs],
            'combinations': [[0, 2], [1, 2]],  # TODO array tuples
        }
    def setUp(self):
        from acme.messages2 import ChallengeBody
        from acme.messages2 import STATUS_VALID
        self.challbs = (
            ChallengeBody(
                uri='http://challb1',
                status=STATUS_VALID,
                chall=challenges.SimpleHTTP(token='IlirfxKKXAsHtmzK29Pj8A')),
            ChallengeBody(
                uri='http://challb2',
                status=STATUS_VALID,
                chall=challenges.DNS(token='DGyRejmCefe7v4NfDGDKfA')),
            ChallengeBody(uri='http://challb3',
                          status=STATUS_VALID,
                          chall=challenges.RecoveryToken()),
        )
        combinations = ((0, 2), (1, 2))

        from acme.messages2 import Authorization
        from acme.messages2 import Identifier
        from acme.messages2 import IDENTIFIER_FQDN
        identifier = Identifier(typ=IDENTIFIER_FQDN, value='example.com')
        self.authz = Authorization(identifier=identifier,
                                   combinations=combinations,
                                   challenges=self.challbs)

        self.jobj_from = {
            'identifier': identifier.to_json(),
            'challenges': [challb.to_json() for challb in self.challbs],
            'combinations': combinations,
        }
예제 #5
0
    def test_perform_stored(self):
        self.rec_token.store_token("example4.com", 444)
        response = self.rec_token.perform(
            achallenges.RecoveryToken(challb=challenges.RecoveryToken(),
                                      domain="example4.com"))

        self.assertEqual(response,
                         challenges.RecoveryTokenResponse(token="444"))
예제 #6
0
    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(
            achallenges.RecoveryToken(challb=challenges.RecoveryToken(),
                                      domain="example3.com"))
        self.assertTrue(self.rec_token.requires_human("example3.com"))

        # Shouldn't throw an error
        self.rec_token.cleanup(
            achallenges.RecoveryToken(challb=None, domain="example4.com"))

        # SHOULD throw an error (OSError other than nonexistent file)
        self.assertRaises(
            OSError, self.rec_token.cleanup,
            achallenges.RecoveryToken(challb=None,
                                      domain=("a" + "r" * 10000 + ".com")))
예제 #7
0
        pkg_resources.resource_string(
            "acme.jose", os.path.join("testdata", "rsa512_key.pem"))))

# Challenges
SIMPLE_HTTP = challenges.SimpleHTTP(
    token="evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA")
DVSNI = challenges.DVSNI(
    r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6\xbf'\xb3"
    "\xed\x9a9nX\x0f'\\m\xe7\x12",
    nonce="a82d5ff8ef740d12881f6d3c2277ab2e")
DNS = challenges.DNS(token="17817c66b60ce2e4012dfad92657527a")
RECOVERY_CONTACT = challenges.RecoveryContact(
    activation_url="https://example.ca/sendrecovery/a5bd99383fb0",
    success_url="https://example.ca/confirmrecovery/bb1b9928932",
    contact="c********[email protected]")
RECOVERY_TOKEN = challenges.RecoveryToken()
POP = challenges.ProofOfPossession(
    alg="RS256",
    nonce="xD\xf9\xb9\xdbU\xed\xaa\x17\xf1y|\x81\x88\x99 ",
    hints=challenges.ProofOfPossession.Hints(
        jwk=jose.JWKRSA(key=KEY.publickey()),
        cert_fingerprints=("93416768eb85e33adc4277f4c9acd63e7418fcfe",
                           "16d95b7b63f1972b980b14c20291f3c0d1855d95",
                           "48b46570d9fc6358108af43ad1649484def0debf"),
        certs=(),  # TODO
        subject_key_identifiers=("d0083162dcc4c8a23ecb8aecbd86120e56fd24e5"),
        serial_numbers=(34234239832, 23993939911, 17),
        issuers=(
            "C=US, O=SuperT LLC, CN=SuperTrustworthy Public CA",
            "O=LessTrustworthy CA Inc, CN=LessTrustworthy But StillSecure",
        ),