diff --git a/php/src/vaas/Message/BaseVerdictRequest.php b/php/src/vaas/Message/BaseVerdictRequest.php index 30b4c738..23ece8be 100644 --- a/php/src/vaas/Message/BaseVerdictRequest.php +++ b/php/src/vaas/Message/BaseVerdictRequest.php @@ -8,8 +8,8 @@ class BaseVerdictRequest extends BaseMessage { public string $guid; public string $session_id; - public bool $UseHashLookup; - public bool $UseCache; + public bool $use_hash_lookup; + public bool $use_cache; public function __construct(kind $kind, string $uuid = null, string $SessionId) { diff --git a/php/src/vaas/Vaas.php b/php/src/vaas/Vaas.php index a6616b6c..ac99a886 100644 --- a/php/src/vaas/Vaas.php +++ b/php/src/vaas/Vaas.php @@ -401,8 +401,8 @@ private function _verdictResponseForSha256(Sha256 $sha256, string $uuid = null): $websocket = $this->_vaasConnection->GetAuthenticatedWebsocket(); $request = new VerdictRequest(strtolower($sha256), $uuid, $this->_vaasConnection->SessionId); - $request->UseCache = $this->_options->UseCache; - $request->UseHashLookup = $this->_options->UseHashLookup; + $request->use_cache = $this->_options->UseCache; + $request->use_hash_lookup = $this->_options->UseHashLookup; $websocket->send(json_encode($request)); if ($this->_logger != null) @@ -427,8 +427,8 @@ private function _verdictResponseForUrl(string $url, string $uuid = null): Verdi $websocket = $this->_vaasConnection->GetAuthenticatedWebsocket(); $request = new VerdictRequestForUrl($url, $uuid, $this->_vaasConnection->SessionId); - $request->UseCache = $this->_options->UseCache; - $request->UseHashLookup = $this->_options->UseHashLookup; + $request->use_cache = $this->_options->UseCache; + $request->use_hash_lookup = $this->_options->UseHashLookup; $websocket->send(json_encode($request)); if ($this->_logger != null) @@ -456,8 +456,8 @@ private function _verdictResponseForStream(string $uuid = null): VerdictResponse $websocket = $this->_vaasConnection->GetAuthenticatedWebsocket(); $request = new VerdictRequestForStream($this->_vaasConnection->SessionId, $uuid); - $request->UseCache = $this->_options->UseCache; - $request->UseHashLookup = $this->_options->UseHashLookup; + $request->use_cache = $this->_options->UseCache; + $request->use_hash_lookup = $this->_options->UseHashLookup; $websocket->send(json_encode($request)); if ($this->_logger != null) diff --git a/php/tests/vaas/ProtocolTest.php b/php/tests/vaas/ProtocolTest.php index fdefe698..439dd664 100644 --- a/php/tests/vaas/ProtocolTest.php +++ b/php/tests/vaas/ProtocolTest.php @@ -57,4 +57,21 @@ public function testForSha256CallBeforeConnection_ThrowsVaasInvalidStateExceptio $vaas = new Vaas("url"); $vaas->ForSha256("000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"); } + + public function testVerdictRequestSerializationTest(): void + { + $verdictRequest = new \VaasSdk\Message\VerdictRequest( + "000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8", + "guid", + "sessionid" + ); + $verdictRequest->use_cache = false; + $verdictRequest->use_hash_lookup = false; + + $string = json_encode($verdictRequest); + $this->assertEquals( + '{"kind":"VerdictRequest","guid":"guid","session_id":"sessionid","use_hash_lookup":false,"use_cache":false,"sha256":"000005c43196142f01d615a67b7da8a53cb0172f8e9317a2ec9a0a39a1da6fe8"}', + $string + ); + } } diff --git a/php/tests/vaas/VaasTest.php b/php/tests/vaas/VaasTest.php index 85139188..61a369e2 100644 --- a/php/tests/vaas/VaasTest.php +++ b/php/tests/vaas/VaasTest.php @@ -64,9 +64,9 @@ public function setUp(): void } } - private function _getVaas(): Vaas + private function _getVaas(bool $useCache = false, bool $useHashLookup = true): Vaas { - return new Vaas($_ENV["VAAS_URL"], $this->_getDebugLogger(), new VaasOptions(false, false)); + return new Vaas($_ENV["VAAS_URL"], $this->_getDebugLogger(), new VaasOptions($useCache, $useHashLookup)); } private function _getDebugLogger(): LoggerInterface