Skip to content

Commit 41ddd7e

Browse files
author
Adam Stoler
committed
Remove incorrect check that required at least one param to be specified for ServiceMode records
Add unit tests to verify that ServiceMode records without any params are allowed and can be properly converted between text and wire formats
1 parent 4eff203 commit 41ddd7e

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/main/java/org/xbill/DNS/SVCBBase.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,6 @@ protected void rdataFromString(Tokenizer st, Name origin) throws IOException {
789789
}
790790
st.unget();
791791

792-
if (svcPriority > 0 && svcParams.isEmpty()) {
793-
throw new TextParseException(
794-
"At least one parameter value must be specified for ServiceMode");
795-
}
796792
if (svcPriority == 0 && !svcParams.isEmpty()) {
797793
throw new TextParseException("No parameter values allowed for AliasMode");
798794
}

src/test/java/org/xbill/DNS/SVCBRecordTest.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ void aliasMode() throws IOException {
117117
assertEquals(str, wireToString(bytes));
118118
}
119119

120+
@Test
121+
void serviceModeWithoutParameters() throws IOException {
122+
String str = "1 .";
123+
byte[] bytes = stringToWire(str);
124+
byte[] expected = new byte[] {0, 1, 0};
125+
assertArrayEquals(expected, bytes);
126+
assertEquals(str, wireToString(bytes));
127+
}
128+
120129
@Test
121130
void serviceModePort() throws IOException {
122131
String str = "1 . port=8443";
@@ -319,6 +328,7 @@ void masterFormatParsing() throws IOException {
319328
+ "test.net. 86400 IN NS ns1.test.net.\n"
320329
+ "test.net. 300 IN HTTPS 0 www.test.net.\n"
321330
+ "test.net. 300 IN SVCB 1 . alpn=h2\n"
331+
+ "test.net. 300 IN HTTPS 1 .\n"
322332
+ "www.test.net. 300 IN A 1.2.3.4\n";
323333
Master m = new Master(new ByteArrayInputStream(str.getBytes()));
324334

@@ -333,6 +343,9 @@ void masterFormatParsing() throws IOException {
333343
assertEquals(Type.SVCB, r.getType());
334344
assertEquals("1 . alpn=h2", r.rdataToString());
335345
r = m.nextRecord();
346+
assertEquals(Type.HTTPS, r.getType());
347+
assertEquals("1 .", r.rdataToString());
348+
r = m.nextRecord();
336349
assertEquals(Type.A, r.getType());
337350
assertEquals("1.2.3.4", r.rdataToString());
338351
r = m.nextRecord();
@@ -351,12 +364,6 @@ void extraQuotesInParamValues() {
351364
assertThrows(TextParseException.class, () -> stringToWire(str));
352365
}
353366

354-
@Test
355-
void serviceModeWithoutParameters() {
356-
String str = "1 aliasmode.example.com.";
357-
assertThrows(TextParseException.class, () -> stringToWire(str));
358-
}
359-
360367
@Test
361368
void aliasModeWithParameters() {
362369
String str = "0 . alpn=h3";
@@ -465,12 +472,6 @@ void emptyString() {
465472
assertThrows(TextParseException.class, () -> stringToWire(str));
466473
}
467474

468-
@Test
469-
void noParamValues() {
470-
String str = "1 .";
471-
assertThrows(TextParseException.class, () -> stringToWire(str));
472-
}
473-
474475
@Test
475476
void svcPriorityTooHigh() {
476477
String str = "65536 . port=443";

0 commit comments

Comments
 (0)