Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/main/java/org/xbill/DNS/SVCBBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,6 @@ protected void rdataFromString(Tokenizer st, Name origin) throws IOException {
}
st.unget();

if (svcPriority > 0 && svcParams.isEmpty()) {
throw new TextParseException(
"At least one parameter value must be specified for ServiceMode");
}
if (svcPriority == 0 && !svcParams.isEmpty()) {
throw new TextParseException("No parameter values allowed for AliasMode");
}
Expand Down
25 changes: 13 additions & 12 deletions src/test/java/org/xbill/DNS/SVCBRecordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ void aliasMode() throws IOException {
assertEquals(str, wireToString(bytes));
}

@Test
void serviceModeWithoutParameters() throws IOException {
String str = "1 .";
byte[] bytes = stringToWire(str);
byte[] expected = new byte[] {0, 1, 0};
assertArrayEquals(expected, bytes);
assertEquals(str, wireToString(bytes));
}

@Test
void serviceModePort() throws IOException {
String str = "1 . port=8443";
Expand Down Expand Up @@ -319,6 +328,7 @@ void masterFormatParsing() throws IOException {
+ "test.net. 86400 IN NS ns1.test.net.\n"
+ "test.net. 300 IN HTTPS 0 www.test.net.\n"
+ "test.net. 300 IN SVCB 1 . alpn=h2\n"
+ "test.net. 300 IN HTTPS 1 .\n"
+ "www.test.net. 300 IN A 1.2.3.4\n";
Master m = new Master(new ByteArrayInputStream(str.getBytes()));

Expand All @@ -333,6 +343,9 @@ void masterFormatParsing() throws IOException {
assertEquals(Type.SVCB, r.getType());
assertEquals("1 . alpn=h2", r.rdataToString());
r = m.nextRecord();
assertEquals(Type.HTTPS, r.getType());
assertEquals("1 .", r.rdataToString());
r = m.nextRecord();
assertEquals(Type.A, r.getType());
assertEquals("1.2.3.4", r.rdataToString());
r = m.nextRecord();
Expand All @@ -351,12 +364,6 @@ void extraQuotesInParamValues() {
assertThrows(TextParseException.class, () -> stringToWire(str));
}

@Test
void serviceModeWithoutParameters() {
String str = "1 aliasmode.example.com.";
assertThrows(TextParseException.class, () -> stringToWire(str));
}

@Test
void aliasModeWithParameters() {
String str = "0 . alpn=h3";
Expand Down Expand Up @@ -465,12 +472,6 @@ void emptyString() {
assertThrows(TextParseException.class, () -> stringToWire(str));
}

@Test
void noParamValues() {
String str = "1 .";
assertThrows(TextParseException.class, () -> stringToWire(str));
}

@Test
void svcPriorityTooHigh() {
String str = "65536 . port=443";
Expand Down