Example #1
0
        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();
        }
 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();
 }
Example #3
0
 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());
     }
 }
Example #4
0
        function _testContactObject()
        {
        	// CreateContact
        	/*
        	try
        	{
	        	$c = $this->registry->NewContactInstance("registrant");
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov',
	        		'org' 		=> 'MK1O',
	        		'cc' 		=> 'NO',
	        		'sp' 		=> 'crimea',
	        		'city' 		=> 'TRONDHEIM',
	        		'pc' 		=> '7491',
	        		'sp' 		=> 'Crimea',
	        		'street1' 	=> 'bbfdgfd fds',
					'street2' 	=> 'dsf fd d',
	        		'voice' 	=> '+33.12345678',
	        		'fax' 		=> '+33.12345678',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        	}
        	
        	try 
        	{
        		//$this->registry->CreateContact($c);
        		//$this->assertTrue(true, 'Contact created');
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact created');
        		var_dump($e);
        	}
        	
        	try
        	{
	        	$c = $this->registry->NewContactInstance("tech");
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov',
	        		'org' 		=> 'MK1O',
	        		'cc' 		=> 'NO',
	        		'sp' 		=> 'crimea',
	        		'city' 		=> 'TRONDHEIM',
	        		'pc' 		=> '7491',
	        		'sp' 		=> 'Crimea',
	        		'street1' 	=> 'bbfdgfd fds',
					'street2' 	=> 'dsf fd d',
	        		'voice' 	=> '+33.12345678',
	        		'fax' 		=> '+33.12345678',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        	}
        	
        	try 
        	{
        		//$this->registry->CreateContact($c);
        		//$this->assertTrue(true, 'Contact created');
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact created');
        		var_dump($e);
        	}
        	
        	exit();
        	sleep(1);
        	
        	try
        	{
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov2',
	        		'org' 		=> 'MK1O2',
	        		'cc' 		=> 'UA',
	        		'sp' 		=> 'crimea2',
	        		'city' 		=> 'TRONDHEIM2',
	        		'pc' 		=> '74912',
	        		'sp' 		=> 'Crimea2',
	        		'street1' 	=> 'bbfdgfd fds2',
					'street2' 	=> 'dsf fd d2',
	        		'voice' 	=> '+33.123456782',
	        		'fax' 		=> '+33.123456782',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        		exit();
        	}
        	
        	try
        	{
        		//$this->registry->UpdateContact($c);        		
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact updated');
        		var_dump($e->getMessage());
        	}
        	
        	sleep(1);
        	*/
        	$c = DBContact::GetInstance()->LoadByCLID("11390275");
        	
        	try 
        	{
        		$c2 = $this->registry->GetRemoteContact($c);
        		var_dump($c2);
        		$this->assertTrue($c2, 'Remote contact received');
        	} 
        	catch (Exception $e) 
        	{
        		var_dump($e);
        		$this->assertTrue(false, 'remote contact received');
        	}
        		
        	try 
        	{
        		//$this->registry->DeleteContact($c2);
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact deleted');
        		var_dump($e->getMessage());        		
        	}
        }
Example #5
0
        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');
        }
Example #6
0
 function _testModule()
 {
     $Domain = $this->Registry->NewDomainInstance();
     $Domain->Name = 'webta' . rand(1000, 9999);
     ////
     // 1. Check domain
     $Resp = $this->Module->DomainCanBeRegistered($Domain);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Domain available for registration');
     ////
     // 2. Create contact
     $Contact = $this->Registry->NewContactInstanceByGroup('generic');
     $Contact->SetFieldList($this->contact_fields);
     $Resp = $this->Module->CreateContact($Contact);
     $Contact->CLID = $Resp->CLID;
     $this->AssertTrue($Resp->Succeed() && $Resp->CLID, 'Create contact');
     ////
     // 3. Contact info
     $RContact = $this->Registry->NewContactInstanceByGroup('generic');
     $RContact->CLID = $Contact->CLID;
     $RContact = $this->Registry->GetRemoteContact($RContact);
     $rfields = $RContact->GetFieldList();
     $fields = $Contact->GetFieldList();
     $eq = true;
     foreach (array_keys($this->contact_fields) as $k) {
         $eq = $eq && $rfields[$k] == $fields[$k];
     }
     $this->AssertTrue($Resp->Succeed() && $rfields['FirstName'] == $fields['FirstName'] && $rfields['LastName'] == $fields['LastName'], 'Get remote contact');
     ////
     // 4. Create domain
     $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT);
     $Domain->SetContact($Contact, CONTACT_TYPE::BILLING);
     $Domain->SetContact($Contact, CONTACT_TYPE::TECH);
     $Domain->SetContact($Contact, CONTACT_TYPE::ADMIN);
     $Domain->SetNameserverList(array(new Nameserver('ns.hostdad.com'), new Nameserver('ns2.hostdad.com')));
     $period = 3;
     $Resp = $this->Module->CreateDomain($Domain, $period);
     $this->AssertTrue($Resp->CreateDate && date('Ymd', strtotime("+{$period} year")) == date('Ymd', $Resp->ExpireDate), 'Create domain');
     ////
     // 5. Create 2 child nameservers for domain
     $NS1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
     $NS2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
     $Resp = $this->Module->CreateNameserverHost($NS1);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Create subordinate nameserver 1');
     $Resp = $this->Module->CreateNameserverHost($NS2);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Create subordinate nameserver 2');
     ////
     // 6. Assign nameservers to domain
     $Changes = $Domain->GetNameserverChangelist();
     $Changes->Add($NS1);
     $Changes->Add($NS2);
     $Resp = $this->Module->UpdateDomainNameservers($Domain, $Changes);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Update domain nameservers');
     ////
     // 7. Create tech contact and assign it to domain
     $Tech = $this->Registry->NewContactInstanceByGroup('generic');
     $Tech->SetFieldList($this->tech_contact_fields);
     $Resp = $this->Module->CreateContact($Tech);
     $Tech->CLID = $Resp->CLID;
     $Resp = $this->Module->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, null, $Tech);
     ////
     // 8. Lock domain
     $Resp = $this->Module->LockDomain($Domain);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Lock domain');
     ////
     // 9. Perform an INFO command on the domain to verify update
     $RDomain = $this->Registry->NewDomainInstance();
     $RDomain->Name = $Domain->Name;
     $Resp = $this->Module->GetRemoteDomain($RDomain);
     $this->AssertTrue($Resp->TechContact == $Tech->CLID && count($Resp->GetNameserverList()) == 4, 'Perform an INFO command on the domain to verify update');
     $Tech2 = $this->Registry->NewContactInstanceByGroup('generic');
     $Tech2->CLID = $Resp->TechContact;
     $this->Registry->GetRemoteContact($Tech2);
     ////
     // 10. Update one of the name server�s IP Address
     $NS1->IPAddr = gethostbyname('ns.hostdad.com');
     $Resp = $this->Module->UpdateNameserverHost($NS1);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Update one of the name server�s IP Address');
     ////
     // 11. Renew domain for 2 years
     $old_expire_date = $Domain->ExpireDate;
     $period = 2;
     $Resp = $this->Module->RenewDomain($Domain, array('period' => $period));
     $this->AssertTrue(date('Ymd', $Resp->ExpireDate) == date('Ymd', strtotime("+{$period} year", $old_expire_date)), 'Renew domain');
     ////
     // 12. Delete nameservers
     $list = $Domain->GetNameserverList();
     $list[] = $NS1;
     $list[] = $NS2;
     $Changes = new Changelist($list, array());
     //var_dump($Changes->GetList());
     //var_dump($Changes->GetRemoved());
     $Resp = $this->Module->UpdateDomainNameservers($Domain, $Changes);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Remove nameservers from domain');
     ////
     // 13. Delete domain
     $Resp = $this->Module->DeleteDomain($Domain);
     $this->AssertTrue($Resp->Succeed() && $Resp->Result, 'Delete domain');
     ////
     // 14. Delete contact
     $Resp = $this->Module->DeleteContact($Contact);
     $Resp = $this->Module->DeleteContact($Tech);
 }