| | |
| | | } |
| | | |
| | | @Test |
| | | void mapsFinishAsNormalCompletion() |
| | | { |
| | | String xml = "<bts><cmd>inquire_resp</cmd><list count=\"1\">" |
| | | + "<inquire dev=\"22-1-1-1-0\" workstatus=\"finish\"/></list></bts>"; |
| | | |
| | | RealtimeSnapshot snapshot = codec.parseSnapshots(xml, Instant.EPOCH).values().iterator().next(); |
| | | |
| | | assertEquals(DeviceWorkStatus.FINISHED, snapshot.workStatus()); |
| | | } |
| | | |
| | | @Test |
| | | void parsesHistoryPageAndHongKongDeviceTime() |
| | | { |
| | | ChannelIdentity channel = new ChannelIdentity("lab-bts", 24, 1, 1, 1); |
| | |
| | | } |
| | | |
| | | @Test |
| | | void rejectsResponsesMissingRequiredContainers() |
| | | { |
| | | BtsProtocolException discovery = assertThrows(BtsProtocolException.class, |
| | | () -> codec.parseDeviceInfo("<bts><cmd>getdevinfo_resp</cmd></bts>")); |
| | | BtsProtocolException realtime = assertThrows(BtsProtocolException.class, |
| | | () -> codec.parseSnapshots("<bts><cmd>inquire_resp</cmd></bts>", Instant.EPOCH)); |
| | | BtsProtocolException availability = assertThrows(BtsProtocolException.class, |
| | | () -> codec.parseHistoryAvailability("<bts><cmd>inquiredf_resp</cmd></bts>")); |
| | | ChannelIdentity channel = new ChannelIdentity("lab-bts", 24, 1, 1, 1); |
| | | BtsProtocolException history = assertThrows(BtsProtocolException.class, |
| | | () -> codec.parseHistory("<bts><cmd>download_resp</cmd>" |
| | | + "<download devtype=\"24\" devid=\"1\" subdevid=\"1\" chlid=\"1\" testid=\"42\"/>" |
| | | + "</bts>", channel, "42", 1)); |
| | | |
| | | assertEquals(BtsProtocolException.Reason.MISSING_FIELD, discovery.reason()); |
| | | assertEquals(BtsProtocolException.Reason.MISSING_FIELD, realtime.reason()); |
| | | assertEquals(BtsProtocolException.Reason.MISSING_FIELD, availability.reason()); |
| | | assertEquals(BtsProtocolException.Reason.MISSING_FIELD, history.reason()); |
| | | } |
| | | |
| | | @Test |
| | | void rejectsDoctypeAndExternalEntities() |
| | | { |
| | | String xml = "<!DOCTYPE bts [<!ENTITY xxe SYSTEM \"file:///etc/passwd\">]><bts><cmd>inquire_resp</cmd>&xxe;</bts>"; |