def test_invalid_message(self): """Test that an invalid message kills the association.""" class DummyDUL(object): def __init__(self): self.event_queue = queue.Queue() dimse = DIMSEServiceProvider(DummyAssociation()) p_data_tf = ( # | | length b"\x04\x00\x00\x00\x00\x4E" # P-DATA-TF 78 b"\x00\x00\x00\x4a\x01" # PDV Item 70 b"\x03" # PDV: 2 -> 69 # C-ECHO-RQ # CommandGroupLen | len 4 | value 64 b"\x00\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00" # 12 # AffSOPClass | len 18 | value b"\x00\x00\x02\x00\x12\x00\x00\x00" b"\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x31\x2e" b"\x31\x00" # 26 # CommandField | len 2 | 0x0030 -> C-ECHO-RQ b"\x00\x00\x00\x01\x02\x00\x00\x00\x30\x00" # 10 # Message ID | len 6 | -> should be invalid b"\x00\x00\x10\x01\x06\x00\x00\x00\xff\xff\xff\xff\xff\xff" # 14 # CommandDSType | len 2 | no DS b"\x00\x00\x00\x08\x02\x00\x00\x00\x01\x01" # 10 ) pdata = P_DATA_TF() pdata.decode(p_data_tf) pdata = pdata.to_primitive() # Should send Evt19 due to invalid message dimse.receive_primitive(pdata) assert dimse.assoc.dul.event_queue.get() == 'Evt19'
def test_invalid_message(self, monkeypatch): """Test that an invalid message kills the association.""" monkeypatch.setattr(_config, 'ENFORCE_UID_CONFORMANCE', True) dimse = DIMSEServiceProvider(DummyAssociation()) p_data_tf = ( # | | length b"\x04\x00\x00\x00\x00\x4E" # P-DATA-TF 78 b"\x00\x00\x00\x4a\x01" # PDV Item 70 b"\x03" # PDV: 2 -> 69 # C-ECHO-RQ # CommandGroupLen | len 4 | value 64 b"\x00\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00" # 12 # AffSOPClass | len 18 | 1.2.840.00008.1.1 - invalid b"\x00\x00\x02\x00\x12\x00\x00\x00" b"\x31\x2e\x32\x2e\x38\x34\x30\x2e\x30\x30\x30\x30\x38\x2e\x31\x2e" b"\x31\x00" # 26 # CommandField | len 2 | 0x0030 -> C-ECHO-RQ b"\x00\x00\x00\x01\x02\x00\x00\x00\x30\x00" # 10 # Message ID | len 6 | value b"\x00\x00\x10\x01\x06\x00\x00\x00\xff\xff\xff\xff\xff\xff" # 14 # CommandDSType | len 2 | no DS b"\x00\x00\x00\x08\x02\x00\x00\x00\x01\x01" # 10 ) pdata = P_DATA_TF() pdata.decode(p_data_tf) pdata = pdata.to_primitive() # Should send Evt19 due to invalid message dimse.receive_primitive(pdata) assert dimse.assoc.dul.event_queue.get() == 'Evt19'
def test_invalid_message(self): class DummyDUL(object): def __init__(self): self.event_queue = queue.Queue() dimse = DIMSEServiceProvider(DummyAssociation()) p_data_tf = ( b"\x04\x00\x00\x00\x00\x48" # P-DATA-TF 74 b"\x00\x00\x00\x44\x01" # PDV Item 70 b"\x03" # PDV: 2 -> 69 b"\x00\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00" # 12 Command Group Length b"\x00\x00\x02\x00\x12\x00\x00\x00\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x31\x2e\x31\x00" # 26 b"\x00\x00\x00\x01\x02\x00\x00\x00\x30\x00" # 10 Command Field b"\x00\x00\x10\x01\x00\x00\x00\x00" # 10 Message ID b"\x00\x00\x00\x08\x02\x00\x00\x00\x01\x01" # 10 Command Data Set Type ) pdata = P_DATA_TF() pdata.decode(p_data_tf) pdata = pdata.to_primitive() dimse.receive_primitive(pdata) assert dimse.assoc.dul.event_queue.get() == 'Evt19'
def setup(self): """Set up""" self.dimse = DIMSEServiceProvider(DummyDUL(), 1)
def test_peek_item(self): """Test peek_msg with nothing on the queue.""" dimse = DIMSEServiceProvider(DummyAssociation()) primitive = C_STORE() dimse.msg_queue.put((14, primitive)) assert dimse.peek_msg() == (14, primitive)
def test_peek_empty(self): """Test peek_msg with nothing on the queue.""" dimse = DIMSEServiceProvider(DummyAssociation()) assert dimse.peek_msg() == (None, None)
def setup(self): """Set up""" self.dimse = DIMSEServiceProvider(DummyAssociation())