Added tests for password deletion and OTP settings in AddressBookTest and SettingsTest
This commit is contained in:
parent
3c151bfd99
commit
df519ad89b
2 changed files with 47 additions and 4 deletions
|
@ -688,12 +688,14 @@
|
||||||
public function testCaseInsensitiveContactAddress(): void
|
public function testCaseInsensitiveContactAddress(): void
|
||||||
{
|
{
|
||||||
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnCaseTest');
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnCaseTest');
|
||||||
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe');
|
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
||||||
$johnClient->settingsSetPassword('SecretTestingPassword123');
|
$this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceCaseTest');
|
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceCaseTest');
|
||||||
$aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith');
|
$this->assertTrue($aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith'));
|
||||||
$aliceClient->settingsSetPassword('SecretTestingPassword123');
|
$this->assertTrue($aliceClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($aliceClient->getSessionState()->isAuthenticated());
|
||||||
$aliceAddress = $aliceClient->getIdentifiedAs();
|
$aliceAddress = $aliceClient->getIdentifiedAs();
|
||||||
$mixedCaseAddress = ucfirst(strtolower($aliceAddress->getUsername())).'@'.strtoupper($aliceAddress->getDomain());
|
$mixedCaseAddress = ucfirst(strtolower($aliceAddress->getUsername())).'@'.strtoupper($aliceAddress->getDomain());
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
use Helper;
|
use Helper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
q use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\PrivacyState;
|
use Socialbox\Enums\PrivacyState;
|
||||||
|
use Socialbox\Enums\SessionState;
|
||||||
use Socialbox\Enums\Types\InformationFieldName;
|
use Socialbox\Enums\Types\InformationFieldName;
|
||||||
use Socialbox\Exceptions\CryptographyException;
|
use Socialbox\Exceptions\CryptographyException;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
@ -512,4 +514,43 @@
|
||||||
$this->assertTrue($aliceResolved->informationFieldExists(InformationFieldName::DISPLAY_NAME));
|
$this->assertTrue($aliceResolved->informationFieldExists(InformationFieldName::DISPLAY_NAME));
|
||||||
$this->assertEquals('Alice Smith', $aliceResolved->getInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
$this->assertEquals('Alice Smith', $aliceResolved->getInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
*/
|
||||||
|
public function testDeleteRequiredPassword(): void
|
||||||
|
{
|
||||||
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'deleteRequiredPassword');
|
||||||
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
||||||
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
|
$this->expectException(RpcException::class);
|
||||||
|
$testClient->settingsDeletePassword();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
*/
|
||||||
|
public function testSettingsSetOtp(): void
|
||||||
|
{
|
||||||
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testSetOtp');
|
||||||
|
$testAddress = $testClient->getIdentifiedAs();
|
||||||
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
||||||
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
||||||
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
||||||
|
|
||||||
|
$secret = $testClient->settingsSetOtp('SecretTestingPassword123');
|
||||||
|
$this->assertNotEmpty($secret);
|
||||||
|
|
||||||
|
$testClient = new SocialClient($testAddress);
|
||||||
|
$this->assertFalse($testClient->getSessionState()->isAuthenticated());
|
||||||
|
$this->assertTrue($testClient->getSessionState()->containsFlag(SessionFlags::VER_OTP));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue