01: package CustomDNS.Tests;
02:
03: import CustomDNS.UpdateClient;
04: import CustomDNS.UpdateProtocol;
05: import CustomDNS.UpdateProtocol.ServerResponse;
06:
07: public class TestWithClients extends TestVirtualDNS {
08:
09: // The port to run our test DNS servers on. This should be greater
10: // than 1024 (to prevent us from needing root privs under Unix).
11: static final short dnsPort = 5298;
12:
13: // Our standard constructor.
14: public TestWithClients(String name) {
15: super (name);
16: }
17:
18: // An overridable method which returns the DNS port we should use.
19: protected short getDNSPort() {
20: return this .dnsPort;
21: }
22:
23: // We run this test twice so we can ignore the
24: // initial database state. We do each half of the test in
25: // a separate method to default our resolver cache.
26: public void testUpdateWithClients1() throws Exception {
27: UpdateClient.updateAddress(fullPath("update1.prop"));
28: assertAddress("test2.myzone.test", "10.0.0.1");
29: }
30:
31: public void testUpdateWithClients2() throws Exception {
32: UpdateClient.updateAddress(fullPath("update2.prop"));
33: assertAddress("test2.myzone.test", "10.0.0.2");
34: }
35:
36: public void testUpdateWithExplicitAddress() throws Exception {
37: UpdateClient
38: .updateAddress(fullPath("update2.prop"), "10.0.0.3");
39: assertAddress("test2.myzone.test", "10.0.0.3");
40: }
41:
42: public void testUnknownZone() throws Exception {
43: try {
44: UpdateClient
45: .updateAddress(fullPath("update-unknown-zone.prop"));
46: fail("Server accepted bad zone");
47: } catch (ServerResponse r) {
48: assertEquals(r.getCode(),
49: UpdateProtocol.STATUS_UNKNOWN_ZONE);
50: }
51: }
52:
53: public void testUpdateNotAllowed() throws Exception {
54: try {
55: UpdateClient
56: .updateAddress(fullPath("update-not-allowed.prop"));
57: fail("Server authenticated an update it should have prevented");
58: } catch (ServerResponse r) {
59: assertEquals(r.getCode(), UpdateProtocol.STATUS_NOT_ALLOWED);
60: }
61: }
62:
63: public void testDynamicUpperCaseQuery() throws Exception {
64: assertAddress("FOO1.MYZONE.TEST", "10.0.0.1");
65: }
66: }
|