class DVSNIResponseTest(unittest.TestCase):

    def setUp(self):
        from letsencrypt.acme.challenges import DVSNIResponse
        self.msg = DVSNIResponse(
            s='\xf5\xd6\xe3\xb2]\xe0L\x0bN\x9cKJ\x14I\xa1K\xa3#\xf9\xa8'
              '\xcd\x8c7\x0e\x99\x19)\xdc\xb7\xf3\x9bw')
        self.jmsg = {
            'type': 'dvsni',
            's': '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c',
        }

    def test_z_and_domain(self):
        from letsencrypt.acme.challenges import DVSNI
        challenge = DVSNI(
            r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6"
              "\xbf'\xb3\xed\x9a9nX\x0f'\\m\xe7\x12",
            nonce=long('439736375371401115242521957580409149254868992063'
                       '44333654741504362774620418661L'))
        # pylint: disable=invalid-name
        z = '38e612b0397cc2624a07d351d7ef50e46134c0213d9ed52f7d7c611acaeed41b'
        self.assertEqual(z, self.msg.z(challenge))
        self.assertEqual(
            '{0}.acme.invalid'.format(z), self.msg.z_domain(challenge))

    def test_to_partial_json(self):
        self.assertEqual(self.jmsg, self.msg.to_partial_json())

    def test_from_json(self):
        from letsencrypt.acme.challenges import DVSNIResponse
        self.assertEqual(self.msg, DVSNIResponse.from_json(self.jmsg))

    def test_from_json_hashable(self):
        from letsencrypt.acme.challenges import DVSNIResponse
        hash(DVSNIResponse.from_json(self.jmsg))
class DVSNIResponseTest(unittest.TestCase):
    def setUp(self):
        from letsencrypt.acme.challenges import DVSNIResponse
        self.msg = DVSNIResponse(
            s='\xf5\xd6\xe3\xb2]\xe0L\x0bN\x9cKJ\x14I\xa1K\xa3#\xf9\xa8'
            '\xcd\x8c7\x0e\x99\x19)\xdc\xb7\xf3\x9bw')
        self.jmsg = {
            'type': 'dvsni',
            's': '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c',
        }

    def test_z_and_domain(self):
        from letsencrypt.acme.challenges import DVSNI
        challenge = DVSNI(
            r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6"
            "\xbf'\xb3\xed\x9a9nX\x0f'\\m\xe7\x12",
            nonce=long('439736375371401115242521957580409149254868992063'
                       '44333654741504362774620418661L'))
        # pylint: disable=invalid-name
        z = '38e612b0397cc2624a07d351d7ef50e46134c0213d9ed52f7d7c611acaeed41b'
        self.assertEqual(z, self.msg.z(challenge))
        self.assertEqual('{0}.acme.invalid'.format(z),
                         self.msg.z_domain(challenge))

    def test_to_json(self):
        self.assertEqual(self.jmsg, self.msg.to_json())

    def test_from_json(self):
        from letsencrypt.acme.challenges import DVSNIResponse
        self.assertEqual(self.msg, DVSNIResponse.from_json(self.jmsg))
 def setUp(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     self.msg = DVSNIResponse(
         s='\xf5\xd6\xe3\xb2]\xe0L\x0bN\x9cKJ\x14I\xa1K\xa3#\xf9\xa8'
         '\xcd\x8c7\x0e\x99\x19)\xdc\xb7\xf3\x9bw')
     self.jmsg = {
         'type': 'dvsni',
         's': '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c',
     }
 def setUp(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     self.msg = DVSNIResponse(
         s='\xf5\xd6\xe3\xb2]\xe0L\x0bN\x9cKJ\x14I\xa1K\xa3#\xf9\xa8'
           '\xcd\x8c7\x0e\x99\x19)\xdc\xb7\xf3\x9bw')
     self.jmsg = {
         'type': 'dvsni',
         's': '9dbjsl3gTAtOnEtKFEmhS6Mj-ajNjDcOmRkp3Lfzm3c',
     }
 def test_from_json_hashable(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     hash(DVSNIResponse.from_json(self.jmsg))
 def test_from_json(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     self.assertEqual(self.msg, DVSNIResponse.from_json(self.jmsg))
 def test_from_json(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     self.assertEqual(self.msg, DVSNIResponse.from_json(self.jmsg))
 def test_from_json_hashable(self):
     from letsencrypt.acme.challenges import DVSNIResponse
     hash(DVSNIResponse.from_json(self.jmsg))