public function __construct(DataForm $ConnectionConfig) { if (!$ConnectionConfig instanceof DataForm) { throw new Exception(_("ConnectionConfig must be an instance of DataForm")); } foreach ($ConnectionConfig->ListFields() as $field) { $this->{$field->Name} = $field->Value; } }
public function __construct(DataForm $ConnectionConfig) { if (!$ConnectionConfig instanceof DataForm) { throw new Exception(_("ConnectionConfig must be an instance of DataForm")); } foreach ($ConnectionConfig->ListFields() as $field) { $this->{$field->Name} = $field->Value; } $this->ProtocolVersion = '1.1'; $this->Fields7BitSafe = true; $this->GPG = new GnuPG($this->GPGPath, $this->GPGHomeDir); }
public function RunTest(DataForm $DF) { $filename = '/tmp/eppdrs-srsplus-certtest-' . date('YmdHis') . '.log'; Log::RegisterLogger("File", "SRSPLUS", $filename); Log::SetDefaultLogger("SRSPLUS"); $fields = $DF->ListFields(); $conf_fields = $this->Config->ListFields(); $conf_fields['Login']->Value = $fields['Login']->Value; $conf_fields['Email']->Value = $fields['Email']->Value; $conf_fields['Host']->Value = $fields['Host']->Value; $conf_fields['GPGPass']->Value = $fields['GPGPass']->Value; $conf_fields['TestMode']->Value = '1'; $Module = new SRSPlusRegistryModule(new RegistryManifest(MODULES_PATH . "/registries/SRSPlus/module.xml")); $Module->InitializeModule('com', $this->Config); $Registry = new Registry($Module); $oplog = array(); //// // 1. Create contact $op = array('title' => "Create contact"); try { $Contact = $Registry->NewContactInstanceByGroup('generic'); $Contact->SetFieldList(array("firstname" => "Marat", "lastname" => "Komarov", "org" => "Webta", "street1" => "Testing str. 80", "street2" => "Drive 54", "city" => "Testing", "pc" => "90210", "cc" => "US", "sp" => "TX", "voice" => "+333.1234567", "fax" => "+333.1234567", "email" => "*****@*****.**")); $Registry->CreateContact($Contact); $Contact2 = $Registry->NewContactInstanceByGroup('generic'); $Contact2->SetFieldList(array("firstname" => "Marat", "lastname" => "Komarov", "org" => "Webta", "street1" => "Testing str. 80", "street2" => "Drive 54", "city" => "Testing", "pc" => "90210", "cc" => "US", "sp" => "TX", "voice" => "+333.1234567", "fax" => "+333.1234567", "email" => "*****@*****.**")); $Registry->CreateContact($Contact2); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 2. Get remote contact $op = array('title' => 'Get contact'); try { $RContact = $Registry->NewContactInstanceByGroup('generic'); $RContact->CLID = $Contact->CLID; $RContact = $Registry->GetRemoteContact($Contact); $contact_fields = $Contact->GetFieldList(); $rcontact_fields = $RContact->GetFieldList(); $op['ok'] = $contact_fields['first_name'] == $rcontact_fields['first_name'] && $contact_fields['last_name'] == $rcontact_fields['last_name']; if (!$op['ok']) { $op['fail_reason'] = 'Invalid module behavoiur'; } } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 3. Update contact $op = array('title' => 'Edit contact'); try { $contact_fields['email'] = '*****@*****.**'; $contact_fields['voice'] = '+554.233456'; $Contact->SetFieldList($contact_fields); $Registry->UpdateContact($Contact); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 4. Create domain $op = array('title' => 'Create domain'); try { $Domain = $Registry->NewDomainInstance(); $Domain->Name = 'webta' . rand(100, 999); $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT); $Domain->SetContact($Contact2, CONTACT_TYPE::TECH); $period = 1; $Registry->CreateDomain($Domain, $period); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 5. Get remote domain $op = array('title' => 'Whois'); try { $RDomain = $Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $Registry->GetRemoteDomain($RDomain); $op['ok'] = date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate); if (!$ok) { $op['fail_reason'] = 'Invalid module behavoiur'; } } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 6. Renew domain $op = array('title' => 'Renew domain'); try { $old_expire_date = $Domain->ExpireDate; $Registry->RenewDomain($Domain, $extra = array('period' => 1)); $op['ok'] = date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+1 year', $old_expire_date)); if (!$ok) { $op['fail_reason'] = 'Invalid module behavoiur'; } } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 7. Create nameserver host $op = array('title' => 'Create nameserver'); try { $NSHost = new NameserverHost("ns.{$Domain->GetHostName()}", '216.168.229.190'); $Registry->CreateNameserverHost($NSHost); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 8. Delete nameserver $op = array('title' => 'Delete nameserver'); try { $Registry->DeleteNameserverHost($NSHost); $op['ok'] = true; } catch (Exception $e) { $op['ok'] = false; $op['fail_reason'] = $e->getMessage(); } $oplog[] = $op; //// // 9. Delete domain $op = array('title' => 'Delete domain'); try { $Registry->DeleteDomain($Domain); $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-srsplus-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']}", 60, ' ', 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; return; $chk = strlen($contact4->ClID) > 0; $this->assertTrue($chk, "Create billing contact"); //Try to fetch contact info $info = $registry->GetContactInfo($contact1->ClID); $this->assertTrue(is_array($info), "Check Registrant contact ID"); // Try to fetch contact info $info = $registry->GetContactInfo($contact2->ClID); $this->assertTrue(is_array($info), "Check Tech contact ID"); // Try to fetch contact info $info = $registry->GetContactInfo($contact3->ClID); $this->assertTrue(is_array($info), "Check Admin contact ID"); // Try to create domain name //$GRRegistry->SetCurrentTLD("gr"); $domainname = "newwebtatest" . rand(10000, 99999); $domain = $registry->CreateDomain($domainname, $contact1->ClID, $contact2->ClID, $contact3->ClID, $contact4->ClID, "2", array("ns.hostdad.com", "ns2.hostdad.com"), array()); $this->assertTrue(is_array($domain), "Create domain name"); $domainlock = $registry->DomainLock($domainname, 1, array()); $this->assertTrue($domainlock, "Domain locked"); /* $hostav = $registry->CheckHost("ns1.{$domainname}.ws"); if ($hostav == 1) { $hostcr = $registry->CreateHost("ns1.{$domainname}.ws", "66.235.185.21"); $this->assertTrue($hostcr, "Cannot create host 1"); } elseif (!$hostav) { $this->assertTrue($hostav, "Cannot check host 1"); } */ //$d_info = $registry->TransferApprove("webtatestt105", array()); //$d_info = $registry->TransferReject("webtatestt106", array()); //$d_info = $registry->DomainInfo("webtatestt103"); //$this->assertTrue(is_array($d_info), "Cannot get domain info"); /* $c_chk = $registry->CheckContact($contactid); $this->assertTrue($c_chk>0, "Cannot check contact id"); $updNS = $registry->UpdateDomainNS($domainname, array("ns.hostdad.com"), array("ns1.nsys.ws")); $this->assertTrue($updNS, "Cannot update domain NS"); */ //$GRRegistry->SetCurrentTLD("gr"); //$trnsf = $registry->UnCreateDomain("nwebtatest1", array("protocol"=>"5052")); //$this->assertTrue($trnsf, "Cannot approve transfer"); //$req = $registry->CheckTransferStatus("test", "1113383"); //$this->assertTrue($req, "Transfer Status Checked"); // Try to dissconnect $dsk = $registry->Disconnect(); $this->assertTrue($dsk, "Disconnect from EPP Server"); $registry->Disconnect(); //$registry->Disconnect(); }
public function SetUp(DataForm $TestConf) { $test_conf = $TestConf->ListFields(); $ModuleConf = DotSERegistryModule::GetConfigurationForm(); $module_conf = $ModuleConf->ListFields(); $module_conf['ServerHost']->Value = $test_conf['ServerHost']->Value; $module_conf['ServerPort']->Value = $test_conf['ServerPort']->Value; $module_conf['Login']->Value = $test_conf['Login']->Value; $module_conf['Password']->Value = $test_conf['Password']->Value; $this->Module = new DotSERegistryModule(new RegistryManifest(MODULES_PATH . "/registries/DotSE/module.xml")); $this->Module->InitializeModule("se", $ModuleConf); $this->Registry = new Registry($this->Module); $this->Prefix = $test_conf["DomainPrefix"]->Value; $this->ContactCLID = $test_conf["ContactCLID"]->Value; $this->AuthInfo = $test_conf["AuthInfo"]->Value; }