|
|
|
@ -26,7 +26,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldDisplayName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldDisplayName');
|
|
|
|
|
|
|
|
|
|
$displayName = Helper::generateRandomString(32);
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, $displayName);
|
|
|
|
@ -42,7 +42,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidDisplayName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'malformedInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldInvalidDisplayName');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -73,7 +73,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldFirstName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldFirstName');
|
|
|
|
|
|
|
|
|
|
$firstName = Helper::generateRandomString(32);
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, $firstName);
|
|
|
|
@ -89,7 +89,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidFirstName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'malformedInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldInvalidFirstName');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -120,7 +120,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldMiddleName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldMiddleName');
|
|
|
|
|
|
|
|
|
|
$middleName = Helper::generateRandomString(32);
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::MIDDLE_NAME, $middleName);
|
|
|
|
@ -137,7 +137,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidMiddleName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'malformedInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldInvalidMiddleName');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -168,7 +168,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldLastName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldLastName');
|
|
|
|
|
|
|
|
|
|
$lastName = Helper::generateRandomString(32);
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::LAST_NAME, $lastName);
|
|
|
|
@ -184,7 +184,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidLastName(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'malformedInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldInvalidLastName');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -215,7 +215,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldPhoneNumber(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldPhoneNumber');
|
|
|
|
|
|
|
|
|
|
$phoneNumber = sprintf('+%d', Helper::generateRandomNumber(12));
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::PHONE_NUMBER, $phoneNumber);
|
|
|
|
@ -231,7 +231,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidPhoneNumber(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'malformedTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'testInformationFieldInvalidPhoneNumber');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -282,7 +282,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldEmailAddress(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldEmailAddress');
|
|
|
|
|
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::EMAIL_ADDRESS, 'testing@example.com');
|
|
|
|
|
$this->assertTrue($rpcClient->settingsInformationFieldExists(InformationFieldName::EMAIL_ADDRESS));
|
|
|
|
@ -298,7 +298,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidEmailAddress(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'malformedTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'testInformationFieldInvalidEmailAddress');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -344,7 +344,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidUrl(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'malformedTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'testInformationFieldInvalidUrl');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -375,7 +375,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldBirthday(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'validInputTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInformationFieldBirthday');
|
|
|
|
|
|
|
|
|
|
$rpcClient->settingsAddInformationField(InformationFieldName::BIRTHDAY, '2021-01-01');
|
|
|
|
|
$this->assertTrue($rpcClient->settingsInformationFieldExists(InformationFieldName::BIRTHDAY));
|
|
|
|
@ -390,7 +390,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInformationFieldInvalidBirthday(): void
|
|
|
|
|
{
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'malformedTest');
|
|
|
|
|
$rpcClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'testInformationFieldInvalidBirthday');
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -421,7 +421,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidInformationField(): void
|
|
|
|
|
{
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'invalidInformationFieldTest');
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testInvalidInformationField');
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
|
|
|
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
|
|
|
@ -456,7 +456,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testDeleteRequiredInformationField(): void
|
|
|
|
|
{
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'invalidInformationFieldPrivacyTest');
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testDeleteRequiredInformationField');
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
|
|
|
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
|
|
|
@ -473,7 +473,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testDeleteInformationField(): void
|
|
|
|
|
{
|
|
|
|
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnDeleteInformationFieldTest');
|
|
|
|
|
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'testDeleteInformationField');
|
|
|
|
|
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
|
|
|
|
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'John', PrivacyState::PUBLIC));
|
|
|
|
|
$this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
@ -589,7 +589,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testSettingsAddMultipleSigningKeys(): void
|
|
|
|
|
{
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'deleteRequiredPassword');
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testSettingsAddMultipleSigningKeys');
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
|
|
|
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
|
|
|
@ -603,6 +603,32 @@
|
|
|
|
|
$signingKeys[$signatureUuid] = $signingKeypair;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assertCount(20, $testClient->settingsGetSignatures());
|
|
|
|
|
|
|
|
|
|
// Verify all the signatures
|
|
|
|
|
foreach($signingKeys as $signatureUuid => $signingKeypair)
|
|
|
|
|
{
|
|
|
|
|
$signature = $testClient->settingsGetSignature($signatureUuid);
|
|
|
|
|
$this->assertNotNull($signature);
|
|
|
|
|
$this->assertEquals($signingKeypair->getPublicKey(), $signature->getPublicKey());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete the first 5 signatures
|
|
|
|
|
$deletedSignatures = array_slice($signingKeys, 0, 10);
|
|
|
|
|
foreach($deletedSignatures as $signatureUuid => $signingKeypair)
|
|
|
|
|
{
|
|
|
|
|
$this->assertTrue($testClient->settingsDeleteSignature($signatureUuid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify the remaining signatures
|
|
|
|
|
$remainingSignatures = array_slice($signingKeys, 10);
|
|
|
|
|
foreach($remainingSignatures as $signatureUuid => $signingKeypair)
|
|
|
|
|
{
|
|
|
|
|
$signature = $testClient->settingsGetSignature($signatureUuid);
|
|
|
|
|
$this->assertNotNull($signature);
|
|
|
|
|
$this->assertEquals($signingKeypair->getPublicKey(), $signature->getPublicKey());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assertCount(10, $testClient->settingsGetSignatures());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -614,7 +640,7 @@
|
|
|
|
|
*/
|
|
|
|
|
public function testSettingsAddExceedingSigningKeys(): void
|
|
|
|
|
{
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'deleteRequiredPassword');
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testSettingsAddExceedingSigningKeys');
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
|
|
|
|
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
|
|
|
@ -630,4 +656,66 @@
|
|
|
|
|
$signingKeys[$signatureUuid] = $signingKeypair;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws RpcException
|
|
|
|
|
* @throws DatabaseOperationException
|
|
|
|
|
* @throws ResolutionException
|
|
|
|
|
* @throws CryptographyException
|
|
|
|
|
*/
|
|
|
|
|
public function testGetInformationFields(): void
|
|
|
|
|
{
|
|
|
|
|
$testClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testGetInformationFields');
|
|
|
|
|
$phoneNumber = sprintf('+%d', Helper::generateRandomNumber(12));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe', PrivacyState::PUBLIC));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::FIRST_NAME, 'John', PrivacyState::PUBLIC));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::LAST_NAME, 'Doe', PrivacyState::PUBLIC));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::EMAIL_ADDRESS, 'johndoe@example.com', PrivacyState::CONTACTS));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::PHONE_NUMBER, $phoneNumber, PrivacyState::TRUSTED));
|
|
|
|
|
$this->assertTrue($testClient->settingsAddInformationField(InformationFieldName::BIRTHDAY, '1978-16-05', PrivacyState::TRUSTED));
|
|
|
|
|
$this->assertTrue($testClient->settingsSetPassword('SecretTestingPassword123'));
|
|
|
|
|
$this->assertTrue($testClient->getSessionState()->isAuthenticated());
|
|
|
|
|
|
|
|
|
|
$informationFields = $testClient->settingsGetInformationFields();
|
|
|
|
|
$this->assertCount(6, $informationFields);
|
|
|
|
|
|
|
|
|
|
foreach($informationFields as $informationField)
|
|
|
|
|
{
|
|
|
|
|
switch($informationField->getName())
|
|
|
|
|
{
|
|
|
|
|
case InformationFieldName::DISPLAY_NAME:
|
|
|
|
|
$this->assertEquals('John Doe', $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::PUBLIC, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InformationFieldName::FIRST_NAME:
|
|
|
|
|
$this->assertEquals('John', $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::PUBLIC, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InformationFieldName::LAST_NAME:
|
|
|
|
|
$this->assertEquals('Doe', $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::PUBLIC, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InformationFieldName::EMAIL_ADDRESS:
|
|
|
|
|
$this->assertEquals('johndoe@example.com', $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::CONTACTS, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InformationFieldName::PHONE_NUMBER:
|
|
|
|
|
$this->assertEquals($phoneNumber, $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::TRUSTED, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InformationFieldName::BIRTHDAY:
|
|
|
|
|
$this->assertEquals('1978-16-05', $informationField->getValue());
|
|
|
|
|
$this->assertEquals(PrivacyState::TRUSTED, $informationField->getPrivacyState());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
$this->fail(sprintf('Unexpected information field: %s', $informationField->getName()->value));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|