diff --git a/tests/Socialbox/AddressBookTest.php b/tests/Socialbox/AddressBookTest.php index c21d9b1..0acba21 100644 --- a/tests/Socialbox/AddressBookTest.php +++ b/tests/Socialbox/AddressBookTest.php @@ -688,12 +688,14 @@ public function testCaseInsensitiveContactAddress(): void { $johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnCaseTest'); - $johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'); - $johnClient->settingsSetPassword('SecretTestingPassword123'); + $this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe')); + $this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123')); + $this->assertTrue($johnClient->getSessionState()->isAuthenticated()); $aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceCaseTest'); - $aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith'); - $aliceClient->settingsSetPassword('SecretTestingPassword123'); + $this->assertTrue($aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith')); + $this->assertTrue($aliceClient->settingsSetPassword('SecretTestingPassword123')); + $this->assertTrue($aliceClient->getSessionState()->isAuthenticated()); $aliceAddress = $aliceClient->getIdentifiedAs(); $mixedCaseAddress = ucfirst(strtolower($aliceAddress->getUsername())).'@'.strtoupper($aliceAddress->getDomain()); diff --git a/tests/Socialbox/SettingsTest.php b/tests/Socialbox/SettingsTest.php index 418ae8a..3ea8ac4 100644 --- a/tests/Socialbox/SettingsTest.php +++ b/tests/Socialbox/SettingsTest.php @@ -4,7 +4,9 @@ use Helper; use PHPUnit\Framework\TestCase; +q use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\PrivacyState; + use Socialbox\Enums\SessionState; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\CryptographyException; use Socialbox\Exceptions\DatabaseOperationException; @@ -512,4 +514,43 @@ $this->assertTrue($aliceResolved->informationFieldExists(InformationFieldName::DISPLAY_NAME)); $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)); + } } \ No newline at end of file