forked from oroinc/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/dev/master'
- Loading branch information
Showing
19 changed files
with
642 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Oro/Bundle/DataAuditBundle/Tests/Behat/Features/dataaudit_labels_are_translates.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@ticket-BAP-17600 | ||
@fixture-OroUserBundle:user.yml | ||
Feature: DataAudit labels are translated | ||
In order to get information about changed entity fields | ||
As a Admin user | ||
I need to be able to see entity labels translated in data audit grid | ||
|
||
Scenario: | ||
Given I login as administrator | ||
And I go to System/User Management/Users | ||
And I click "Edit" on row "Charlie" in grid | ||
And I fill form with: | ||
| Username | charlie-up | | ||
| First Name | FNUP | | ||
| Last Name | LNUP | | ||
| Primary Email | email-up@test.com | | ||
And save and close form | ||
When I go to System/ Data Audit | ||
Then I should see "Username:" in grid | ||
And I should see "First Name:" in grid | ||
And I should see "Last Name:" in grid | ||
And I should see "Primary Email:" in grid |
23 changes: 0 additions & 23 deletions
23
src/Oro/Bundle/SyncBundle/Client/Factory/GosClientFactory.php
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/Oro/Bundle/SyncBundle/Client/Factory/GosClientFactoryInterface.php
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
src/Oro/Bundle/SyncBundle/Client/Wamp/Factory/ClientAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory; | ||
|
||
/** | ||
* This class represents connection attributes which will be used to create an instance of WampClient. | ||
*/ | ||
class ClientAttributes | ||
{ | ||
/** @var string */ | ||
private $host; | ||
|
||
/** @var int */ | ||
private $port; | ||
|
||
/** @var string */ | ||
private $path; | ||
|
||
/** | ||
* Any registered socket transport returned by http://php.net/manual/en/function.stream-get-transports.php | ||
* | ||
* @var string | ||
*/ | ||
private $transport; | ||
|
||
/** | ||
* Will be passed to a context create function http://php.net/manual/en/function.stream-context-create.php | ||
* | ||
* @var array | ||
*/ | ||
private $contextOptions; | ||
|
||
/** | ||
* @param string $host | ||
* @param int $port | ||
* @param string $path | ||
* @param string $transport | ||
* @param array $contextOptions | ||
*/ | ||
public function __construct( | ||
string $host, | ||
int $port, | ||
string $path, | ||
string $transport, | ||
array $contextOptions | ||
) { | ||
if ($host === '*') { | ||
$host = '127.0.0.1'; | ||
} | ||
|
||
$this->host = $host; | ||
$this->port = $port; | ||
$this->path = $path; | ||
$this->transport = $transport; | ||
$this->contextOptions = $contextOptions; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getHost(): string | ||
{ | ||
return $this->host; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPort(): int | ||
{ | ||
return $this->port; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPath(): string | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTransport(): string | ||
{ | ||
return $this->transport; | ||
} | ||
|
||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getContextOptions(): array | ||
{ | ||
return $this->contextOptions; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Oro/Bundle/SyncBundle/Client/Wamp/Factory/WampClientFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory; | ||
|
||
use Oro\Bundle\SyncBundle\Client\Wamp\WampClient; | ||
|
||
/** | ||
* Creates websocket server client. | ||
*/ | ||
class WampClientFactory implements WampClientFactoryInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createClient(ClientAttributes $clientAttributes): WampClient | ||
{ | ||
$options = $clientAttributes->getContextOptions(); | ||
|
||
return new WampClient( | ||
$clientAttributes->getHost(), | ||
$clientAttributes->getPort(), | ||
$clientAttributes->getTransport(), | ||
$options ? ['ssl' => $options] : [], | ||
// We don't have to check origin when connecting from backend. | ||
'127.0.0.1' | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Oro/Bundle/SyncBundle/Client/Wamp/Factory/WampClientFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory; | ||
|
||
use Oro\Bundle\SyncBundle\Client\Wamp\WampClient; | ||
|
||
/** | ||
* Interface for websocket server client factories. | ||
*/ | ||
interface WampClientFactoryInterface | ||
{ | ||
/** | ||
* @param ClientAttributes $clientAttributes | ||
* | ||
* @return WampClient | ||
*/ | ||
public function createClient(ClientAttributes $clientAttributes): WampClient; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\SyncBundle\Client\Wamp; | ||
|
||
use Gos\Component\WebSocketClient\Exception\BadResponseException; | ||
use Gos\Component\WebSocketClient\Wamp\Client as GosClient; | ||
use Gos\Component\WebSocketClient\Wamp\Protocol; | ||
|
||
/** | ||
* Overrides GosClient to add the ability to set socket transport and context options. | ||
*/ | ||
class WampClient extends GosClient | ||
{ | ||
/** | ||
* Will be passed to a context create function http://php.net/manual/en/function.stream-context-create.php | ||
* | ||
* @var array | ||
*/ | ||
private $contextOptions; | ||
|
||
/** | ||
* @param string $host | ||
* @param int $port | ||
* @param string $transport | ||
* @param array $contextOptions | ||
* @param string|null $origin | ||
*/ | ||
public function __construct( | ||
string $host, | ||
int $port, | ||
string $transport, | ||
array $contextOptions = [], | ||
?string $origin = null | ||
) { | ||
$secured = $this->isSecured($transport); | ||
|
||
parent::__construct($host, $port, $secured, $origin); | ||
|
||
$this->contextOptions = $contextOptions; | ||
$this->endpoint = "{$transport}://{$host}:{$port}"; | ||
} | ||
|
||
/** | ||
* Overrides parent method to add ability to set socket context. | ||
* | ||
* {@inheritdoc} | ||
*/ | ||
public function connect($target = '/') | ||
{ | ||
$this->target = '/' . ltrim($target, '/'); | ||
|
||
if ($this->connected) { | ||
return $this->sessionId; | ||
} | ||
|
||
$this->socket = $this->openSocket(); | ||
|
||
$response = $this->upgradeProtocol($this->target); | ||
|
||
$this->verifyResponse($response); | ||
|
||
$payload = json_decode($this->read()); | ||
|
||
if ((int)$payload[0] !== Protocol::MSG_WELCOME) { | ||
throw new BadResponseException('WAMP Server did not send welcome message.'); | ||
} | ||
|
||
$this->sessionId = $payload[1]; | ||
|
||
$this->connected = true; | ||
|
||
return $this->sessionId; | ||
} | ||
|
||
/** | ||
* @param string $transport | ||
* | ||
* @return bool | ||
* | ||
* @extensionPoint to change the logic of websocket protocol detection. | ||
*/ | ||
protected function isSecured(string $transport): bool | ||
{ | ||
return $transport === 'ssl' || stripos($transport, 'tls') === 0; | ||
} | ||
|
||
/** | ||
* @return resource | ||
* | ||
* @throws BadResponseException | ||
* | ||
* @extensionPoint to change the logic of socket creation. | ||
*/ | ||
protected function openSocket() | ||
{ | ||
$socket = @stream_socket_client( | ||
$this->endpoint, | ||
$errno, | ||
$errstr, | ||
1, | ||
STREAM_CLIENT_CONNECT, | ||
stream_context_create($this->contextOptions) | ||
); | ||
|
||
if (!$socket) { | ||
throw new BadResponseException('Could not open socket. Reason: ' . $errstr); | ||
} | ||
|
||
return $socket; | ||
} | ||
} |
Oops, something went wrong.