Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes the flag-usage #397

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions php/src/vaas/Message/BaseVerdictRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 6 additions & 6 deletions php/src/vaas/Vaas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions php/tests/vaas/ProtocolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
4 changes: 2 additions & 2 deletions php/tests/vaas/VaasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading