Add tests for address book functionality to handle contact addition scenarios
This commit is contained in:
parent
7d13e4acdb
commit
4d2e7ce6e2
1 changed files with 52 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Socialbox\Classes\Cryptography;
|
use Socialbox\Classes\Cryptography;
|
||||||
use Socialbox\Enums\PrivacyState;
|
use Socialbox\Enums\PrivacyState;
|
||||||
|
use Socialbox\Enums\ReservedUsernames;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Enums\Types\ContactRelationshipType;
|
use Socialbox\Enums\Types\ContactRelationshipType;
|
||||||
use Socialbox\Enums\Types\InformationFieldName;
|
use Socialbox\Enums\Types\InformationFieldName;
|
||||||
|
@ -176,6 +177,57 @@
|
||||||
$this->assertEquals('John Test Signature', $johnKnownSigningKeyTest->getName());
|
$this->assertEquals('John Test Signature', $johnKnownSigningKeyTest->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
* @throws RpcException
|
||||||
|
*/
|
||||||
|
public function testAddHostAsContact(): void
|
||||||
|
{
|
||||||
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
|
||||||
|
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
||||||
|
$this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
|
$this->expectException(RpcException::class);
|
||||||
|
$johnClient->addressBookAddContact(sprintf('%s@%s', ReservedUsernames::HOST->value, TEAPOT_DOMAIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
* @throws RpcException
|
||||||
|
*/
|
||||||
|
public function testAddressBookTrustNonExistent(): void
|
||||||
|
{
|
||||||
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
|
||||||
|
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe');
|
||||||
|
$johnClient->settingsSetPassword('SecretTestingPassword123');
|
||||||
|
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
|
$this->expectException(RpcException::class);
|
||||||
|
$johnClient->addressBookUpdateRelationship(sprintf('phonyUser@%s', COFFEE_DOMAIN), ContactRelationshipType::TRUSTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
*/
|
||||||
|
public function testAddSelfAsContact(): void
|
||||||
|
{
|
||||||
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
|
||||||
|
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
||||||
|
$this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
|
$this->expectException(RpcException::class);
|
||||||
|
$johnClient->addressBookAddContact($johnClient->getIdentifiedAs());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DatabaseOperationException
|
* @throws DatabaseOperationException
|
||||||
* @throws ResolutionException
|
* @throws ResolutionException
|
||||||
|
|
Loading…
Add table
Reference in a new issue