public function testGetAllRecords() { // simulate the Dyn API response $this->apiClient->getHttpClient()->getAdapter()->setResponse("HTTP/1.1 200 OK" . "\r\n" . "Content-type: application/json" . "\r\n\r\n" . '{"status": "success", "data": {"cname_records": [], "cert_records": [], "dname_records": [], "aaaa_records": [], "ipseckey_records": [], "loc_records": [], "ptr_records": [], "soa_records": [{"zone": "example.com", "ttl": 3600, "fqdn": "example.com", "record_type": "SOA", "rdata": {"rname": "user@example.com.", "retry": 600, "mname": "ns1.xx.dynect.net.", "minimum": 1800, "refresh": 3600, "expire": 604800, "serial": 1}, "record_id": 123456780, "serial_style": "increment"}], "kx_records": [], "dnskey_records": [], "naptr_records": [], "rp_records": [], "mx_records": [{"zone": "example.com", "ttl": 3600, "fqdn": "example.com", "record_type": "MX", "rdata": {"preference": 10, "exchange": "mail.example.com."}, "record_id": 123456781}], "key_records": [], "px_records": [], "ds_records": [], "sshfp_records": [], "ns_records": [{"zone": "example.com", "service_class": "", "ttl": 86400, "fqdn": "example.com", "record_type": "NS", "rdata": {"nsdname": "ns1.xx.dynect.net."}, "record_id": 123456782}, {"zone": "example.com", "service_class": "", "ttl": 86400, "fqdn": "example.com", "record_type": "NS", "rdata": {"nsdname": "ns2.xx.dynect.net."}, "record_id": 123456783}, {"zone": "example.com", "service_class": "", "ttl": 86400, "fqdn": "example.com", "record_type": "NS", "rdata": {"nsdname": "ns3.xx.dynect.net."}, "record_id": 123456784}, {"zone": "example.com", "service_class": "", "ttl": 86400, "fqdn": "example.com", "record_type": "NS", "rdata": {"nsdname": "ns4.xx.dynect.net."}, "record_id": 123456785}], "dhcid_records": [], "srv_records": [], "nsap_records": [], "txt_records": [], "spf_records": [], "a_records": [{"zone": "example.com", "ttl": 3600, "fqdn": "www.example.com", "record_type": "A", "rdata": {"address": "127.0.0.1"}, "record_id": 123456786}]}, "job_id": 987654321, "msgs": [{"INFO": "get_tree: Here is your zone tree", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}'); // setup the exact data structure we expect to get back (a bit combersome) $records = array('CNAME' => array(), 'CERT' => array(), 'DNAME' => array(), 'AAAA' => array(), 'IPSECKEY' => array(), 'LOC' => array(), 'PTR' => array(), 'SOA' => array(), 'KX' => array(), 'DNSKEY' => array(), 'NAPTR' => array(), 'RP' => array(), 'MX' => array(), 'KEY' => array(), 'PX' => array(), 'DS' => array(), 'SSHFP' => array(), 'NS' => array(), 'DHCID' => array(), 'SRV' => array(), 'NSAP' => array(), 'TXT' => array(), 'SPF' => array(), 'A' => array()); $aRecord = new ARecord(); $aRecord->setFqdn('www.example.com')->setAddress('127.0.0.1')->setTtl(3600)->setId(123456786); $records['A'][] = $aRecord; $mxRecord = new MXRecord(); $mxRecord->setFqdn('example.com')->setExchange('mail.example.com.')->setPreference(10)->setTtl(3600)->setId(123456781); $records['MX'][] = $mxRecord; $ns1 = new NSRecord(); $ns1->setFqdn('example.com')->setNsDName('ns1.xx.dynect.net.')->setTtl(86400)->setId(123456782); $ns2 = clone $ns1; $ns2->setNsDName('ns2.xx.dynect.net.')->setId(123456783); $ns3 = clone $ns1; $ns3->setNsDName('ns3.xx.dynect.net.')->setId(123456784); $ns4 = clone $ns1; $ns4->setNsDName('ns4.xx.dynect.net.')->setId(123456785); $records['NS'][] = $ns1; $records['NS'][] = $ns2; $records['NS'][] = $ns3; $records['NS'][] = $ns4; $soa = new SOARecord(); $soa->setRname('user@example.com.')->setSerialStyle('increment')->setFqdn('example.com')->setTtl(3600)->setId(123456780); $records['SOA'][] = $soa; $this->assertEquals($records, $this->zone->getAllRecords()); }
<?php /** * This example creates a new zone, adds some records to it, and then publishes. */ require '../../vendor/autoload.php'; use Dyn\TrafficManagement; use Dyn\TrafficManagement\Record\A; use Dyn\TrafficManagement\Record\MX; $tm = new TrafficManagement('customerName', 'username', 'password'); // login $tm->createSession(); // create new zone $zone = $tm->createZone('example.com', '*****@*****.**', 3600); // add an A record to it $record = new A(); $record->setFqdn('www.example.com')->setAddress('127.0.0.1'); $zone->createRecord($record); // add an MX record to it $record = new MX(); $record->setFqdn('example.com')->setPreference(10)->setExchange('mail.example.com'); $zone->createRecord($record); // publish (makes the zone live) $zone->publish(); // logout $tm->deleteSession();
<?php /** * This example creates a single 'A' record and then publishes the changes */ require '../../vendor/autoload.php'; use Dyn\TrafficManagement; use Dyn\TrafficManagement\Record\A; $tm = new TrafficManagement('customerName', 'username', 'password'); // login $tm->createSession(); // retrieve zone $zone = $tm->getZone('example.com'); // configure the new record $record = new A(); $record->setAddress('127.0.0.1'); // create the new record $zone->createRecord($record, 'test.example.com'); // publish changes to the zone (makes the new record live) $zone->publish(); // logout $tm->deleteSession();
public function testAddressValidation() { $this->setExpectedException('InvalidArgumentException'); $a = new A(); $a->setAddress('0:0:0:0:0:ffff:8600:4c33'); }