Add tests for adding multiple and exceeding signing keys in SettingsTest
Some checks are pending
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release (push) Waiting to run
Some checks are pending
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release (push) Waiting to run
This commit is contained in:
parent
d140c861a0
commit
22629f9b30
1 changed files with 52 additions and 0 deletions
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
use Helper;
|
use Helper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Socialbox\Classes\Cryptography;
|
||||||
use Socialbox\Classes\OtpCryptography;
|
use Socialbox\Classes\OtpCryptography;
|
||||||
use Socialbox\Enums\Flags\SessionFlags;
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\PrivacyState;
|
use Socialbox\Enums\PrivacyState;
|
||||||
|
use Socialbox\Enums\StandardError;
|
||||||
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;
|
||||||
|
@ -578,4 +580,54 @@
|
||||||
// Verify the OTP
|
// Verify the OTP
|
||||||
$this->assertTrue($testClient->verificationOtpAuthentication($otp));
|
$this->assertTrue($testClient->verificationOtpAuthentication($otp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
*/
|
||||||
|
public function testSettingsAddMultipleSigningKeys(): 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());
|
||||||
|
|
||||||
|
$signingKeys = [];
|
||||||
|
for($i = 0; $i < 20; $i++)
|
||||||
|
{
|
||||||
|
$signingKeypair = Cryptography::generateSigningKeyPair();
|
||||||
|
$signatureUuid = $testClient->settingsAddSignature($signingKeypair->getPublicKey());
|
||||||
|
$this->assertNotNull($signatureUuid);
|
||||||
|
$signingKeys[$signatureUuid] = $signingKeypair;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertCount(10, $testClient->settingsGetSignatures());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RpcException
|
||||||
|
* @throws DatabaseOperationException
|
||||||
|
* @throws ResolutionException
|
||||||
|
* @throws CryptographyException
|
||||||
|
*/
|
||||||
|
public function testSettingsAddExceedingSigningKeys(): 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());
|
||||||
|
|
||||||
|
$signingKeys = [];
|
||||||
|
$this->expectException(RpcException::class);
|
||||||
|
$this->expectExceptionCode(StandardError::FORBIDDEN->value);
|
||||||
|
for($i = 0; $i < 25; $i++)
|
||||||
|
{
|
||||||
|
$signingKeypair = Cryptography::generateSigningKeyPair();
|
||||||
|
$signatureUuid = $testClient->settingsAddSignature($signingKeypair->getPublicKey());
|
||||||
|
$this->assertNotNull($signatureUuid);
|
||||||
|
$signingKeys[$signatureUuid] = $signingKeypair;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue