Skip to content
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
54 changes: 1 addition & 53 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use BigBlueButton\Enum\ApiMethod;
use BigBlueButton\Enum\HashingAlgorithm;
use BigBlueButton\Exceptions\ConfigException;
use BigBlueButton\Exceptions\NetworkException;
use BigBlueButton\Exceptions\ParsingException;
use BigBlueButton\Exceptions\RuntimeException;
Expand Down Expand Up @@ -77,10 +76,6 @@ class BigBlueButton
public const CONNECTION_ERROR_BASEURL = 1;
public const CONNECTION_ERROR_SECRET = 2;

protected string $securitySecret;

protected string $bbbServerBaseUrl;

protected UrlBuilder $urlBuilder;

protected ?string $jSessionId = null;
Expand All @@ -90,57 +85,10 @@ class BigBlueButton
protected TransportInterface $transport;

/**
* @param string|null $baseUrl (optional) If not given, it will be retrieved from the environment
* @param string|null $secret (optional) If not given, it will be retrieved from the environment
* @param TransportInterface|null $transport (optional) Use a custom transport for all HTTP requests. Will fallback to default CurlTransport.
*
* @throws ConfigException
*/
public function __construct(?string $baseUrl = null, ?string $secret = null, ?TransportInterface $transport = null, protected HashingAlgorithm $hashingAlgorithm = HashingAlgorithm::SHA_1)
public function __construct(protected string $bbbServerBaseUrl, protected string $securitySecret, ?TransportInterface $transport = null, protected HashingAlgorithm $hashingAlgorithm = HashingAlgorithm::SHA_1)
{
if (null === $baseUrl) {
@trigger_error(\sprintf('Constructing "%s" without passing a server base URL is deprecated and will throw an exception 6.0.', self::class), \E_USER_DEPRECATED);
}

if (null === $secret) {
@trigger_error(\sprintf('Constructing "%s" without passing a secret is deprecated and will throw an exception 6.0.', self::class), \E_USER_DEPRECATED);
}

if (getenv('BBB_SECURITY_SALT') !== false || getenv('BBB_SECRET') !== false) {
@trigger_error('Using BBB_SECURITY_SALT or BBB_SECRET environment variables is deprecated for security reasons and will be removed in 6.0. Use the constructor parameters instead.', \E_USER_DEPRECATED);
}

if (getenv('BBB_SERVER_BASE_URL') !== false) {
@trigger_error('Using BBB_SERVER_BASE_URL environment variable is deprecated for security reasons and will be removed in 6.0. Use the constructor parameters instead.', \E_USER_DEPRECATED);
}

// Keeping backward compatibility with older deployed versions
$securitySecret = $secret ?: getenv('BBB_SECURITY_SALT') ?: getenv('BBB_SECRET');

if (false === $securitySecret) {
// @codeCoverageIgnoreStart
@trigger_error(\sprintf('Constructing "%s" without passing a secret is deprecated since 6.0 and will throw an exception in 7.0.', self::class), \E_USER_DEPRECATED);
$this->securitySecret = ''; // previous behaviour
// @codeCoverageIgnoreEnd
} else {
$this->securitySecret = $securitySecret;
}

$bbbServerBaseUrl = $baseUrl ?: getenv('BBB_SERVER_BASE_URL');

if (false === $bbbServerBaseUrl) {
// @codeCoverageIgnoreStart
@trigger_error(\sprintf('Constructing "%s" without passing a server base URL is deprecated since 6.0 and will throw an exception in 7.0.', self::class), \E_USER_DEPRECATED);
$this->bbbServerBaseUrl = ''; // previous behaviour
// @codeCoverageIgnoreEnd
} else {
$this->bbbServerBaseUrl = $bbbServerBaseUrl;
}

if (empty($this->bbbServerBaseUrl)) {
throw new ConfigException('Base url required');
}

$this->urlBuilder = new UrlBuilder($this->securitySecret, $this->bbbServerBaseUrl, $this->hashingAlgorithm);
$this->transport = $transport ?? CurlTransport::createWithDefaultOptions();
}
Expand Down
26 changes: 0 additions & 26 deletions src/Exceptions/ConfigException.php

This file was deleted.

44 changes: 2 additions & 42 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@

namespace BigBlueButton\Parameters;

use BigBlueButton\Core\InlinePresentation;
use BigBlueButton\Core\Presentation;
use BigBlueButton\Core\UrlPresentation;
use BigBlueButton\Enum\Feature;
use BigBlueButton\Enum\GuestPolicy;
use BigBlueButton\Enum\MeetingLayout;
Expand Down Expand Up @@ -253,7 +251,6 @@ final class CreateMeetingParameters extends MetaParameters
protected ?string $pluginManifests = null;
protected ?string $pluginManifestsFetchUrl = null;
protected ?bool $presentationConversionCacheEnabled = null;
protected ?bool $allowOverrideClientSettingsOnCreateCall = null;
protected ?string $clientSettingsOverride = null;
protected ?string $clientSettingsOverrideJsonUrl = null;
protected ?bool $multiUserWhiteboardEnabled = null;
Expand Down Expand Up @@ -363,28 +360,9 @@ public function setGuestPolicyAlwaysAccept(): self
/**
* @return $this
*/
public function addPresentation(string|Presentation $nameOrUrlOrPresentation, ?string $content = null, ?string $filename = null): self
public function addPresentation(Presentation $presentation): self
{
if ($nameOrUrlOrPresentation instanceof Presentation) {
$this->presentations[$nameOrUrlOrPresentation->getArrayKey()] = $nameOrUrlOrPresentation;

return $this;
}

@trigger_error(\sprintf('Calling addPresentation in "%s" with any parameters other than a single Presentation object is deprecated and will throw an exception in 7.0.', self::class), \E_USER_DEPRECATED);

if ($content) {
$presentation = new InlinePresentation($content, $nameOrUrlOrPresentation);
$this->presentations[$presentation->getArrayKey()] = $presentation;
} else {
$presentation = new UrlPresentation($nameOrUrlOrPresentation);

if ($filename != null) {
$presentation->setFilename($filename);
}

$this->presentations[$presentation->getArrayKey()] = $presentation;
}
$this->presentations[$presentation->getArrayKey()] = $presentation;

return $this;
}
Expand All @@ -409,24 +387,6 @@ public function addBreakoutRoomsGroup(string $id, ?string $name, array $roster):
return $this;
}

/**
* @deprecated This is a server-side setting only — it is not read from the create request; will be removed in 7.0.
*/
public function isAllowOverrideClientSettingsOnCreateCall(): ?bool
{
return $this->allowOverrideClientSettingsOnCreateCall;
}

/**
* @deprecated This is a server-side setting only — it is not read from the create request; will be removed in 7.0.
*/
public function setAllowOverrideClientSettingsOnCreateCall(bool $allowOverrideClientSettingsOnCreateCall): self
{
$this->allowOverrideClientSettingsOnCreateCall = $allowOverrideClientSettingsOnCreateCall;

return $this;
}

/** @return array<string,Presentation> */
public function getPresentations(): array
{
Expand Down
23 changes: 1 addition & 22 deletions src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
namespace BigBlueButton\Parameters;

use BigBlueButton\Core\Presentation;
use BigBlueButton\Core\UrlPresentation;
use BigBlueButton\Util\SimpleXMLElementExtended;

/**
Expand All @@ -38,28 +37,8 @@ public function __construct(protected string $meetingID)
{
}

public function addPresentation(string|Presentation $urlOrPresentation, ?string $filename = null, ?bool $downloadable = null, ?bool $removable = null): self
public function addPresentation(Presentation $presentation): self
{
if ($urlOrPresentation instanceof Presentation) {
$this->presentations[$urlOrPresentation->getArrayKey()] = $urlOrPresentation;

return $this;
}

@trigger_error(\sprintf('Calling addPresentation in "%s" with any parameters other than a single Presentation object is deprecated and will throw an exception in 7.0.', self::class), \E_USER_DEPRECATED);

$presentation = new UrlPresentation($urlOrPresentation);

if ($filename !== null) {
$presentation->setFilename($filename);
}
if ($downloadable !== null) {
$presentation->setDownloadable($downloadable);
}
if ($removable !== null) {
$presentation->setRemovable($removable);
}

$this->presentations[$presentation->getArrayKey()] = $presentation;

return $this;
Expand Down
41 changes: 33 additions & 8 deletions tests/functional/BigBlueButtonFunctionalTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
namespace BigBlueButton\Tests\Functional;

use BigBlueButton\BigBlueButton;
use BigBlueButton\Core\InlinePresentation;
use BigBlueButton\Core\UrlPresentation;
use BigBlueButton\Http\Transport\TransportInterface;
use BigBlueButton\Parameters\DeleteRecordingsParameters;
use BigBlueButton\Parameters\EndMeetingParameters;
Expand All @@ -47,11 +49,34 @@ protected function setUp(): void
{
parent::setUp();

$this->bbb = new BigBlueButton(null, null, static::createTransport());
$this->bbb = new BigBlueButton(
$this->getBbbServerBaseUrl(),
$this->getBbbSecret(),
static::createTransport()
);
}

abstract protected static function createTransport(): TransportInterface;

private function getBbbServerBaseUrl(): string
{
$baseUrl = getenv('BBB_SERVER_BASE_URL');

return \is_string($baseUrl) ? $baseUrl : '';
}

private function getBbbSecret(): string
{
$secret = getenv('BBB_SECRET');
if (\is_string($secret) && $secret !== '') {
return $secret;
}

$salt = getenv('BBB_SECURITY_SALT');

return \is_string($salt) ? $salt : '';
}

/* Check Connection */

/**
Expand All @@ -67,15 +92,15 @@ public function testIsConnectionWorking(): void
$this->assertNull($error);

// Check with wrong baseurl and correct secret
$wrong_url_bbb = new BigBlueButton($this->faker->url);
$wrong_url_bbb = new BigBlueButton($this->faker->url, $this->getBbbSecret());
$result = $wrong_url_bbb->isConnectionWorking();
$this->assertFalse($result);
// Check error message
$error = $wrong_url_bbb->getConnectionError();
$this->assertSame(BigBlueButton::CONNECTION_ERROR_BASEURL, $error);

// Check with correct baseurl and wrong secret
$wrong_secret_bbb = new BigBlueButton(null, $this->faker->text);
$wrong_secret_bbb = new BigBlueButton($this->getBbbServerBaseUrl(), $this->faker->text);
$result = $wrong_secret_bbb->isConnectionWorking();
$this->assertFalse($result);
// Check error message
Expand Down Expand Up @@ -117,7 +142,7 @@ public function testCreateMeeting(): void
public function testCreateMeetingWithDocumentUrl(): void
{
$params = $this->getCreateMock($this->generateCreateParams());
$params->addPresentation('https://picsum.photos/3840/2160/?random');
$params->addPresentation(new UrlPresentation('https://picsum.photos/3840/2160/?random'));

$result = $this->bbb->createMeeting($params);

Expand All @@ -135,7 +160,7 @@ public function testCreateMeetingWithDocumentUrl(): void
public function testCreateMeetingWithDocumentUrlAndFileName(): void
{
$params = $this->getCreateMock($this->generateCreateParams());
$params->addPresentation('https://picsum.photos/3840/2160/?random', null, 'placeholder.png');
$params->addPresentation((new UrlPresentation('https://picsum.photos/3840/2160/?random'))->setFilename('placeholder.png'));

$result = $this->bbb->createMeeting($params);

Expand All @@ -157,7 +182,7 @@ public function testCreateMeetingWithDocumentEmbedded(): void
$content = file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png');
$this->assertIsString($content);

$params->addPresentation('bbb_logo.png', $content);
$params->addPresentation(new InlinePresentation($content, 'bbb_logo.png'));

$result = $this->bbb->createMeeting($params);

Expand All @@ -175,12 +200,12 @@ public function testCreateMeetingWithDocumentEmbedded(): void
public function testCreateMeetingWithMultiDocument(): void
{
$params = $this->getCreateMock($this->generateCreateParams());
$params->addPresentation('https://picsum.photos/3840/2160/?random', null, 'presentation.png');
$params->addPresentation((new UrlPresentation('https://picsum.photos/3840/2160/?random'))->setFilename('presentation.png'));

$content = file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png');
$this->assertIsString($content);

$params->addPresentation('logo.png', $content);
$params->addPresentation(new InlinePresentation($content, 'logo.png'));

$result = $this->bbb->createMeeting($params);

Expand Down
22 changes: 4 additions & 18 deletions tests/unit/BigBlueButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
namespace BigBlueButton\Tests\Unit;

use BigBlueButton\BigBlueButton;
use BigBlueButton\Core\UrlPresentation;
use BigBlueButton\Enum\ApiMethod;
use BigBlueButton\Enum\HashingAlgorithm;
use BigBlueButton\Exceptions\ConfigException;
use BigBlueButton\Exceptions\NetworkException;
use BigBlueButton\Exceptions\ParsingException;
use BigBlueButton\Http\Transport\TransportInterface;
Expand Down Expand Up @@ -59,21 +59,7 @@ protected function setUp(): void
parent::setUp();

$this->transport = $this->createMock(TransportInterface::class);
$this->bbb = new BigBlueButton('http://localhost/', null, $this->transport);
}

public function testMissingUrl(): void
{
$this->expectException(ConfigException::class);

$previousEnvironmentValue = getenv('BBB_SERVER_BASE_URL');
putenv('BBB_SERVER_BASE_URL=');

try {
new BigBlueButton('');
} finally {
putenv('BBB_SERVER_BASE_URL='.$previousEnvironmentValue);
}
$this->bbb = new BigBlueButton('http://localhost/', 'S3cr3t', $this->transport);
}

public function testNetworkFailure(): void
Expand Down Expand Up @@ -270,8 +256,8 @@ public function testCreateWithPresentation(): void
{
$createMeetingParams = $this->generateCreateParams();
$params = $this->getCreateMock($createMeetingParams);
$params->addPresentation('http://test-install.blindsidenetworks.com/default.pdf', null, 'presentation.pdf');
$params->addPresentation('http://test-install.blindsidenetworks.com/file.pdf');
$params->addPresentation((new UrlPresentation('http://test-install.blindsidenetworks.com/default.pdf'))->setFilename('presentation.pdf'));
$params->addPresentation(new UrlPresentation('http://test-install.blindsidenetworks.com/file.pdf'));
$params->setClientSettingsOverride('{ "public": { "app": { "appName": "Test" } } }');

$xml = '<response>
Expand Down
Loading
Loading