-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbfc0d2
commit 25fc5e0
Showing
7 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.xbill.DNS; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class MasterTest { | ||
|
||
@Test | ||
void nextRecord() throws IOException { | ||
Name exampleComName = Name.fromConstantString("example.com."); | ||
try (Master master = new Master(MasterTest.class.getResourceAsStream("/zonefileEx1"))) { | ||
master.expandGenerate(false); | ||
Record rr = master.nextRecord(); | ||
assertEquals(Type.SOA, rr.getType()); | ||
rr = master.nextRecord(); | ||
assertEquals(Type.NS, rr.getType()); | ||
rr = master.nextRecord(); | ||
assertEquals(Type.MX, rr.getType()); | ||
|
||
rr = master.nextRecord(); | ||
// test special '@' resolves name correctly | ||
assertEquals(exampleComName, rr.getName()); | ||
|
||
rr = master.nextRecord(); | ||
// test relative host become absolute | ||
assertEquals(Name.fromConstantString("mail3.example.com."), rr.getAdditionalName()); | ||
|
||
rr = master.nextRecord(); | ||
assertEquals(Type.A, rr.getType()); | ||
|
||
rr = master.nextRecord(); | ||
assertEquals(Type.AAAA, rr.getType()); | ||
|
||
rr = master.nextRecord(); | ||
assertEquals(Type.CNAME, rr.getType()); | ||
|
||
rr = master.nextRecord(); | ||
assertNull(rr); | ||
// $GENERATE directive is last in zonefile | ||
assertTrue(master.generators().hasNext()); | ||
} | ||
} | ||
|
||
@Test | ||
void invalidGenRange() { | ||
try (Master master = new Master(MasterTest.class.getResourceAsStream("/zonefileInvalidGenRange"))) { | ||
assertThrows(TextParseException.class, master::nextRecord); | ||
} | ||
} | ||
|
||
@Test | ||
void invalidGenType() { | ||
try (Master master = new Master(MasterTest.class.getResourceAsStream("/zonefileInvalidGenType"))) { | ||
assertThrows(TextParseException.class, master::nextRecord); | ||
} | ||
} | ||
|
||
@Test | ||
void invalidTSIG() { | ||
try (Master master = new Master(MasterTest.class.getResourceAsStream("/zonefileInvalidTSIG"))) { | ||
assertThrows(TextParseException.class, master::nextRecord); | ||
} | ||
} | ||
|
||
@Test | ||
void invalidOriginNotAbsolute() { | ||
assertThrows(RelativeNameException.class, () -> | ||
new Master((InputStream) null, Name.fromConstantString("notabsolute"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$ORIGIN example.com. ; designates the start of this zone file in the namespace | ||
$TTL 1h ; default expiration time of all resource records without their own TTL value | ||
example.com. IN SOA ns.example.com. username.example.com. ( 2007120710 1d 2h 4w 1h ) | ||
example.com. IN NS ns ; ns.example.com is a nameserver for example.com | ||
example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com | ||
@ IN MX 20 mail2.example.com. ; equivalent to above line, "@" represents zone origin | ||
@ IN MX 50 mail3 ; equivalent to above line, but using a relative host name | ||
example.com. IN A 192.0.2.1 ; IPv4 address for example.com | ||
IN AAAA 2001:db8:10::1 ; IPv6 address for example.com | ||
www IN CNAME example.com. ; www.example.com is an alias for example.com | ||
$GENERATE 1-3/1 $.0.168.192.in-addr.arpa. PTR host-$.dsl.example.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$GENERATE 3-1 $.0.168.192.in-addr.arpa. PTR host-$.dsl.example.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$TTL 1h | ||
$GENERATE 1-3 example.com. MX 10 mail.example.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
monitor.reg.neustar.com. 0 ANY TSIG hmac-md5.sig-alg.reg.int. 1553302104 300 16 YWDHVhM3MpeTglOvyaj5fA== 27955 NOERROR 0 |