Moved test case testPeerResolution to SocialClientTest
This commit is contained in:
parent
4cce8bf91b
commit
a8acda8155
2 changed files with 80 additions and 74 deletions
|
@ -58,80 +58,6 @@
|
||||||
$this->assertTrue($rpcClient->getSessionState()->isAuthenticated());
|
$this->assertTrue($rpcClient->getSessionState()->isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws RpcException
|
|
||||||
* @throws ResolutionException
|
|
||||||
* @throws CryptographyException
|
|
||||||
* @throws DatabaseOperationException
|
|
||||||
*/
|
|
||||||
public function testPeerResolution(): void
|
|
||||||
{
|
|
||||||
$johnClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'johnDoe');
|
|
||||||
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Test User');
|
|
||||||
$this->assertEquals('Test User', $johnClient->settingsGetInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
|
||||||
$johnClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'John');
|
|
||||||
$this->assertEquals('John', $johnClient->settingsGetInformationField(InformationFieldName::FIRST_NAME)->getValue());
|
|
||||||
$johnClient->settingsAddInformationField(InformationFieldName::LAST_NAME, 'Doe');
|
|
||||||
$this->assertEquals('Doe', $johnClient->settingsGetInformationField(InformationFieldName::LAST_NAME)->getValue());
|
|
||||||
$johnClient->settingsSetPassword('SecuredTestingPassword123');
|
|
||||||
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
|
||||||
$this->assertFalse($johnClient->getSessionState()->containsFlag(SessionFlags::REGISTRATION_REQUIRED));
|
|
||||||
$this->assertFalse($johnClient->getSessionState()->containsFlag(SessionFlags::AUTHENTICATION_REQUIRED));
|
|
||||||
|
|
||||||
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceSmith');
|
|
||||||
$aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Test User');
|
|
||||||
$this->assertEquals('Test User', $aliceClient->settingsGetInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
|
||||||
$aliceClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'Alice');
|
|
||||||
$this->assertEquals('Alice', $aliceClient->settingsGetInformationField(InformationFieldName::FIRST_NAME)->getValue());
|
|
||||||
$aliceClient->settingsAddInformationField(InformationFieldName::LAST_NAME, 'Smith');
|
|
||||||
$this->assertEquals('Smith', $aliceClient->settingsGetInformationField(InformationFieldName::LAST_NAME)->getValue());
|
|
||||||
$aliceClient->settingsSetPassword('SecuredTestingPassword123');
|
|
||||||
$this->assertTrue($aliceClient->getSessionState()->isAuthenticated());
|
|
||||||
$this->assertFalse($aliceClient->getSessionState()->containsFlag(SessionFlags::REGISTRATION_REQUIRED));
|
|
||||||
$this->assertFalse($aliceClient->getSessionState()->containsFlag(SessionFlags::AUTHENTICATION_REQUIRED));
|
|
||||||
|
|
||||||
$aliceResolved = $aliceClient->resolvePeer($aliceClient->getSelf()->getPeerAddress());
|
|
||||||
foreach($aliceResolved->getInformationFields() as $informationField)
|
|
||||||
{
|
|
||||||
switch($informationField->getName())
|
|
||||||
{
|
|
||||||
case InformationFieldName::DISPLAY_NAME:
|
|
||||||
$this->assertEquals('Test User', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
case InformationFieldName::FIRST_NAME:
|
|
||||||
$this->assertEquals('Alice', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
case InformationFieldName::LAST_NAME:
|
|
||||||
$this->assertEquals('Smith', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->fail('Unexpected information field: ' . $informationField->getName()->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$johnResolved = $aliceClient->resolvePeer($johnClient->getSelf()->getPeerAddress());
|
|
||||||
foreach($johnResolved->getInformationFields() as $informationField)
|
|
||||||
{
|
|
||||||
switch($informationField->getName())
|
|
||||||
{
|
|
||||||
case InformationFieldName::DISPLAY_NAME:
|
|
||||||
$this->assertEquals('Test User', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
case InformationFieldName::FIRST_NAME:
|
|
||||||
$this->assertEquals('John', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
case InformationFieldName::LAST_NAME:
|
|
||||||
$this->assertEquals('Doe', $informationField->getValue());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->fail('Unexpected information field: ' . $informationField->getName()->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($johnClient->getSelf()->getPeerAddress(), $johnResolved->getPeerAddress());
|
|
||||||
$this->assertEquals($aliceClient->getSelf()->getPeerAddress(), $aliceResolved->getPeerAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ResolutionException
|
* @throws ResolutionException
|
||||||
* @throws RpcException
|
* @throws RpcException
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
use Exception;
|
use Exception;
|
||||||
use Helper;
|
use Helper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
|
use Socialbox\Enums\Types\InformationFieldName;
|
||||||
|
use Socialbox\Exceptions\CryptographyException;
|
||||||
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
use Socialbox\Exceptions\ResolutionException;
|
||||||
|
use Socialbox\Exceptions\RpcException;
|
||||||
|
|
||||||
class SocialClientTest extends TestCase
|
class SocialClientTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -34,4 +40,78 @@
|
||||||
$this->fail('Failed to create RPC client: ' . $e->getMessage());
|
$this->fail('Failed to create RPC client: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
*/
|
||||||
|
public function testPeerResolution(): void
|
||||||
|
{
|
||||||
|
$johnClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'johnDoe');
|
||||||
|
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Test User');
|
||||||
|
$this->assertEquals('Test User', $johnClient->settingsGetInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
||||||
|
$johnClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'John');
|
||||||
|
$this->assertEquals('John', $johnClient->settingsGetInformationField(InformationFieldName::FIRST_NAME)->getValue());
|
||||||
|
$johnClient->settingsAddInformationField(InformationFieldName::LAST_NAME, 'Doe');
|
||||||
|
$this->assertEquals('Doe', $johnClient->settingsGetInformationField(InformationFieldName::LAST_NAME)->getValue());
|
||||||
|
$johnClient->settingsSetPassword('SecuredTestingPassword123');
|
||||||
|
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
||||||
|
$this->assertFalse($johnClient->getSessionState()->containsFlag(SessionFlags::REGISTRATION_REQUIRED));
|
||||||
|
$this->assertFalse($johnClient->getSessionState()->containsFlag(SessionFlags::AUTHENTICATION_REQUIRED));
|
||||||
|
|
||||||
|
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceSmith');
|
||||||
|
$aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Test User');
|
||||||
|
$this->assertEquals('Test User', $aliceClient->settingsGetInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
||||||
|
$aliceClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'Alice');
|
||||||
|
$this->assertEquals('Alice', $aliceClient->settingsGetInformationField(InformationFieldName::FIRST_NAME)->getValue());
|
||||||
|
$aliceClient->settingsAddInformationField(InformationFieldName::LAST_NAME, 'Smith');
|
||||||
|
$this->assertEquals('Smith', $aliceClient->settingsGetInformationField(InformationFieldName::LAST_NAME)->getValue());
|
||||||
|
$aliceClient->settingsSetPassword('SecuredTestingPassword123');
|
||||||
|
$this->assertTrue($aliceClient->getSessionState()->isAuthenticated());
|
||||||
|
$this->assertFalse($aliceClient->getSessionState()->containsFlag(SessionFlags::REGISTRATION_REQUIRED));
|
||||||
|
$this->assertFalse($aliceClient->getSessionState()->containsFlag(SessionFlags::AUTHENTICATION_REQUIRED));
|
||||||
|
|
||||||
|
$aliceResolved = $aliceClient->resolvePeer($aliceClient->getSelf()->getPeerAddress());
|
||||||
|
foreach($aliceResolved->getInformationFields() as $informationField)
|
||||||
|
{
|
||||||
|
switch($informationField->getName())
|
||||||
|
{
|
||||||
|
case InformationFieldName::DISPLAY_NAME:
|
||||||
|
$this->assertEquals('Test User', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
case InformationFieldName::FIRST_NAME:
|
||||||
|
$this->assertEquals('Alice', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
case InformationFieldName::LAST_NAME:
|
||||||
|
$this->assertEquals('Smith', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->fail('Unexpected information field: ' . $informationField->getName()->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$johnResolved = $aliceClient->resolvePeer($johnClient->getSelf()->getPeerAddress());
|
||||||
|
foreach($johnResolved->getInformationFields() as $informationField)
|
||||||
|
{
|
||||||
|
switch($informationField->getName())
|
||||||
|
{
|
||||||
|
case InformationFieldName::DISPLAY_NAME:
|
||||||
|
$this->assertEquals('Test User', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
case InformationFieldName::FIRST_NAME:
|
||||||
|
$this->assertEquals('John', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
case InformationFieldName::LAST_NAME:
|
||||||
|
$this->assertEquals('Doe', $informationField->getValue());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->fail('Unexpected information field: ' . $informationField->getName()->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($johnClient->getSelf()->getPeerAddress(), $johnResolved->getPeerAddress());
|
||||||
|
$this->assertEquals($aliceClient->getSelf()->getPeerAddress(), $aliceResolved->getPeerAddress());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue