Add tests for invalid address book operations

This commit is contained in:
netkas 2025-03-28 15:04:37 -04:00
parent 9ef2ea64be
commit bbbcfb49f0
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -43,6 +43,24 @@
$this->assertTrue($aliceClient->addressBookContactExists($johnClient->getIdentifiedAs()));
}
/**
* @throws RpcException
* @throws ResolutionException
* @throws CryptographyException
* @throws DatabaseOperationException
*/
public function testAddressBookAddInvalidAddress(): 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);
$this->expectExceptionCode(StandardError::RPC_INVALID_ARGUMENTS->value);
$johnClient->addressBookAddContact('invalid invalid invalid');
}
/**
* @throws ResolutionException
* @throws RpcException
@ -617,6 +635,23 @@
$this->assertFalse($johnClient->addressBookDeleteContact(Helper::generateRandomPeer($johnClient->getIdentifiedAs()->getDomain())));
}
/**
* @throws RpcException
* @throws ResolutionException
* @throws CryptographyException
* @throws DatabaseOperationException
*/
public function testDeleteInvalidContact(): void
{
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
$this->assertTrue($johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe', PrivacyState::PUBLIC));
$this->assertTrue($johnClient->settingsSetPassword('SecretTestingPassword123'));
$this->expectException(RpcException::class);
$this->expectExceptionCode(StandardError::RPC_INVALID_ARGUMENTS->value);
$this->assertFalse($johnClient->addressBookDeleteContact('invalid invalid invalid'));
}
/**
* @throws DatabaseOperationException
* @throws ResolutionException