예제 #1
0
    def test_write_with_known_uuid(self):
        """
        Test that a RevokeRequestPayload object with a known UUID can be
        written to a data stream.
        """
        reason = objects.RevocationReason(
            code=enums.RevocationReasonCode.KEY_COMPROMISE)
        date = primitives.DateTime(tag=enums.Tags.COMPROMISE_OCCURRENCE_DATE,
                                   value=6)

        stream = utils.BytearrayStream()
        payload = revoke.RevokeRequestPayload(unique_identifier=self.uuid,
                                              revocation_reason=reason,
                                              compromise_date=date)
        payload.write(stream)

        length_expected = len(self.encoding_a)
        length_received = len(stream)

        msg = "encoding lengths not equal"
        msg += "; expected {0}, received {1}".format(length_expected,
                                                     length_received)
        self.assertEqual(length_expected, length_received, msg)

        msg = "encoding mismatch"
        msg += ";\nexpected:\n{0}\nreceived:\n{1}".format(
            self.encoding_a, stream)

        self.assertEqual(self.encoding_a, stream, msg)
예제 #2
0
    def test_read_with_known_uuid(self):
        """
        Test that a RevokeRequestPayload object with known UUID can be read
        from a data stream.
        """
        payload = revoke.RevokeRequestPayload()
        payload.read(self.encoding_a)
        expected = '668eff89-3010-4258-bc0e-8c402309c746'
        observed = payload.unique_identifier.value

        msg = "Revoke UUID value mismatch"
        msg += "; expected {0}, received {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)
예제 #3
0
    def _revoke(self,
                unique_identifier=None,
                revocation_code=None,
                revocation_message=None,
                credential=None):
        operation = Operation(OperationEnum.REVOKE)

        reason = objects.RevocationReason(code=revocation_code,
                                          message=revocation_message)
        uuid = None
        if unique_identifier is not None:
            uuid = attr.UniqueIdentifier(unique_identifier)

        payload = revoke.RevokeRequestPayload(
            unique_identifier=uuid,
            revocation_reason=reason,
            compromise_date=None)  # TODO(tim-kelsey): sort out date handling

        batch_item = messages.RequestBatchItem(operation=operation,
                                               request_payload=payload)
        message = self._build_request_message(credential, [batch_item])
        self._send_message(message)
        message = messages.ResponseMessage()
        data = self._receive_message()
        message.read(data)
        batch_items = message.batch_items
        batch_item = batch_items[0]
        payload = batch_item.response_payload

        if payload is None:
            payload_unique_identifier = None
        else:
            payload_unique_identifier = payload.unique_identifier

        result = RevokeResult(batch_item.result_status,
                              batch_item.result_reason,
                              batch_item.result_message,
                              payload_unique_identifier)
        return result
예제 #4
0
 def _create_revoke_payload(self):
     return revoke.RevokeRequestPayload()
예제 #5
0
 def test_init_with_args(self):
     """
     Test that a RevokeRequestPayload object can be constructed with valid
     values.
     """
     revoke.RevokeRequestPayload(unique_identifier=self.uuid)
예제 #6
0
 def test_init_with_none(self):
     """
     Test that a RevokeRequestPayload object can be constructed with no
     specified value.
     """
     revoke.RevokeRequestPayload()