1#!/usr/bin/perl -w 2 3use Net::DRI; 4use Net::DRI::Data::Raw; 5use Net::DRI::Protocol::EPP::Connection; 6use DateTime; 7use DateTime::Duration; 8 9use Encode (); 10use Test::More tests => 110; 11eval { no warnings; require Test::LongString; Test::LongString->import(max => 100); $Test::LongString::Context=50; }; 12*{'main::is_string'}=\&main::is if $@; 13 14our $E1='<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">'; 15our $E2='</epp>'; 16our $TRID='<trID><clTRID>ABC-12345</clTRID><svTRID>54322-XYZ</svTRID></trID>'; 17 18our $R1; 19sub mysend 20{ 21 my ($transport,$count,$msg)=@_; 22 $R1=substr(Net::DRI::Protocol::EPP::Connection->write_message(undef,$msg),4); 23 return 1; 24} 25 26our $R2; 27sub myrecv 28{ 29 return Net::DRI::Data::Raw->new_from_string($R2? $R2 : $E1.'<response>'.r().$TRID.'</response>'.$E2); 30} 31 32my $dri=Net::DRI->new(10); 33$dri->{trid_factory}=sub { return 'ABC-12345'; }; 34$dri->add_registry('CAT'); 35$dri->target('CAT')->add_current_profile('p1','test=epp',{f_send=>\&mysend,f_recv=>\&myrecv}); 36 37my ($rc,$s,$d,$dh,@c,$co); 38 39#################################################################################################### 40## Contacts 41 42## p.31 43 44$co=$dri->local_object('contact')->srid('sh8013'); 45$co->name('John Doe'); 46$co->org('Example Inc.'); 47$co->street(['123 Example Dr.','Suite 100']); 48$co->city('Dulles'); 49$co->sp('VA'); 50$co->pc('20166-6503'); 51$co->cc('US'); 52$co->voice('+1.7035555555x1234'); 53$co->fax('+1.7035555556'); 54$co->email('jdoe@example.com'); 55$co->auth({pw=>'2fooBAR'}); 56$co->disclose({voice=>0,email=>0}); 57$co->lang('ca'); 58$co->maintainer('MyDomains.cat'); 59$co->email_sponsor('catsponsor@example.com'); 60$rc=$dri->contact_create($co); 61is($R1,$E1.'<command><create><contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd"><contact:id>sh8013</contact:id><contact:postalInfo type="loc"><contact:name>John Doe</contact:name><contact:org>Example Inc.</contact:org><contact:addr><contact:street>123 Example Dr.</contact:street><contact:street>Suite 100</contact:street><contact:city>Dulles</contact:city><contact:sp>VA</contact:sp><contact:pc>20166-6503</contact:pc><contact:cc>US</contact:cc></contact:addr></contact:postalInfo><contact:voice x="1234">+1.7035555555</contact:voice><contact:fax>+1.7035555556</contact:fax><contact:email>jdoe@example.com</contact:email><contact:authInfo><contact:pw>2fooBAR</contact:pw></contact:authInfo><contact:disclose flag="0"><contact:voice/><contact:email/></contact:disclose></contact:create></create><extension><cx:create xmlns:cx="http://xmlns.domini.cat/epp/contact-ext-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/contact-ext-1.0 puntcat-contact-ext-1.0.xsd"><cx:language>ca</cx:language><cx:maintainer>MyDomains.cat</cx:maintainer><cx:sponsorEmail>catsponsor@example.com</cx:sponsorEmail></cx:create></extension><clTRID>ABC-12345</clTRID></command>'.$E2,'contact_create build'); 62 63##p.33 64$R2=''; 65$co=$dri->local_object('contact')->srid('sh8013')->auth({pw=>'2fooBAR'}); 66$toc=$dri->local_object('changes'); 67$toc->add('status',$dri->local_object('status')->no('delete')); 68my $co2=$dri->local_object('contact'); 69$co2->org(''); 70$co2->street(['124 Example Dr.','Suite 200']); 71$co2->city('Dulles'); 72$co2->sp('VA'); 73$co2->pc('20166-6503'); 74$co2->cc('US'); 75$co2->voice('+1.7034444444'); 76$co2->fax(''); 77$co2->auth({pw=>'2fooBAR'}); 78$co2->disclose({voice=>1,email=>1}); 79$co2->lang('ca'); 80$co2->maintainer('MyDomains.cat'); 81$co2->email_sponsor('catsponsor@example.com'); 82$toc->set('info',$co2); 83$rc=$dri->contact_update($co,$toc); 84 85is_string($R1,$E1.'<command><update><contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd"><contact:id>sh8013</contact:id><contact:add><contact:status s="clientDeleteProhibited"/></contact:add><contact:chg><contact:postalInfo type="loc"><contact:org/><contact:addr><contact:street>124 Example Dr.</contact:street><contact:street>Suite 200</contact:street><contact:city>Dulles</contact:city><contact:sp>VA</contact:sp><contact:pc>20166-6503</contact:pc><contact:cc>US</contact:cc></contact:addr></contact:postalInfo><contact:voice>+1.7034444444</contact:voice><contact:fax/><contact:authInfo><contact:pw>2fooBAR</contact:pw></contact:authInfo><contact:disclose flag="1"><contact:voice/><contact:email/></contact:disclose></contact:chg></contact:update></update><extension><cx:update xmlns:cx="http://xmlns.domini.cat/epp/contact-ext-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/contact-ext-1.0 puntcat-contact-ext-1.0.xsd"><cx:chg><cx:language>ca</cx:language><cx:maintainer>MyDomains.cat</cx:maintainer><cx:sponsorEmail>catsponsor@example.com</cx:sponsorEmail></cx:chg></cx:update></extension><clTRID>ABC-12345</clTRID></command>'.$E2,'contact_update build'); 86 87##p.35 88 89$R2=$E1.'<response>'.r().'<resData><contact:infData xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"><contact:id>sh8013</contact:id><contact:roid>SH8013-REP</contact:roid><contact:status s="linked"/><contact:status s="clientDeleteProhibited"/><contact:postalInfo type="loc"><contact:name>John Doe</contact:name><contact:org>Example Inc.</contact:org><contact:addr><contact:street>123 Example Dr.</contact:street><contact:street>Suite 100</contact:street><contact:city>Dulles</contact:city><contact:sp>VA</contact:sp><contact:pc>20166-6503</contact:pc><contact:cc>US</contact:cc></contact:addr></contact:postalInfo><contact:voice x="1234">+1.7035555555</contact:voice><contact:fax>+1.7035555556</contact:fax><contact:email>jdoe@example.com</contact:email><contact:clID>R-123</contact:clID><contact:crID>R-123</contact:crID><contact:crDate>1999-04-03T22:00:00.0Z</contact:crDate><contact:upID>R-123</contact:upID><contact:upDate>1999-12-03T09:00:00.0Z</contact:upDate><contact:trDate>2000-04-08T09:00:00.0Z</contact:trDate><contact:authInfo><contact:pw>2fooBAR</contact:pw></contact:authInfo><contact:disclose flag="0"><contact:voice/><contact:email/></contact:disclose></contact:infData></resData><extension><cx:infData xmlns:cx="http://xmlns.domini.cat/epp/contact-ext-1.0"><cx:language>ca</cx:language><cx:maintainer>myDomains.cat</cx:maintainer><cx:sponsorEmail>catsponsor@example.com</cx:sponsorEmail></cx:infData></extension><trID><clTRID>ABC-12345</clTRID><svTRID>54322-XYZ</svTRID></trID></response>'.$E2; 90$co=$dri->local_object('contact')->srid('sh8013')->auth({pw=>'2fooBAR'}); 91$rc=$dri->contact_info($co); 92is_string($R1,$E1.'<command><info><contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd"><contact:id>sh8013</contact:id><contact:authInfo><contact:pw>2fooBAR</contact:pw></contact:authInfo></contact:info></info><clTRID>ABC-12345</clTRID></command>'.$E2,'contact_info build'); 93is($rc->is_success(),1,'contact_info is_success'); 94is($dri->get_info('exist'),1,'contact_info get_info(exist)'); 95$co=$dri->get_info('self'); 96isa_ok($co,'Net::DRI::Data::Contact::CAT','contact_info get_info(self)'); 97is($co->srid(),'sh8013','contact_info get_info(self) srid'); 98is($co->roid(),'SH8013-REP','contact_info get_info(self) roid'); 99$s=$dri->get_info('status'); 100isa_ok($s,'Net::DRI::Data::StatusList','contact_info get_info(status)'); 101is_deeply([$s->list_status()],['clientDeleteProhibited','linked'],'contact_info get_info(status) list_status'); 102is($s->can_delete(),0,'contact_info get_info(status) can_delete'); 103is($co->name(),'John Doe','contact_info get_info(self) name'); 104is($co->org(),'Example Inc.','contact_info get_info(self) org'); 105is_deeply($co->street(),['123 Example Dr.','Suite 100'],'contact_info get_info(self) street'); 106is($co->city(),'Dulles','contact_info get_info(self) city'); 107is($co->sp(),'VA','contact_info get_info(self) sp'); 108is($co->pc(),'20166-6503','contact_info get_info(self) pc'); 109is($co->cc(),'US','contact_info get_info(self) cc'); 110is($co->voice(),'+1.7035555555x1234','contact_info get_info(self) voice'); 111is($co->fax(),'+1.7035555556','contact_info get_info(self) fax'); 112is($co->email(),'jdoe@example.com','contact_info get_info(self) email'); 113is($dri->get_info('clID'),'R-123','contact_info get_info(clID)'); 114is($dri->get_info('crID'),'R-123','contact_info get_info(crID)'), 115$d=$dri->get_info('crDate'); 116isa_ok($d,'DateTime','contact_info get_info(crDate)'); 117is("".$d,'1999-04-03T22:00:00','contact_info get_info(crDate) value'); 118is($dri->get_info('upID'),'R-123','contact_info get_info(upID)'); 119$d=$dri->get_info('upDate'); 120isa_ok($d,'DateTime','contact_info get_info(upDate)'); 121is("".$d,'1999-12-03T09:00:00','contact_info get_info(upDate) value'); 122$d=$dri->get_info('trDate'); 123isa_ok($d,'DateTime','contact_info get_info(trDate)'); 124is("".$d,'2000-04-08T09:00:00','contact_info get_info(trDate) value'); 125is_deeply($co->auth(),{pw=>'2fooBAR'},'contact_info get_info(self) auth'); 126is_deeply($co->disclose(),{voice=>0,email=>0},'contact_info get_info(self) disclose'); 127is($co->lang(),'ca','contact_info get_info(self) lang'); 128is($co->maintainer(),'myDomains.cat','contact_info get_info(self) maintainer'); 129is($co->email_sponsor(),'catsponsor@example.com','contact_info get_info(self) email_sponsor'); 130 131#################################################################################################### 132## Domains 133 134##p.48 135$R2=''; 136my $cs=$dri->local_object('contactset'); 137my $c1=$dri->local_object('contact')->srid('jd1234'); 138my $c2=$dri->local_object('contact')->srid('sh8013'); 139$cs->set($c1,'registrant'); 140$cs->set($c2,'admin'); 141$cs->set($c2,'tech'); 142$cs->set($c2,'billing'); 143$rc=$dri->domain_create('barca.cat',{pure_create=>1,duration=>DateTime::Duration->new(years=>2),ns=>$dri->local_object('hosts')->set(['ns1.example.com'],['ns1.example.net']),contact=>$cs,auth=>{pw=>'2fooBAR'},name_variant=>['barc�.cat','xn--bara-2oa.cat'],lang=>'ca',maintainer=>'myDomains.cat',ens=>{sponsor=>['sponsor1@example.com','sponsor2@example.net','sponsor3@example.org'],intended_use=>'Website dedicated about sailing around Barcelona'}}); 144is_string($R1,Encode::encode('utf8',$E1.'<command><create><domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>barca.cat</domain:name><domain:period unit="y">2</domain:period><domain:ns><domain:hostObj>ns1.example.com</domain:hostObj><domain:hostObj>ns1.example.net</domain:hostObj></domain:ns><domain:registrant>jd1234</domain:registrant><domain:contact type="admin">sh8013</domain:contact><domain:contact type="billing">sh8013</domain:contact><domain:contact type="tech">sh8013</domain:contact><domain:authInfo><domain:pw>2fooBAR</domain:pw></domain:authInfo></domain:create></create><extension><dx:create xmlns:dx="http://xmlns.domini.cat/epp/domain-ext-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/domain-ext-1.0 puntcat-domain-ext-1.0.xsd"><dx:nameVariant>barc�.cat</dx:nameVariant><dx:nameVariant>xn--bara-2oa.cat</dx:nameVariant><dx:language>ca</dx:language><dx:maintainer>myDomains.cat</dx:maintainer><dx:ens><dx:sponsoring><dx:sponsor>sponsor1@example.com</dx:sponsor><dx:sponsor>sponsor2@example.net</dx:sponsor><dx:sponsor>sponsor3@example.org</dx:sponsor></dx:sponsoring><dx:intendedUse>Website dedicated about sailing around Barcelona</dx:intendedUse></dx:ens></dx:create></extension><clTRID>ABC-12345</clTRID></command>'.$E2),'domain_create build'); 145 146 147##p.51 148$R2=''; 149$toc=$dri->local_object('changes'); 150$toc->add('ns',$dri->local_object('hosts')->set('ns2.example.com')); 151$cs=$dri->local_object('contactset'); 152$cs->set($dri->local_object('contact')->srid('mak21'),'tech'); 153$toc->add('contact',$cs); 154$toc->add('status',$dri->local_object('status')->no('publish','Payment overdue.')); 155$toc->del('ns',$dri->local_object('hosts')->set('ns1.example.com')); 156$cs=$dri->local_object('contactset'); 157$cs->set($dri->local_object('contact')->srid('sh8013'),'tech'); 158$toc->del('contact',$cs); 159$toc->del('status',$dri->local_object('status')->no('update')); 160$toc->set('registrant',$dri->local_object('contact')->srid('sh8013')); 161$toc->set('auth',{pw=>'2BARfoo'}); 162$toc->add('name_variant',['b�rca.cat']); 163$toc->del('name_variant',['bar�a.cat']); 164$toc->set('maintainer','ACME Domains, Inc.'); 165$rc=$dri->domain_update('barca.cat',$toc); 166is_string($R1,Encode::encode('utf8',$E1.'<command><update><domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>barca.cat</domain:name><domain:add><domain:ns><domain:hostObj>ns2.example.com</domain:hostObj></domain:ns><domain:contact type="tech">mak21</domain:contact><domain:status lang="en" s="clientHold">Payment overdue.</domain:status></domain:add><domain:rem><domain:ns><domain:hostObj>ns1.example.com</domain:hostObj></domain:ns><domain:contact type="tech">sh8013</domain:contact><domain:status s="clientUpdateProhibited"/></domain:rem><domain:chg><domain:registrant>sh8013</domain:registrant><domain:authInfo><domain:pw>2BARfoo</domain:pw></domain:authInfo></domain:chg></domain:update></update><extension><dx:update xmlns:dx="http://xmlns.domini.cat/epp/domain-ext-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/domain-ext-1.0 puntcat-domain-ext-1.0.xsd"><dx:add><dx:nameVariant>b�rca.cat</dx:nameVariant></dx:add><dx:rem><dx:nameVariant>bar�a.cat</dx:nameVariant></dx:rem><dx:chg><dx:maintainer>ACME Domains, Inc.</dx:maintainer></dx:chg></dx:update></extension><clTRID>ABC-12345</clTRID></command>'.$E2),'domain_update build'); 167 168##p.58 169$R2=Encode::encode('utf8',$E1.'<response>'.r().'<resData><domain:infData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:name>barca.cat</domain:name><domain:roid>BARCA-REP</domain:roid><domain:status s="ok"/><domain:registrant>jd1234</domain:registrant><domain:contact type="admin">sh8013</domain:contact><domain:contact type="tech">sh8013</domain:contact><domain:contact type="billing">sh8013</domain:contact><domain:ns><domain:hostObj>ns1.example.com</domain:hostObj><domain:hostObj>ns1.example.net</domain:hostObj></domain:ns><domain:host>ns1.barca.cat</domain:host><domain:host>ns2.barca.cat</domain:host><domain:clID>ClientX</domain:clID><domain:crID>ClientY</domain:crID><domain:crDate>2006-04-03T22:00:00.0Z</domain:crDate><domain:upID>ClientX</domain:upID><domain:upDate>2006-12-03T09:00:00.0Z</domain:upDate><domain:exDate>2007-04-03T22:00:00.0Z</domain:exDate><domain:trDate>2006-04-08T09:00:00.0Z</domain:trDate><domain:authInfo><domain:pw>2fooBAR</domain:pw></domain:authInfo></domain:infData></resData><extension><dx:infData xmlns:dx="http://xmlns.domini.cat/epp/domain-ext-1.0"><dx:nameVariant>b�rca.cat</dx:nameVariant><dx:nameVariant>bar�a.cat</dx:nameVariant><dx:language>ca</dx:language><dx:ens><dx:sponsoring><dx:sponsor>sponsor1@example.com</dx:sponsor><dx:sponsor>sponsor2@example.net</dx:sponsor><dx:sponsor>sponsor3@example.org</dx:sponsor></dx:sponsoring><dx:registrationType>standard</dx:registrationType><dx:intendedUse>Website dedicated about sailing around Barcelona</dx:intendedUse></dx:ens></dx:infData></extension><trID><clTRID>ABC-12345</clTRID><svTRID>54322-XYZ</svTRID></trID></response>'.$E2); 170$rc=$dri->domain_info('barca.cat',{auth=>{pw=>'2fooBAR'}}); 171is($dri->get_info('exist'),1,'domain_info get_info(exist)'); 172is($dri->get_info('roid'),'BARCA-REP','domain_info get_info(roid)'); 173$s=$dri->get_info('status'); 174isa_ok($s,'Net::DRI::Data::StatusList','domain_info get_info(status)'); 175is_deeply([$s->list_status()],['ok'],'domain_info get_info(status) list'); 176is($s->is_active(),1,'domain_info get_info(status) is_active'); 177$s=$dri->get_info('contact'); 178isa_ok($s,'Net::DRI::Data::ContactSet','domain_info get_info(contact)'); 179is_deeply([$s->types()],['admin','billing','registrant','tech'],'domain_info get_info(contact) types'); 180is($s->get('registrant')->srid(),'jd1234','domain_info get_info(contact) registrant srid'); 181is($s->get('admin')->srid(),'sh8013','domain_info get_info(contact) admin srid'); 182is($s->get('tech')->srid(),'sh8013','domain_info get_info(contact) tech srid'); 183is($s->get('billing')->srid(),'sh8013','domain_info get_info(contact) billing srid'); 184$dh=$dri->get_info('host'); 185isa_ok($dh,'Net::DRI::Data::Hosts','domain_info get_info(host)'); 186@c=$dh->get_names(); 187is_deeply(\@c,['ns1.barca.cat','ns2.barca.cat'],'domain_info get_info(host) get_names'); 188$dh=$dri->get_info('ns'); 189isa_ok($dh,'Net::DRI::Data::Hosts','domain_info get_info(ns)'); 190@c=$dh->get_names(); 191is_deeply(\@c,['ns1.example.com','ns1.example.net'],'domain_info get_info(ns) get_names'); 192is($dri->get_info('clID'),'ClientX','domain_info get_info(clID)'); 193is($dri->get_info('crID'),'ClientY','domain_info get_info(crID)'); 194$d=$dri->get_info('crDate'); 195isa_ok($d,'DateTime','domain_info get_info(crDate)'); 196is("".$d,'2006-04-03T22:00:00','domain_info get_info(crDate) value'); 197is($dri->get_info('upID'),'ClientX','domain_info get_info(upID)'); 198$d=$dri->get_info('upDate'); 199isa_ok($d,'DateTime','domain_info get_info(upDate)'); 200is("".$d,'2006-12-03T09:00:00','domain_info get_info(upDate) value'); 201$d=$dri->get_info('exDate'); 202isa_ok($d,'DateTime','domain_info get_info(exDate)'); 203is("".$d,'2007-04-03T22:00:00','domain_info get_info(exDate) value'); 204$d=$dri->get_info('trDate'); 205isa_ok($d,'DateTime','domain_info get_info(trDate)'); 206is("".$d,'2006-04-08T09:00:00','domain_info get_info(trDate) value'); 207is_deeply($dri->get_info('auth'),{pw=>'2fooBAR'},'domain_info get_info(auth)'); 208is_deeply($dri->get_info('name_variant'),['b�rca.cat','bar�a.cat'],'domain_info get_info(name_variant)'); 209is($dri->get_info('lang'),'ca','domain_info get_info(lang)'); 210is(ref($dri->get_info('ens')),'HASH','domain_info get_info(ens) HASH'); 211my %ens=%{$dri->get_info('ens')}; 212is_deeply($ens{sponsor},['sponsor1@example.com','sponsor2@example.net','sponsor3@example.org'],'domain_info get_info(ens) sponsor'); 213is($ens{registration_type},'standard','domain_info get_info(ens) registration_type'); 214is($ens{intended_use},'Website dedicated about sailing around Barcelona','domain_info get_info(ens) intended_use'); 215 216#################################################################################################### 217 218## Defensive Registration 219 220# p.71 221my $ro=$dri->remote_object('defreg'); 222$cs=$dri->local_object('contactset'); 223$c1=$dri->local_object('contact')->srid('C100004'); 224$cs->set($c1,'registrant'); 225$cs->set($c1,'admin'); 226$cs->set($c1,'billing'); 227$rc=$ro->create('test28-id',{duration=>DateTime::Duration->new(years=>2),pattern=>'coca-cola',contact=>$cs,auth=>{pw=>'123456'},maintainer=>'myDomains Inc',trademark=>{name=>'Coca Cola',issue_date=>DateTime->new(year=>1923,month=>12,day=>30),country=>'US',number=>12345}}); 228is_string($R1,$E1.'<command><create><defreg:create xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>test28-id</defreg:id><defreg:period unit="y">2</defreg:period><defreg:pattern>coca-cola</defreg:pattern><defreg:registrant>C100004</defreg:registrant><defreg:contact type="billing">C100004</defreg:contact><defreg:contact type="admin">C100004</defreg:contact><defreg:authInfo><defreg:pw>123456</defreg:pw></defreg:authInfo><defreg:maintainer>myDomains Inc</defreg:maintainer><defreg:trademark><defreg:name>Coca Cola</defreg:name><defreg:issueDate>1923-12-30</defreg:issueDate><defreg:country>US</defreg:country><defreg:number>12345</defreg:number></defreg:trademark></defreg:create></create><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_create build'); 229 230# p.73 231$ro=$dri->remote_object('defreg','test18-id'); 232$toc=$dri->local_object('changes'); 233$cs=$dri->local_object('contactset'); 234$cs->set($dri->local_object('contact')->srid('C100004'),'admin'); 235$toc->add('contact',$cs); 236$toc->add('status',$dri->local_object('status')->no('update')); 237$cs=$dri->local_object('contactset'); 238$cs->set($dri->local_object('contact')->srid('C100005'),'admin'); 239$toc->del('contact',$cs); 240$toc->set('registrant',$dri->local_object('contact')->srid('C39392')); 241$toc->set('auth',{pw=>'1234567'}); 242$toc->set('maintainer','test'); 243$toc->set('trademark',{name=>'ACMED',issue_date=>DateTime->new(year=>2005,month=>12,day=>31),country=>'DE',number=>123456}); 244$rc=$ro->update($toc); 245is_string($R1,$E1.'<command><update><defreg:update xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>test18-id</defreg:id><defreg:add><defreg:contact type="admin">C100004</defreg:contact><defreg:status s="clientUpdateProhibited"/></defreg:add><defreg:rem><defreg:contact type="admin">C100005</defreg:contact></defreg:rem><defreg:chg><defreg:registrant>C39392</defreg:registrant><defreg:authInfo><defreg:pw>1234567</defreg:pw></defreg:authInfo><defreg:maintainer>test</defreg:maintainer><defreg:trademark><defreg:name>ACMED</defreg:name><defreg:issueDate>2005-12-31</defreg:issueDate><defreg:country>DE</defreg:country><defreg:number>123456</defreg:number></defreg:trademark></defreg:chg></defreg:update></update><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_update build'); 246 247# p.74 248$ro=$dri->remote_object('defreg','DR39533'); 249$rc=$ro->delete(); 250is_string($R1,$E1.'<command><delete><defreg:delete xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>DR39533</defreg:id></defreg:delete></delete><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_delete build'); 251 252# p.75 253$ro=$dri->remote_object('defreg','DR38328'); 254$rc=$ro->renew({duration=>DateTime::Duration->new(years=>2),current_expiration=>DateTime->new(year=>2009,month=>01,day=>23)}); 255is_string($R1,$E1.'<command><renew><defreg:renew xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>DR38328</defreg:id><defreg:curExpDate>2009-01-23</defreg:curExpDate><defreg:period unit="y">2</defreg:period></defreg:renew></renew><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_renew build'); 256 257# p.76 258$R2=$E1.'<response>'.r().'<resData><defreg:infData xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0"><defreg:id>A29483</defreg:id><defreg:roid>39483-A</defreg:roid><defreg:pattern>coca-cola</defreg:pattern><defreg:status s="serverUpdateProhibited"/><defreg:status s="serverDeleteProhibited"/><defreg:registrant>jd1234</defreg:registrant><defreg:contact type="admin">sh8013</defreg:contact><defreg:contact type="billing">sh8013</defreg:contact><defreg:authInfo><defreg:pw>2fooBAR</defreg:pw></defreg:authInfo><defreg:maintainer>myDomains.cat</defreg:maintainer><defreg:trademark><defreg:name>ACMED</defreg:name><defreg:issueDate>2005-12-31</defreg:issueDate><defreg:country>DE</defreg:country><defreg:number>123456</defreg:number></defreg:trademark><defreg:clID>R-123</defreg:clID><defreg:crID>R-123</defreg:crID><defreg:crDate>2006-04-03T22:00:00.0Z</defreg:crDate></defreg:infData></resData><trID><clTRID>ABC-12345</clTRID><svTRID>54322-XYZ</svTRID></trID></response>'.$E2; 259$ro=$dri->remote_object('defreg','A29483'); 260$rc=$ro->info({auth=>{pw=>'mySecret',roid=>'DR-5932'}}); 261is_string($R1,$E1.'<command><info><defreg:info xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>A29483</defreg:id><defreg:authInfo><defreg:pw roid="DR-5932">mySecret</defreg:pw></defreg:authInfo></defreg:info></info><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_info build'); 262is($rc->is_success(),1,'defreg_info is_success'); 263is($dri->get_info('action'),'info','defreg_info get_info(action)'); 264is($dri->get_info('exist'),1,'defreg_info get_info(exist)'); 265is($dri->get_info('id'),'A29483','defreg_info get_info(id)'); 266is($dri->get_info('roid'),'39483-A','defreg_info get_info(roid)'); 267is($dri->get_info('pattern'),'coca-cola','defreg_info get_info(pattern)'); 268$s=$dri->get_info('status'); 269isa_ok($s,'Net::DRI::Data::StatusList','defreg_info get_info(status)'); 270is_deeply([$s->list_status()],['serverDeleteProhibited','serverUpdateProhibited'],'defreg_info get_info(status) list'); 271is($s->can_update(),0,'defreg_info get_info(status) can_update'); 272is($s->can_delete(),0,'defreg_info get_info(status) can_delete'); 273$s=$dri->get_info('contact'); 274isa_ok($s,'Net::DRI::Data::ContactSet','defreg_info get_info(contact)'); 275is_deeply([$s->types()],['admin','billing','registrant'],'defreg_info get_info(contact) types'); 276is($s->get('registrant')->srid(),'jd1234','defreg_info get_info(contact) registrant srid'); 277is($s->get('admin')->srid(),'sh8013','defreg_info get_info(contact) admin srid'); 278is($s->get('billing')->srid(),'sh8013','defreg_info get_info(contact) billing srid'); 279is_deeply($dri->get_info('auth'),{pw=>'2fooBAR'},'defreg_info get_info(auth)'); 280is($dri->get_info('maintainer'),'myDomains.cat','defreg_info get_info(maintainer)'); 281is(ref($dri->get_info('trademark')),'HASH','defreg_info get_info(trademark) HASH'); 282my %t=%{$dri->get_info('trademark')}; 283is_deeply([sort(keys(%t))],['country','issue_date','name','number'],'defreg_info get_info(trademark) KEYS'); 284is($t{name},'ACMED','defreg_info get_info(trademark) name'); 285is(''.$t{issue_date},'2005-12-31T00:00:00','defreg_info get_info(trademark) issue_date'); 286is($t{country},'DE','defreg_info get_info(trademark) country'); 287is($t{number},'123456','defreg_info get_info(trademark) number'); 288is($dri->get_info('clID'),'R-123','defreg_info get_info(clID)'); 289is($dri->get_info('crID'),'R-123','defreg_info get_info(crID)'); 290$d=$dri->get_info('crDate'); 291isa_ok($d,'DateTime','defreg_info get_info(crDate)'); 292is("".$d,'2006-04-03T22:00:00','defreg_info get_info(crDate) value'); 293 294# p.78 295$R2=$E1.'<response>'.r().'<resData><defreg:chkData xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0"><defreg:cd><defreg:id avail="1">DR3958</defreg:id></defreg:cd><defreg:cd><defreg:id avail="0">DR3959</defreg:id><defreg:reason>In use</defreg:reason></defreg:cd><defreg:cd><defreg:id avail="0">REG-38245</defreg:id><defreg:reason>Reserved</defreg:reason></defreg:cd></defreg:chkData></resData><trID><clTRID>ABC-12345</clTRID><svTRID>54322-XYZ</svTRID></trID></response>'.$E2; 296$ro=$dri->remote_object('defreg'); 297$rc=$ro->check('DR3958','DR3959','REG-38245'); 298is_string($R1,$E1.'<command><check><defreg:check xmlns:defreg="http://xmlns.domini.cat/epp/defreg-1.0" xsi:schemaLocation="http://xmlns.domini.cat/epp/defreg-1.0 puntcat-defreg-1.0.xsd"><defreg:id>DR3958</defreg:id><defreg:id>DR3959</defreg:id><defreg:id>REG-38245</defreg:id></defreg:check></check><clTRID>ABC-12345</clTRID></command>'.$E2,'defreg_check build'); 299is($rc->is_success(),1,'defreg_check is_success'); 300is($dri->get_info('action','defreg','DR3958'),'check','defreg_check get_info(action)'); 301is($dri->get_info('exist','defreg','DR3958'),0,'defreg_check get_info(exist) 1'); 302is($dri->get_info('exist','defreg','DR3959'),1,'defreg_check get_info(exist) 2'); 303is($dri->get_info('exist_reason','defreg','DR3959'),'In use','defreg_check get_info(exist_reason) 1'); 304is($dri->get_info('exist','defreg','REG-38245'),1,'defreg_check get_info(exist) 3'); 305is($dri->get_info('exist_reason','defreg','REG-38245'),'Reserved','defreg_check get_info(exist_reason) 2'); 306 307exit 0; 308 309sub r 310{ 311 my ($c,$m)=@_; 312 return '<result code="'.($c || 1000).'"><msg>'.($m || 'Command completed successfully').'</msg></result>'; 313} 314