def test_read_valid(self): stream = self.encoding_full payload = payloads.MACRequestPayload() payload.read(stream) self.assertEqual(self.unique_identifier, payload.unique_identifier) self.assertEqual(self.cryptographic_parameters, payload.cryptographic_parameters) self.assertEqual(self.data, payload.data)
def test_write_valid(self): expected = self.encoding_full stream = utils.BytearrayStream() payload = payloads.MACRequestPayload(self.unique_identifier, self.cryptographic_parameters, self.data) payload.write(stream) self.assertEqual(expected, stream)
def test_read_no_data(self): """ Test that an InvalidKmipEncoding error gets raised when attempting to read a mac request encoding with no data. """ payload = payloads.MACRequestPayload() args = (self.encoding_no_data, ) self.assertRaisesRegexp(exceptions.InvalidKmipEncoding, "expected mac request data not found", payload.read, *args)
def test_init_valid(self): """ Test that the payload can be properly constructed and the attributes cab be properly set and retrieved. """ payload = payloads.MACRequestPayload(self.unique_identifier, self.cryptographic_parameters, self.data) self.assertEqual(payload.unique_identifier, self.unique_identifier) self.assertEqual(payload.cryptographic_parameters, self.cryptographic_parameters) self.assertEqual(payload.data, self.data)
def test_write_with_no_data(self): """ Test that an InvalidField error gets raised when attempting to write a mac request with no data. """ stream = utils.BytearrayStream() payload = payloads.MACRequestPayload(self.unique_identifier, self.cryptographic_parameters, None) args = (stream, ) self.assertRaisesRegexp(exceptions.InvalidField, "The mac request data is required", payload.write, *args)
def _create_mac_payload(self): return payloads.MACRequestPayload()
def test_init_with_none(self): payloads.MACRequestPayload()