예제 #1
0
파일: TestCase.php 프로젝트: Amrit01/DNS
 /**
  * @return Zone
  */
 protected function buildTestZone()
 {
     $soa = new ResourceRecord();
     $soa->setClass('IN');
     $soa->setName('@');
     $soa->setRdata(Factory::Soa('example.com.', 'postmaster.example.com.', 2015050801, 3600, 14400, 604800, 3600, false));
     $ns1 = new ResourceRecord();
     $ns1->setClass('IN');
     $ns1->setName('@');
     $ns1->setTtl(14400);
     $ns1->setRdata(Factory::Ns('ns1.example.net.au.'));
     $ns2 = new ResourceRecord();
     $ns2->setClass('IN');
     $ns2->setName('@');
     $ns2->setTtl(14400);
     $ns2->setRdata(Factory::Ns('ns2.example.net.au.'));
     $a_record = new ResourceRecord();
     $a_record->setName('subdomain.au');
     $a_record->setRdata(Factory::A('192.168.1.2'));
     $a_record->setComment("This is a local ip.");
     $cname = new ResourceRecord();
     $cname->setName('alias');
     $cname->setRdata(Factory::Cname('subdomain.au.example.com.'));
     $aaaa = new ResourceRecord();
     $aaaa->setName('ipv6domain');
     $aaaa->setRdata(Factory::Aaaa('::1'));
     $aaaa->setComment("This is an IPv6 domain.");
     $mx1 = new ResourceRecord();
     $mx1->setName('@');
     $mx1->setRdata(Factory::Mx(10, 'mail-gw1.example.net.'));
     $mx2 = new ResourceRecord();
     $mx2->setName('@');
     $mx2->setRdata(Factory::Mx(20, 'mail-gw2.example.net.'));
     $mx3 = new ResourceRecord();
     $mx3->setName('@');
     $mx3->setRdata(Factory::Mx(30, 'mail-gw3.example.net.'));
     $txt = new ResourceRecord();
     $txt->setName('example.net.');
     $txt->setRdata(Factory::txt('v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a -all'));
     $loc = new ResourceRecord();
     $loc->setName('canberra');
     $loc->setRdata(Factory::Loc(-35.3075, 149.1244, 500, 20.12, 200.3, 300.1));
     $loc->setComment('This is Canberra');
     $dname = new ResourceRecord();
     $dname->setName('bar.example.com.');
     $dname->setClass(Classes::INTERNET);
     $dname->setRdata(Factory::Dname('foo.example.com.'));
     $hinfo = new ResourceRecord();
     $hinfo->setName('@');
     $hinfo->setClass(Classes::INTERNET);
     $hinfo->setRdata(Factory::Hinfo('2.7GHz', 'Ubuntu 12.04'));
     return new Zone('example.com.', 3600, array($soa, $ns1, $ns2, $a_record, $aaaa, $loc, $dname, $mx3, $mx1, $mx2, $cname, $txt, $hinfo));
 }
예제 #2
0
 public function testCompareResourceRecords()
 {
     $soa = new ResourceRecord();
     $soa->setClass('IN');
     $soa->setName('@');
     $soa->setRdata(Factory::Soa('example.com.', 'postmaster.example.com.', 2015050801, 3600, 14400, 604800, 3600));
     $ns1 = new ResourceRecord();
     $ns1->setClass('IN');
     $ns1->setName('@');
     $ns1->setTtl(14400);
     $ns1->setRdata(Factory::Ns('ns1.example.net.au.'));
     $ns2 = new ResourceRecord();
     $ns2->setClass('IN');
     $ns2->setName('@');
     $ns2->setTtl(14400);
     $ns2->setRdata(Factory::Ns('ns2.example.net.au.'));
     $a = new ResourceRecord();
     $a->setName('subdomain.au');
     $a->setRdata(Factory::A('192.168.1.2'));
     $a->setComment("This is a local ip.");
     $cname = new ResourceRecord();
     $cname->setName('alias');
     $cname->setRdata(Factory::Cname('subdomain.au.example.com.'));
     $aaaa = new ResourceRecord();
     $aaaa->setName('ipv6domain');
     $aaaa->setRdata(Factory::Aaaa('::1'));
     $aaaa->setComment("This is an IPv6 domain.");
     $mx1 = new ResourceRecord();
     $mx1->setName('@');
     $mx1->setRdata(Factory::Mx(10, 'mailgw01.example.net.'));
     $mx2 = new ResourceRecord();
     $mx2->setName('@');
     $mx2->setRdata(Factory::Mx(20, 'mailgw02.example.net.'));
     $txt = new ResourceRecord();
     $txt->setName('example.net.');
     $txt->setRdata(Factory::txt('v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a -all'));
     $dummy = new ResourceRecord();
     $dummy->setName('example.com.');
     $dummy->setRdata(new DummyRdata());
     $this->assertTrue(AlignedBuilder::compareResourceRecords($soa, $ns1) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($ns2, $ns1) > 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($aaaa, $cname) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $a) > 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $mx2) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $mx2) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($dummy, $txt) > 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $dummy) < 0);
 }
예제 #3
0
파일: ReverseTest.php 프로젝트: surjit/DNS
 /**
  *
  */
 public function testReverseIpv6Record()
 {
     $origin = Toolbox::reverseIpv6('2001:f83:21');
     $soa = new ResourceRecord('@', Factory::Soa('example.com.', 'post.example.com.', 2015010101, 3600, 14400, 604800, 3600), null, Classes::INTERNET);
     $ns1 = new ResourceRecord('@', Factory::Ns('ns1.example.com.'), null, Classes::INTERNET);
     $ns2 = new ResourceRecord('@', Factory::Ns('ns2.example.com.'), null, Classes::INTERNET);
     $foo8 = new ResourceRecord('8', Factory::Ptr('foo8.example.com.'), null, Classes::INTERNET);
     $foo9 = new ResourceRecord('9', Factory::Ptr('foo9.example.com.'), null, Classes::INTERNET);
     $fooa = new ResourceRecord('a', Factory::Ptr('fooa.example.com.'), null, Classes::INTERNET);
     $foob = new ResourceRecord('b', Factory::Ptr('foob.example.com.'), null, Classes::INTERNET);
     $fooc = new ResourceRecord('c', Factory::Ptr('fooc.example.com.'), null, Classes::INTERNET);
     $zone = new Zone($origin, 14400, [$soa, $ns1, $ns2, $foo8, $foo9, $fooa, $foob, $fooc]);
     $builder = new ZoneBuilder();
     $this->assertEquals($this->expectedIpv6Record, $builder->build($zone));
     $this->bindTest($zone, $builder);
 }
예제 #4
0
 public function testOutput()
 {
     $soa = Factory::Soa('example.com.', 'postmaster.example.com.', '2015042101', 3600, 14400, 604800, 3600, false);
     $expected = 'example.com. postmaster.example.com. 2015042101 3600 14400 604800 3600';
     $this->assertEquals($expected, $soa->output());
 }
예제 #5
0
 /**
  * @expectedException \Badcow\DNS\ZoneException
  * @expectedExceptionMessage There must be at least one NS record, 0 given.
  */
 public function testValidateNumberOfNs()
 {
     $zone = new Zone('example.com.', 3600);
     $soa = new ResourceRecord();
     $soa->setClass(Classes::INTERNET);
     $soa->setName('@');
     $soa->setRdata(Factory::Soa('example.com.', 'postmaster.example.com.', date('Ymd01'), 3600, 14400, 604800, 3600));
     $zone->addResourceRecord($soa);
     Validator::validate($zone);
 }