public function OnDomainCreated (Domain $Domain) { if ($this->once_run) { return; } $this->once_run = true; //// // 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')); $this->Registry->CreateNameserverHost($ns1); $this->Registry->CreateNameserverHost($ns2); $this->TestCase->assertTrue(true, 'Create nameservers'); } catch (Exception $e) { return $this->TestCase->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); $this->Registry->UpdateDomainNameservers($Domain, $nslist); $this->TestCase->assertTrue( count($Domain->GetNameserverList()) == 4, 'Attach nameservers to domain' ); } catch (Exception $e) { return $this->TestCase->fail('Attach nameservers to domain. Error: ' . $e->getMessage()); } //// // Create tech contact // try { $Tech = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH); $Tech->SetFieldList($this->contact_fields); $this->Registry->CreateContact($Tech); $this->TestCase->assertTrue(true, 'Create another contact'); } catch (Exception $e) { return $this->TestCase->fail('Create another contact. Error: ' . $e->getMessage()); } //// // Update domain contact try { $this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, null, $Tech); $this->TestCase->assertTrue(true, 'Attach contact to domain'); } catch (Exception $e) { return $this->TestCase->fail('Attach contact to domain. 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); $this->TestCase->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' ); } catch (Exception $e) { return $this->TestCase->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->TestCase->assertTrue($Resp->Result, 'Update domain nameserver'); } catch (Exception $e) { return $this->TestCase->fail('Update domain nameserver. Error: ' . $e->getMessage()); } //// // 12. Renew Domain for 2 years // /* try { $this->Registry->RenewDomain($Domain, $extra=array('period' => 2)); $this->TestCase->assertFalse(true, 'Domain renewal. Exception expected'); } catch (Exception $e) { $this->TestCase->assertTrue($e->getMessage() == 'A domain can not be renewed earlier that 365 days from its expiration', 'Domain renewal'); } */ // secondary registry $DataForm = new DataForm(); $DataForm->AppendField( new DataFormField("ServerHost", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'https://devepp.ics.forth.gr:700/epp/proxy')); $DataForm->AppendField( new DataFormField("Login", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'digitalbox1')); $DataForm->AppendField( new DataFormField("Password", FORM_FIELD_TYPE::TEXT , null, null, null, null, 'agrigo')); $DataForm->AppendField( new DataFormField("ClientPrefix", FORM_FIELD_TYPE::TEXT, null, null, null, null, '371')); $DataForm->AppendField( new DataFormField("UseSSLCert", FORM_FIELD_TYPE::CHECKBOX, null, null, null, null, '1')); $DataForm->AppendField( new DataFormField("SSLpwd", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'devepp')); $DataForm->AppendField( new DataFormField("CLID", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'digitalbox1')); $DataForm->AppendField( new DataFormField("SSLCertPath", FORM_FIELD_TYPE::TEXT, null, null, null, null, '/home/marat/webdev/epp-drs/branches/dev/app/modules/registries/EPPGR/ssl/cert.pem')); $Module = new EPPGRRegistryModule(); $Module->InitializeModule('gr', $DataForm); $Registry2 = new Registry($Module); try { $ok = $Registry2->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $this->TestCase->assertTrue($ok, 'Request domain transfer from another session'); } catch (Exception $e) { $this->TestCase->fail('Request domain transfer from another session. Error: ' . $e->getMessage()); } //// // 17. Approve the Transfer using your OT&E1 account // try { $ok = $this->Registry->TransferApprove($Domain); $this->TestCase->assertTrue($ok, 'Approve transfer'); } catch (Exception $e) { return $this->TestCase->fail('Approve transfer. Error: ' . $e->getMessage()); } //// // 19. Initiate the Transfer again using your OT&E1 account // try { $ok = $this->Registry->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $this->TestCase->assertTrue($ok, 'Initiate transfer account 1'); } catch (Exception $e) { return $this->TestCase->fail('Initiate tranfer account 1. Error: ' . $e->getMessage()); } //// // 21. Reject the Transfer using your OT&E2 account // try { $ok = $Registry2->TransferReject($Domain); $this->TestCase->assertTrue($ok, 'Reject transfer account 2'); } catch (Exception $e) { return $this->TestCase->fail('Reject transfer account 2. Error: ' . $e->getMessage()); } //// // Remove domain nameservers try { $ns_list = $Domain->GetNameserverList(); $Changes = $Domain->GetNameserverChangelist(); foreach ($ns_list as $NS) { $Changes->Remove($NS); } $Registry2->UpdateDomainNameservers($Domain, $Changes); $this->TestCase->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain'); } catch (Exception $e) { return $this->TestCase->fail('Remove nameservers from domain. Error: ' . $e->getMessage()); } //// // Delete nameservers try { $Registry2->DeleteNameserverHost($ns1); $Registry2->DeleteNameserverHost($ns2); $this->TestCase->assertTrue(true, 'Delete nameservers'); } catch (Exception $e) { return $this->TestCase->fail('Delete nameservers. Error: ' . $e->getMessage()); } //// // Delete domain try { $Registry2->DeleteDomain($Domain); $this->TestCase->assertTrue(true, 'Delete domain'); } catch (Exception $e) { return $this->TestCase->fail('Delete domain. Error: ' . $e->getMessage()); } //// /// Delete contact try { $Registry2->DeleteContact($Tech); $Registry2->DeleteContact($Domain->GetContact(CONTACT_TYPE::REGISTRANT)); $this->TestCase->assertTrue(true, 'Delete contact'); } catch (Exception $e) { return $this->TestCase->fail('Delete contact. Error: ' . $e->getMessage()); } }
/** * 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; }