function _testOnlineNIC() { $Registrant = $this->Registry->NewContactInstance(CONTACT_TYPE::REGISTRANT); $Registrant->SetFieldList($this->contact_data); $Registrant->AuthCode = rand(100000, 999999); $this->Registry->CreateContact($Registrant); $this->assertTrue($Registrant->CLID != null, 'Create registrant contact'); $Contact = $this->Registry->NewContactInstanceByGroup('generic'); $Contact->SetFieldList(array_merge($this->contact_data, array('cc' => 'US', 'AppPurpose' => 'P1', 'NexusCategory' => 'C12'))); $Contact->AuthCode = rand(100000, 999999); $this->Registry->CreateContact($Contact); $this->assertTrue($Contact->CLID != null, 'Create generic contact'); $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = 'webta' . rand(1000, 9999); $this->assertTrue($this->Registry->DomainCanBeRegistered($Domain), 'Domain available for registration'); $Domain->SetNameserverList(array(new Nameserver('ns1.onlinenic.com'), new Nameserver('ns2.onlinenic.com'))); $Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT); $Domain->SetContact($Contact, CONTACT_TYPE::TECH); $Domain->SetContact($Contact, CONTACT_TYPE::BILLING); $Domain->SetContact($Contact, CONTACT_TYPE::ADMIN); $Domain->AuthCode = rand(10000000, 99999999); $this->Registry->CreateDomain($Domain, 2); $this->assertTrue($Domain->ID != null && $Domain->Status == DOMAIN_STATUS::DELEGATED, 'Create domain'); $contact_data = $Contact->GetFieldList(); $contact_data['name'] = 'Nerrible man'; $Contact->SetFieldList($contact_data); $Contact->ExtraData['type'] = CONTACT_TYPE::TECH; $Contact->ExtraData['domainname'] = $Domain->Name; $this->Registry->UpdateContact($Contact); $this->assertTrue(true, 'Update contact'); $old_expire_date = $Domain->ExpireDate; $this->Registry->RenewDomain($Domain, array('period' => 1)); $this->assertTrue($Domain->ExpireDate !== $old_expire_date, 'Renew domain'); $nslist = $Domain->GetNameserverList(); $changelist = $Domain->GetNameserverChangelist(); $changelist->SetChangedList(array(new Nameserver('ns1.google.com'), new Nameserver('ns2.google.com'))); $this->Registry->UpdateDomainNameservers($Domain, $changelist); $this->assertTrue($Domain->GetNameserverList() == $changelist->GetList(), 'Update domain nameservers'); $Domain2 = $this->Registry->NewDomainInstance(); $Domain2->Name = $Domain->Name; $Domain2 = $this->Registry->GetRemoteDomain($Domain2); $this->assertTrue($Domain2->ExpireDate == $Domain->ExpireDate, 'Get remote domain'); $nshost = new NameserverHost("ns1.{$Domain->GetHostName()}", '70.84.45.21'); $this->Registry->CreateNameserverHost($nshost); $nshost->IPAddr = '70.84.45.23'; $this->Registry->GetModule()->UpdateNameserverHost($nshost); $ok = $this->Registry->DeleteNameserverHost($nshost); $this->assertTrue($ok, 'Delete nameserver host'); $ok = $this->Registry->DeleteDomain($Domain); $this->assertTrue($ok, 'Delete domain'); }
public function Run () { //// // 1. Login (will be done automatical in next command) //// // 2. Poll. Get transfer auth code $Resp = $this->Module->Request('poll-request', array()); $this->AssertTrue($Resp->Succeed, 'Login'); if ($Resp->Code == RFC3730_RESULT_CODE::OK_ACK_DEQUEUE) { $msgID = (string)$Resp->Data->response->msgQ->attributes()->id; $infData = $Resp->Data->response->resData->children('urn:ietf:params:xml:ns:domain-1.0'); $infData = $infData[0]; $auth_code = (string)$infData->authInfo->pw; } else { $auth_code = 'my&p$w#d22.'; } $this->AssertTrue(isset($msgID, $auth_code), 'Poll'); //// // 3. Request transfer $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = "{$this->clID}-domain-1"; $Resp = $this->Module->TransferRequest($Domain, array('pw' => $auth_code)); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Transfer domain 1'); //// // 4. Acknowledge message $Resp = $this->Module->Request('poll-ack', array('msgID' => $msgID)); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Acknowledge message'); //// // 5. Check contact 1 $Contact1 = $this->Registry->NewContactInstanceByGroup('generic'); $Contact1->CLID = strtoupper($this->clID)."-1"; $ok = $this->Registry->ContactCanBeCreated($Contact1); $this->AssertTrue($ok, 'Check contact 1'); //// // 6. Create contact 1 $contact_data = array( 'name' => 'Firstname Lastname', 'org' => 'Organisation', 'street1' => 'Testdivision', 'street2' => 'Teststrasse 999', 'city' => 'Bern', 'pc' => '3001', 'cc' => 'CH', 'voice' => '+41-335-555555', 'email' => '*****@*****.**' ); $Contact1->SetFieldList($contact_data); $Resp = $this->Module->CreateContact($Contact1); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Create contact 1'); $Contact1->CLID = $Resp->CLID; //// // 7. Create name server 1 $NS3 = new NameserverHost('ns3.' . $Domain->GetHostName(), '240.1.1.1'); $Resp = $this->Module->CreateNameserverHost($NS3); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Create name server 1'); //// // 8. Info domain 1 $GrdResp = $this->Module->GetRemoteDomain($Domain); $this->AssertTrue($GrdResp->TechContact, 'Info domain 1'); //// // 9. Info Tech-Contact $Tech = $this->Registry->NewContactInstanceByGroup('generic'); $Tech->CLID = $GrdResp->TechContact; $Resp = $this->Module->GetRemoteContact($Tech); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Info Tech-Contact'); //// // 10. Update domain 1 (complete transfer) $add = '<domain:add>'; $add .= '<domain:ns><domain:hostObj>'.$NS3->HostName.'</domain:hostObj></domain:ns>'; $add .= '<domain:contact type="tech">'.$Contact1->CLID.'</domain:contact>'; $add .= '</domain:add>'; $rem = '<domain:rem>'; $rem .= '<domain:ns><domain:hostObj>ns1.'.$Domain->GetHostName().'</domain:hostObj></domain:ns>'; $rem .= '</domain:rem>'; $chg = '<domain:chg>'; $chg .= '<domain:registrant>'.$Contact1->CLID.'</domain:registrant>'; $chg .= '</domain:chg>'; $params = array( 'name' => $Domain->GetHostName(), 'add' => $add, 'remove' => $rem, 'change' => $chg ); $Resp = $this->Module->Request('domain-update', $params); $this->AssertTrue($Resp->Succeed, 'Update domain 1 (complete transfer)'); //// // 11. Create contact 2 $Contact2 = $this->Registry->NewContactInstanceByGroup('generic'); $Contact2->CLID = strtoupper($this->clID).'-2'; $Contact2->SetFieldList(array( 'name' => 'Firstname2 Lastname2', 'org' => 'Organisation2', 'street1' => 'Testdivision', 'street2' => 'Teststreet 999', 'city' => 'Bern', 'cc' => 'CH', 'pc' => '3001', 'voice' => '+41-335-555555', 'email' => '*****@*****.**' )); $Resp = $this->Module->CreateContact($Contact2); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Create contact 2'); $Contact2->CLID = $Resp->CLID; //// // 12. Delete domain 1 (for a holder transfer) $Resp = $this->Module->DeleteDomain($Domain); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Delete domain 1 (for a holder transfer)'); //// // 13. Create domain 1 $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = "{$this->clID}-domain-1"; $Domain->SetContact($Contact2, CONTACT_TYPE::REGISTRANT); $NS2 = new NameserverHost('ns2.'.$Domain->GetHostName(), '240.1.1.1'); $Domain->SetNameserverList(array($NS2, $NS3)); $Cdr = $this->Module->CreateDomain($Domain, 1); $this->AssertTrue($Cdr->CreateDate && $Cdr->ExpireDate, 'Create domain 1'); //// // 14. Delete contact 1 $Resp = $this->Module->DeleteContact($Contact1); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Delete contact 1'); //// // 15. Delete name server 1 $NS1 = new NameserverHost('ns1.'.$Domain->GetHostName(), '240.1.1.1'); $Resp = $this->Module->DeleteNameserverHost($NS1); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Delete name server 1'); //// // 16. Check domain 2 $Domain2 = $this->Registry->NewDomainInstance(); $Domain2->Name = "{$this->clID}-domain-2"; $ok = $this->Registry->DomainCanBeRegistered($Domain2)->Result; $this->AssertTrue($ok, 'Check domain 2'); //// // 17. Create domain 2 $Domain2->SetContact($Contact2, CONTACT_TYPE::REGISTRANT); $Domain2->SetNameserverList(array($NS3)); $Cdr = $this->Module->CreateDomain($Domain2, 1); $this->AssertTrue($Cdr->CreateDate && $Cdr->ExpireDate, 'Create domain 2'); //// // 18. Create name server 2 subordinate of domain 2 $NS12 = new NameserverHost('ns1.'.$Domain2->GetHostName(), '240.1.1.1'); $Resp = $this->Module->CreateNameserverHost($NS12); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Create name server 2 subordinate of domain 2'); //// // 19. Update domain 1 with ns 2 /* $Changes = $Domain->GetNameserverChangelist(); $Changes->Add($NS12); $this->Registry->UpdateDomainNameservers($Domain, $Changes); $this->AssertTrue(true, 'Update domain 1 with ns 2'); */ $params = array( 'name' => 'test-partner-a-domain-1.ch', 'add' => '<domain:add><domain:ns><domain:hostObj>ns1.test-partner-a-domain-2.ch</domain:hostObj></domain:ns></domain:add>', 'remove' => '', 'change' => '' ); $Resp = $this->Module->Request('domain-update', $params); $this->AssertTrue($Resp->Succeed, 'Update domain 1 with ns 2'); //// // 20. Update contact 2 $contact_data = $Contact2->GetFieldList(); unset($contact_data['org']); $contact_data['street1'] = 'New Division'; $Contact2->SetFieldList($contact_data); $Resp = $this->Module->UpdateContact($Contact2); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Update contact 2'); //// // 21. Delete domain 1 $Resp = $this->Module->DeleteDomain($Domain); $this->AssertTrue($Resp->Code == RFC3730_RESULT_CODE::OK, 'Delete domain 1'); /* $params = array( 'name' => $Domain->GetHostName() ); $Resp = $this->Module->Request('domain-delete', $params); $this->AssertTrue($Resp->Succeed, 'Delete domain 1'); */ //// // 22. Update domain 2 with authinfo $chg = '<domain:chg>'; $chg .= '<domain:authInfo><domain:pw>2BARfoo</domain:pw></domain:authInfo>'; $chg .= '</domain:chg>'; $params = array( 'name' => $Domain2->GetHostName(), 'add' => '', 'remove' => '', 'change' => $chg ); $Resp = $this->Module->Request('domain-update', $params); $this->AssertTrue($Resp->Succeed, 'Update domain 2 with authinfo'); //// // 23. Logout $Resp = $this->Module->Request('logout', array()); $this->AssertTrue(true, 'Logout'); }
function _testEPP () { $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = 'webta' . rand(1000, 9999); // check domain try { $ok = $this->Registry->DomainCanBeRegistered($Domain); $this->assertTrue($ok, 'Domain available for registration'); } catch (Exception $e) { return $this->fail('Domain available for registration. Error: ' . $e->getMessage()); } //// // Create contact try { $Registrant = $this->Registry->NewContactInstanceByGroup('generic'); $Registrant->SetFieldList($this->contact_fields); $this->Registry->CreateContact($Registrant); $this->assertTrue(true, 'Create contact'); } catch (Exception $e) { return $this->fail('Create contact. Error: ' . $e->getMessage()); } //// // Get contact INFO try { $RRegistrant = $this->Registry->NewContactInstanceByGroup('generic'); $RRegistrant->CLID = $Registrant->CLID; $this->Registry->GetRemoteContact($RRegistrant); $fields = $Registrant->GetFieldList(); $rfields = $RRegistrant->GetFieldList(); ksort($fields); ksort($rfields); $discloses = $Registrant->GetDiscloseList(); $rdiscloses = $RRegistrant->GetDiscloseList(); ksort($discloses); ksort($rdiscloses); $this->assertTrue( $fields['name'] == $rfields['name'] && $fields['email'] == $rfields['email'] && $fields['voice'] == $rfields['voice'] && $discloses == $rdiscloses, 'Get remote contact'); } catch (Exception $e) { return $this->fail('Get remote contact. Error: ' . $e->getMessage()); } try { $Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT); $Domain->SetNameserverList(array( new Nameserver('ns.hostdad.com'), new Nameserver('ns2.hostdad.com') )); $this->DBDomain->Save($Domain); $this->Registry->CreateDomain($Domain, 2, array('comment' => 'abc')); $this->assertTrue(true, 'Create domain'); } catch (Exception $e) { return $this->fail('Create domain. Error: ' . $e->getMessage()); } $Obs = new TestRegistryObserver($this->Registry, $this); $this->Registry->AttachObserver($Obs); $this->Registry->DispatchPendingOperations(); }
function testEPP() { $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = 'webta' . rand(1000, 9999); // check domain try { $ok = $this->Registry->DomainCanBeRegistered($Domain)->Result; $this->assertTrue($ok, 'Domain available for registration'); } catch (Exception $e) { return $this->fail('Domain available for registration. Error: ' . $e->getMessage()); } //// // Create contact try { $Registrant = $this->Registry->NewContactInstanceByGroup('generic'); $Registrant->SetFieldList($this->contact_fields); $this->Registry->CreateContact($Registrant); $this->assertTrue(true, 'Create contact'); } catch (Exception $e) { return $this->fail('Create contact. Error: ' . $e->getMessage()); } //// // Get contact INFO try { $RRegistrant = $this->Registry->NewContactInstanceByGroup('generic'); $RRegistrant->CLID = $Registrant->CLID; $this->Registry->GetRemoteContact($RRegistrant); $fields = $Registrant->GetFieldList(); $rfields = $RRegistrant->GetFieldList(); ksort($fields); ksort($rfields); $discloses = $Registrant->GetDiscloseList(); $rdiscloses = $RRegistrant->GetDiscloseList(); ksort($discloses); ksort($rdiscloses); $this->assertTrue($fields['name'] == $rfields['name'] && $fields['email'] == $rfields['email'] && $fields['voice'] == $rfields['voice'] && $discloses == $rdiscloses, 'Get remote contact'); } catch (Exception $e) { return $this->fail('Get remote contact. Error: ' . $e->getMessage()); } try { $Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT); $this->Registry->CreateDomain($Domain, 2); $this->assertTrue(true, 'Create domain'); } catch (Exception $e) { return $this->fail('Create domain. Error: ' . $e->getMessage()); } //// // 3. CREATE 2 child name servers of newly created domain // try { $ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $ns3 = new NameserverHost('ns3.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $this->Registry->CreateNameserverHost($ns1); $this->Registry->CreateNameserverHost($ns2); $this->Registry->CreateNameserverHost($ns3); $this->assertTrue(true, 'Create nameservers'); } catch (Exception $e) { return $this->fail('Create nameservers. Error: ' . $e->getMessage()); } //// // 4. UPDATE Domain to attach child name servers to domain // try { $nslist = $Domain->GetNameserverChangelist(); $nslist->Add($ns1); $nslist->Add($ns2); $nslist->Add($ns3); $this->Registry->UpdateDomainNameservers($Domain, $nslist); $this->assertTrue(count($Domain->GetNameserverList()) == 3, 'Attach nameservers to domain'); } catch (Exception $e) { return $this->fail('Attach nameservers to domain. Error: ' . $e->getMessage()); } //// // 5. UPDATE Domain�s status to // clientHold, clientUpdateProhibited, clientDeleteProhibited, and clientTransferProhibited // within one command try { $flag_list = $Domain->GetFlagChangelist(); $flag_list->SetChangedList(array('clientUpdateProhibited', 'clientDeleteProhibited', 'clientTransferProhibited')); $this->Registry->UpdateDomainFlags($Domain, $flag_list); $this->assertTrue(count($Domain->GetFlagList()) == count($flag_list->GetList()), 'Update domain status'); } catch (Exception $e) { return $this->fail('Update domain status. Error: ' . $e->getMessage()); } //// // 6. Perform an INFO command on the domain to verify update // try { $RDomain = $this->Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $this->Registry->GetRemoteDomain($RDomain); $flags = $Domain->GetFlagList(); $rflags = $RDomain->GetFlagList(); sort($flags); sort($rflags); $this->assertTrue($RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && $rflags == $flags, 'Get remote domain'); } catch (Exception $e) { return $this->fail('Get remote domain. Error: ' . $e->getMessage()); } //// // 7. UPDATE Domain�s status to OK // try { $changes = $Domain->GetFlagChangelist(); foreach ($RDomain->GetFlagList() as $flag) { $changes->Remove($flag); } $this->Registry->UpdateDomainFlags($Domain, $changes); //$changes = $Domain->GetFlagChangelist(); //$changes->Add('ok'); //$this->Registry->UpdateDomainFlags($Domain, $changes); $this->assertTrue($Domain->GetFlagList() == array(), 'Update domain status'); $Domain->SetFlagList(array('ok')); // ok flag set automatical when all other were removed // ^our bug ? } catch (Exception $e) { return $this->fail('Update domain status. Error: ' . $e->getMessage()); } //// // 8. Perform an INFO command on the domain to verify update // try { $RDomain = $this->Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $this->Registry->GetRemoteDomain($RDomain); $this->assertTrue($RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && $RDomain->GetFlagList() == array('ok'), 'Get remote domain'); } catch (Exception $e) { return $this->fail('Get remote domain. Error: ' . $e->getMessage()); } //// // 10. UPDATE one of the name server�s IP Address // try { $ns1->IPAddr = gethostbyname('ns.hostdad.com'); $Resp = $this->Registry->GetModule()->UpdateNameserverHost($ns1); $this->assertTrue($Resp->Result, 'Update domain nameserver'); } catch (Exception $e) { return $this->fail('Update domain nameserver. Error: ' . $e->getMessage()); } //// // 12. Renew Domain for 2 years // try { $old_expire_date = $Domain->ExpireDate; $this->Registry->RenewDomain($Domain, $extra = array('period' => 2)); $this->assertTrue(date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+2 year', $old_expire_date)), 'Domain renewal'); } catch (Exception $e) { return $this->fail('Domain renewal. Error: ' . $e->getMessage()); } //// // Remove domain nameservers try { $nslist = $Domain->GetNameserverChangelist(); $nslist->Remove($ns1); $nslist->Remove($ns2); $nslist->Remove($ns3); $this->Registry->UpdateDomainNameservers($Domain, $nslist); $this->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain'); } catch (Exception $e) { return $this->fail('Remove nameservers from domain. Error: ' . $e->getMessage()); } //// // Delete nameservers try { $this->Registry->DeleteNameserverHost($ns1); $this->Registry->DeleteNameserverHost($ns2); $this->assertTrue(true, 'Delete nameservers'); } catch (Exception $e) { return $this->fail('Delete nameservers. Error: ' . $e->getMessage()); } //// // Delete domain try { $this->Registry->DeleteDomain($Domain); $this->assertTrue(true, 'Delete domain'); } catch (Exception $e) { return $this->fail('Delete domain. Error: ' . $e->getMessage()); } //// /// Delete contact try { $this->Registry->DeleteContact($Registrant); $this->assertTrue(true, 'Delete contact'); } catch (Exception $e) { return $this->fail('Delete contact. Error: ' . $e->getMessage()); } }
function _testEPP () { $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = 'webta' . rand(1000, 9999); var_dump($Domain->Name); //// // Check domain $ok = $this->Registry->DomainCanBeRegistered($Domain); $this->assertTrue($ok, 'Domain available for registration'); //// // Create contact $Registrant = $this->Registry->NewContactInstanceByGroup('generic'); $Registrant->SetFieldList($this->contact_data); $this->Registry->CreateContact($Registrant); $this->assertTrue(true, 'Create contact'); //// // Get remote contact $RRegistrant = $this->Registry->NewContactInstanceByGroup('generic'); $RRegistrant->CLID = $Registrant->CLID; $this->Registry->GetRemoteContact($RRegistrant); $fields = $Registrant->GetFieldList(); $rfields = $RRegistrant->GetFieldList(); $this->assertTrue( $fields['name'] == $rfields['name'] && $fields['email'] == $rfields['email'] && $fields['voice'] == $rfields['voice'], 'Get remote contact' ); //// // Create domain $Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT); $Domain->SetContact($Registrant, CONTACT_TYPE::ADMIN); $Domain->SetContact($Registrant, CONTACT_TYPE::TECH); $Domain->SetContact($Registrant, CONTACT_TYPE::BILLING); $Domain->SetNameserverList(array( new Nameserver('ns.hostdad.com'), new Nameserver('ns2.hostdad.com') )); $this->Registry->CreateDomain($Domain, 2); $this->assertTrue(true, 'Create domain'); //// // Create nameservers $ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $this->Registry->CreateNameserverHost($ns1); $this->Registry->CreateNameserverHost($ns2); $this->assertTrue(true, 'Create nameservers'); //// // Attach nameservers to domain $nslist = $Domain->GetNameserverChangelist(); $nslist->Add($ns1); $nslist->Add($ns2); $this->Registry->UpdateDomainNameservers($Domain, $nslist); $this->assertTrue( count($Domain->GetNameserverList()) == 4, 'Attach nameservers to domain' ); //// // Create contact and update domain tech contact $Tech = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH); $Tech->SetFieldList(array_merge($this->contact_data, array( 'firstname' => 'Nikolas', 'lastname' => 'Toursky' ))); $this->Registry->CreateContact($Tech); $this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, $Registrant, $Tech); $this->assertTrue(true, 'Attach contact to domain'); //// // Lock domain $ok = $this->Registry->LockDomain($Domain); $this->assertTrue($ok, 'Lock domain'); //// // Perform info to verify update $RDomain = $this->Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $this->Registry->GetRemoteDomain($RDomain); $this->assertTrue( $RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && count($RDomain->GetNameserverList()) == count($Domain->GetNameserverList()) && $RDomain->GetContact(CONTACT_TYPE::TECH)->CLID == $Tech->CLID, 'Get remote domain' ); //// // Unlock domain $ok = $this->Registry->UnlockDomain($Domain); $this->assertTrue($ok, 'Unlock domain'); //// // UPDATE one of the name server�s IP Address $ns1->IPAddr = gethostbyname('ns.hostdad.com'); $Resp = $this->Registry->GetModule()->UpdateNameserverHost($ns1); $this->assertTrue($Resp->Result, 'Update domain nameserver'); /* //// // Renew domain for 2 years $old_expire_date = $Domain->ExpireDate; $this->Registry->RenewDomain($Domain, $extra=array('period' => 2)); $this->assertTrue( date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+2 year', $old_expire_date)), 'Domain renewal' ); */ //// // Remove nameservers from domain $ns_list = $Domain->GetNameserverList(); $Changes = $Domain->GetNameserverChangelist(); foreach ($ns_list as $NS) { $Changes->Remove($NS); } $this->Registry->UpdateDomainNameservers($Domain, $Changes); $this->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain'); //// // Delete nameservers foreach ($ns_list as $NS) { if (preg_match('/'.$Domain->Name.'/', $NS->HostName)) { $this->Registry->DeleteNameserverHost($NS); } } $this->assertTrue(true, 'Delete nameservers'); //// // Delete domain $this->Registry->DeleteDomain($Domain); $this->assertTrue(true, 'Delete domain'); //// // Delete contacts $this->Registry->DeleteContact($Registrant); $this->Registry->DeleteContact($Tech); $this->assertTrue(true, 'Delete contacts'); }
/** * Enter description here... */ public function RunTest(DataForm $DF) { $filename = '/tmp/eppdrs-verisign-certtest-' . date('YmdHis') . '.log'; Log::RegisterLogger("File", "Verisign", $filename); Log::SetDefaultLogger("Verisign"); // Build dataforms for modules $DF1 = self::GetConfigurationForm(); $DF1->GetFieldByName('Login')->Value = $DF->GetFieldByName('Login_1')->Value; $DF1->GetFieldByName('Password')->Value = $DF->GetFieldByName('Password_1')->Value; $DF1->GetFieldByName('ServerHost')->Value = $DF->GetFieldByName('ServerHost')->Value; $DF1->GetFieldByName('ServerPort')->Value = $DF->GetFieldByName('ServerPort')->Value; $DF1->GetFieldByName('SSLCertPath')->Value = $DF->GetFieldByName('SSLCertPath')->Value; $DF1->GetFieldByName('SSLCertPass')->Value = $DF->GetFieldByName('SSLCertPass')->Value; $DF2 = self::GetConfigurationForm(); $DF2->GetFieldByName('Login')->Value = $DF->GetFieldByName('Login_2')->Value; $DF2->GetFieldByName('Password')->Value = $DF->GetFieldByName('Password_2')->Value; $DF2->GetFieldByName('ServerHost')->Value = $DF->GetFieldByName('ServerHost')->Value; $DF2->GetFieldByName('ServerPort')->Value = $DF->GetFieldByName('ServerPort')->Value; $DF2->GetFieldByName('SSLCertPath')->Value = $DF->GetFieldByName('SSLCertPath')->Value; $DF2->GetFieldByName('SSLCertPass')->Value = $DF->GetFieldByName('SSLCertPass')->Value; // Initialize modules $Module = new VerisignRegistryModule(new RegistryManifest(MODULES_PATH . "/registries/Verisign/module.xml")); $Module->InitializeModule('com', $DF1); $Registry = new Registry($Module); $Module2 = new VerisignRegistryModule(new RegistryManifest(MODULES_PATH . "/registries/Verisign/module.xml")); $Module2->InitializeModule('com', $DF2); $Registry2 = new Registry($Module2); // The subject domain $Domain = $this->RegistryAccessible->NewDomainInstance(); $Domain->Name = 'webta' . rand(1000, 9999); $Domain->UserID = 1; //// // 1. Using your OT&E1 account perform a CHECK command on domain name(s) until you // receive domain available response $oplog = array(); $op = array('title' => 'Perform a CHECK command on domain name(s)'); try { $ok = $Registry->DomainCanBeRegistered($Domain)->Result; $op['ok'] = (bool) $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 2. CREATE the Domain name using the CREATE command, term of registration should be // 2 years $op = array('title' => "CREATE the Domain name using the CREATE command"); try { $Contact = $Registry->NewContactInstanceByGroup('generic'); $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT); $Domain->SetContact($Contact, CONTACT_TYPE::BILLING); $Domain->SetContact($Contact, CONTACT_TYPE::TECH); $Domain->SetContact($Contact, CONTACT_TYPE::ADMIN); $Registry->CreateDomain($Domain, 2); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 3. CREATE 2 child name servers of newly created domain // $op = array('title' => "CREATE 2 child name servers of newly created domain"); try { $ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $Registry->CreateNameserverHost($ns1); $Registry->CreateNameserverHost($ns2); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 4. UPDATE Domain to attach child name servers to domain // $op = array('title' => "UPDATE Domain to attach child name servers to domain"); try { $nslist = $Domain->GetNameserverChangelist(); $nslist->Add($ns1); $nslist->Add($ns2); $Registry->UpdateDomainNameservers($Domain, $nslist); $op['ok'] = count($Domain->GetNameserverList()) == 2; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 5. UPDATE Domain's status to // clientHold, clientUpdateProhibited, clientDeleteProhibited, and clientTransferProhibited // within one command $op = array('title' => "UPDATE Domain's status"); try { $flag_list = $Domain->GetFlagChangelist(); $flag_list->SetChangedList(array('clientHold', 'clientUpdateProhibited', 'clientDeleteProhibited', 'clientTransferProhibited')); $Registry->UpdateDomainFlags($Domain, $flag_list); $op['ok'] = count($Domain->GetFlagList()) == count($flag_list->GetList()); } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 6. Perform an INFO command on the domain to verify update // $op = array('title' => "Perform an INFO command on the domain to verify update"); try { $RDomain = $Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $Registry->GetRemoteDomain($RDomain); $flags = $Domain->GetFlagList(); $rflags = $RDomain->GetFlagList(); sort($flags); sort($rflags); $op['ok'] = $RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && $rflags == $flags; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 7. UPDATE Domain's status to OK // $op = array('title' => "UPDATE Domain's status to OK"); try { $changes = $Domain->GetFlagChangelist(); foreach ($RDomain->GetFlagList() as $flag) { $changes->Remove($flag); } $Registry->UpdateDomainFlags($Domain, $changes); //$changes = $Domain->GetFlagChangelist(); //$changes->Add('ok'); //$this->Registry->UpdateDomainFlags($Domain, $changes); $op['ok'] = $Domain->GetFlagList() == array(); $Domain->SetFlagList(array('ok')); // ok flag set automatical when all other were removed } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 8. Perform an INFO command on the domain to verify update // $op = array('title' => "Perform an INFO command on the domain to verify update"); try { $RDomain = $Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $Registry->GetRemoteDomain($RDomain); $op['ok'] = $RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && $RDomain->GetFlagList() == array('ok'); } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 9. UPDATE Domain's AUTH INFO Code // $op = array('title' => "UPDATE Domain's AUTH INFO Code"); try { // ���������� AUTH ����������� �������������� � �����-�������� API $VerisignModule = $Registry->GetModule(); $Domain->AuthCode = "ae2Yo&#YARR1"; $params = array('name' => $Domain->GetHostName(), 'subproduct' => 'dot' . strtoupper($Domain->Extension), 'add' => '', 'remove' => '', 'change' => "<domain:chg><domain:authInfo><domain:pw>{$Domain->AuthCode}</domain:pw></domain:authInfo></domain:chg>"); $Resp = $VerisignModule->Request('domain-update', $params); $success = $Resp->Succeed || $Resp->Code == RFC3730_RESULT_CODE::OK_PENDING; $op['ok'] = $success; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 10. UPDATE one of the name server's IP Address // $op = array('title' => "UPDATE one of the name server's IP Address"); try { $ns1->IPAddr = gethostbyname('ns.hostdad.com'); $Resp = $Module->UpdateNameserverHost($ns1); $op['ok'] = $Resp->Result; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 11. Perform a HELLO command // $op = array('title' => "Perform a HELLO command"); try { $VerisignModule = $Registry->GetModule(); $Resp = $VerisignModule->Request('hello', $params = array()); $op['ok'] = $Resp == true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 12. Renew Domain for 2 years // $op = array('title' => "Renew Domain for 2 years"); try { $old_expire_date = $Domain->ExpireDate; $Registry->RenewDomain($Domain, $extra = array('period' => 2)); $op['ok'] = date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+2 year', $old_expire_date)); } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 13. Open Second Session using the OT&E2 account logon // $op = array('title' => "Open Second Session using the OT&E2 account logon"); $op['ok'] = true; // It will be done automatical in next command //// // 14. Perform INFO command on the newly created domain from step 1 using the AUTH // INFO code populated in step 9 to get INFO results // $op = array('title' => "Perform INFO command on the newly created domain from step 1"); try { $RDomain = $Registry2->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain->AuthCode = $Domain->AuthCode; $RDomain = $Registry2->GetRemoteDomain($RDomain); $flags = $Domain->GetFlagList(); $rflags = $RDomain->GetFlagList(); sort($flags); sort($rflags); $op['ok'] = $RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && $rflags == $flags; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 15. Initiate Transfer domain command using your OT&E2 account // $op = array('title' => "Initiate Transfer domain command using your OT&E2 account"); try { $ok = $Registry2->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $op['ok'] = $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 16. Perform a Transfer Query command using your OT&E2 account // $op = array('title' => "Perform a Transfer Query command using your OT&E2 account"); try { // Not implemented in cross-registry API $VerisignModule2 = $Registry2->GetModule(); $params = array('name' => $Domain->GetHostName(), 'pw' => $Domain->AuthCode, 'subproduct' => 'dot' . strtoupper($Domain->Extension)); $Resp = $VerisignModule2->Request('domain-trans-query', $params); $op['ok'] = $Resp->Succeed; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 17. Approve the Transfer using your OT&E1 account // $op = array('title' => "Approve the Transfer using your OT&E1 account"); try { $ok = $Registry->TransferApprove($Domain); $op['ok'] = $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 18. Perform a Poll Command to check for messages in poll queue, ACK first poll message // // not works $op = array('title' => "Perform a Poll Command to check for messages in poll queue"); try { $VerisignModule2 = $Registry->GetModule(); $max_iter = 5; $i = 0; while ($i < $max_iter && ($Mess = $VerisignModule2->ReadMessage()) === false) { sleep(1); $i++; } $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 19. Initiate the Transfer again using your OT&E1 account // $op = array('title' => "Initiate the Transfer again using your OT&E1 account"); try { $ok = $Registry->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $op['ok'] = $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 20. Perform a Transfer Query command using your OT&E2 account // $op = array('title' => "Perform a Transfer Query command using your OT&E2 account"); try { // Not implemented in cross-registry API $VerisignModule2 = $Registry2->GetModule(); $params = array('name' => $Domain->GetHostName(), 'pw' => $Domain->AuthCode, 'subproduct' => 'dot' . strtoupper($Domain->Extension)); $Resp = $VerisignModule2->Request('domain-trans-query', $params); $op['ok'] = $Resp->Succeed; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 21. Reject the Transfer using your OT&E2 account // $op = array('title' => "Reject the Transfer using your OT&E2 account"); try { $ok = $Registry2->TransferReject($Domain); $op['ok'] = $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 22. From OT&E2 sync the domain to the 15th day of the next month // $op = array('title' => "From OT&E2 sync the domain to the 15th day of the next month"); try { $m = (int) date('n') + 1; $ok = $VerisignModule2->UpdateDomainConsoliDate($Domain, array('expMonth' => $m, 'expDay' => 15)); $op['ok'] = $ok; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 23. Exit Gracefully from both sessions by issuing the LOGOUT command // $op = array('title' => "Exit Gracefully from both sessions by issuing the LOGOUT command"); try { $VerisignModule->Request('logout', $params = array()); $VerisignModule2->Request('logout', $params = array()); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; $passed = true; foreach ($oplog as $op) { $passed = $passed && $op['ok']; } $out_filename = sprintf('eppdrs-verisign-certtest-%s.log', $passed ? 'passed' : 'failed'); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $out_filename . '"'); foreach ($oplog as $i => $op) { $n = $i + 1; print str_pad("{$n}. {$op['title']}", 100, ' ', STR_PAD_RIGHT); printf("[%s]\n", $op['ok'] ? 'OK' : 'FAIL'); if (!$op['ok']) { print "fail reason: {$op['fail_reason']}\n"; } } print "\n\n"; print file_get_contents($filename); unlink($filename); die; }