@Test public void transform_invalid() { final RpslObject rpslObject = RpslObject.parse("" + "inetnum: test.ripe.net"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.INETNUM).toString(), is("test.ripe.net")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_inet6num_no_change() { final RpslObject rpslObject = RpslObject.parse("inet6num: 2001:67c:20c4::/48"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat( result.getValueForAttribute(AttributeType.INET6NUM).toString(), is("2001:67c:20c4::/48")); verifyZeroInteractions(objectMessages); }
@Test public void transform_route_no_change() { final RpslObject rpslObject = RpslObject.parse("" + "route: 212.166.64.0/19\n" + "origin: AS12321"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.ROUTE).toString(), is("212.166.64.0/19")); verifyZeroInteractions(objectMessages); }
@Test public void transform_alias_no_dot() { final RpslObject rpslObject = RpslObject.parse( "" + "inet-rtr: test.ripe.net\n" + "alias: alias.ripe.net"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.ALIAS).toString(), is("alias.ripe.net")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_nserver_no_not() { final RpslObject rpslObject = RpslObject.parse( "" + "domain: 17.45.212.in-addr.arpa\n" + "nserver: hostname.nu\n"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.NSERVER).toString(), is("hostname.nu")); verifyZeroInteractions(objectMessages); }
@Test public void transform_domain_no_dot() { final RpslObject rpslObject = RpslObject.parse("domain: 17.45.212.in-addr.arpa"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getKey().toString(), is("17.45.212.in-addr.arpa")); assertThat( result.getValueForAttribute(AttributeType.DOMAIN).toString(), is("17.45.212.in-addr.arpa")); verifyZeroInteractions(objectMessages); }
@Test public void transform_inet6num_change() { final RpslObject rpslObject = RpslObject.parse("inet6num: 2001::/8"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.INET6NUM).toString(), is("2000::/8")); verify(objectMessages) .addMessage( result.getTypeAttribute(), ValidationMessages.attributeValueConverted("2001::/8", "2000::/8")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_route6_uppercase() { final RpslObject rpslObject = RpslObject.parse("" + "route6: 2001:6F8::/32\n" + "origin: AS12321"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.ROUTE6).toString(), is("2001:6f8::/32")); verify(objectMessages) .addMessage( result.findAttribute(AttributeType.ROUTE6), ValidationMessages.attributeValueConverted("2001:6F8::/32", "2001:6f8::/32")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_route_short_prefix() { final RpslObject rpslObject = RpslObject.parse("" + "route: 15/8\n" + "origin: AS12321"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.ROUTE).toString(), is("15.0.0.0/8")); verify(objectMessages) .addMessage( result.getTypeAttribute(), ValidationMessages.attributeValueConverted("15/8", "15.0.0.0/8")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_route_leading_zeroes() { final RpslObject rpslObject = RpslObject.parse("" + "route: 212.166.064.000/19\n" + "origin: AS12321"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.ROUTE).toString(), is("212.166.64.0/19")); verify(objectMessages) .addMessage( result.getTypeAttribute(), ValidationMessages.attributeValueConverted("212.166.064.000/19", "212.166.64.0/19")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_inetrtr_with_trailing_dot() { final RpslObject rpslObject = RpslObject.parse( "" + "inet-rtr: test.ripe.net.\n" + "alias: alias.ripe.net"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.INET_RTR).toString(), is("test.ripe.net")); verify(objectMessages) .addMessage( result.findAttribute(AttributeType.INET_RTR), ValidationMessages.attributeValueConverted("test.ripe.net.", "test.ripe.net")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_nserver_with_dot() { final RpslObject rpslObject = RpslObject.parse( "" + "domain: 17.45.212.in-addr.arpa\n" + "nserver: hostname.nu.\n"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.NSERVER).toString(), is("hostname.nu")); verify(objectMessages) .addMessage( result.findAttribute(AttributeType.NSERVER), ValidationMessages.attributeValueConverted("hostname.nu.", "hostname.nu")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_inetnum_prefix() { final RpslObject rpslObject = RpslObject.parse("inetnum: 193/8"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat( result.getValueForAttribute(AttributeType.INETNUM).toString(), is("193.0.0.0 - 193.255.255.255")); verify(objectMessages) .addMessage( result.getTypeAttribute(), ValidationMessages.attributeValueConverted("193/8", "193.0.0.0 - 193.255.255.255")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_ds_rdata_no_change() { final RpslObject rpslObject = RpslObject.parse( "" + "domain: 17.45.212.in-addr.arpa\n" + "ds-rdata: 52314 5 1 93B5837D4E5C063A3728FAA72BA64068F89B39DF"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat( result.getValueForAttribute(AttributeType.DS_RDATA).toString(), is("52314 5 1 93B5837D4E5C063A3728FAA72BA64068F89B39DF")); verifyZeroInteractions(objectMessages); }
@Test public void transform_domain_with_trailing_dot() { final RpslObject rpslObject = RpslObject.parse("domain: 17.45.212.in-addr.arpa."); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getKey().toString(), is("17.45.212.in-addr.arpa")); assertThat( result.getValueForAttribute(AttributeType.DOMAIN).toString(), is("17.45.212.in-addr.arpa")); verify(objectMessages) .addMessage( result.getTypeAttribute(), ValidationMessages.attributeValueConverted( "17.45.212.in-addr.arpa.", "17.45.212.in-addr.arpa")); verifyNoMoreInteractions(objectMessages); }
@Test public void transform_ds_rdata_remove_spaces() { final RpslObject rpslObject = RpslObject.parse( "" + "domain: 17.45.212.in-addr.arpa\n" + "ds-rdata: 52314 5 1 93B5837D4E5C063 A3728FAA72BA64 068F89B39DF"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat( result.getValueForAttribute(AttributeType.DS_RDATA).toString(), is("52314 5 1 93B5837D4E5C063A3728FAA72BA64068F89B39DF")); verify(objectMessages) .addMessage( result.findAttribute(AttributeType.DS_RDATA), ValidationMessages.attributeValueConverted( "52314 5 1 93B5837D4E5C063 A3728FAA72BA64 068F89B39DF", "52314 5 1 93B5837D4E5C063A3728FAA72BA64068F89B39DF")); verifyNoMoreInteractions(objectMessages); }