Example #1
0
		function setUp ()
		{
        	// Battle account init
        	
        	$this->registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension("ch");
			
        	return;
			
			
			// Test module init 
			
			$Config = EPPCHRegistryModule::GetConfigurationForm();
        	$fields = $Config->ListFields();
        	/*
        	$fields['Login']->Value = 'TEST-PARTNER-A';
        	//$fields['Password']->Value = 'TEST-PARTNER-A-p';
        	$fields['Password']->Value = 'qwerty123456_';
			*/
        	
        	/*
        	$fields['Login']->Value = 'TEST-PARTNER-B';
        	$fields['Password']->Value = 'epp-test-%2A';
			*/
        	
        	$fields['Login']->Value = 'TEST-PARTNER-C';
        	$fields['Password']->Value = 'epp-test-pwd';
        	
        	
        	$fields['ServerHost']->Value = 'diedomainer.com';
        	$fields['ServerPort']->Value = '7001';
        	
        	$Module = new EPPCHRegistryModule();
        	$Module->InitializeModule('ch', $Config);
        	
        	$this->registry = new Registry($Module);
		}
		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');
		}