diff --git a/tests/Socialbox/SettingsTest.php b/tests/Socialbox/SettingsTest.php
index cb7d3b7..2d31637 100644
--- a/tests/Socialbox/SettingsTest.php
+++ b/tests/Socialbox/SettingsTest.php
@@ -749,9 +749,9 @@
// Testing with maximum allowed lengths (assuming 255 characters is the max)
$maxLengthString = Helper::generateRandomString(255);
+ $this->expectException(RpcException::class);
+ $this->expectExceptionCode(StandardError::RPC_INVALID_ARGUMENTS->value);
$rpcClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, $maxLengthString);
- $this->assertTrue($rpcClient->settingsInformationFieldExists(InformationFieldName::DISPLAY_NAME));
- $this->assertEquals($maxLengthString, $rpcClient->settingsGetInformationField(InformationFieldName::DISPLAY_NAME)->getValue());
}
/**
@@ -849,4 +849,180 @@
$rpcClient->settingsAddInformationField(InformationFieldName::MIDDLE_NAME, $xssAttempt);
$this->assertEquals($xssAttempt, $rpcClient->settingsGetInformationField(InformationFieldName::MIDDLE_NAME)->getValue());
}
+
+ /**
+ * @throws RpcException
+ * @throws DatabaseOperationException
+ * @throws ResolutionException
+ * @throws CryptographyException
+ */
+ public function testNonAuthenticatedSettingsAccess(): void
+ {
+ // Create client but don't authenticate
+ $client = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testNonAuthAccess');
+
+ $this->expectException(RpcException::class);
+ $this->expectExceptionCode(StandardError::METHOD_NOT_ALLOWED->value);
+ $client->addressBookAddContact('johndoeExample@example.com');
+ }
+
+ /**
+ * @throws RpcException
+ * @throws DatabaseOperationException
+ * @throws ResolutionException
+ * @throws CryptographyException
+ * @noinspection HtmlUnknownTarget
+ */
+ public function testCrossSiteScriptingDefense(): void
+ {
+ $client = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'testXssDefense');
+ $this->assertTrue($client->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe'));
+ $this->assertTrue($client->settingsSetPassword('SecretPassword123'));
+ $this->assertTrue($client->getSessionState()->isAuthenticated());
+
+ // Test with more complex XSS payloads
+ $xssPayloads = [
+ '
',
+ '\">',
+ '">',
+ 'javascript:/*-->