Skip to content

Commit

Permalink
Deprecated password parameters (fixes #142)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixJacobi committed Oct 1, 2023
1 parent 7ea8e13 commit 265bb21
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/Core/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,17 @@ public function getDialNumber(): string
return $this->dialNumber;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getAttendeePassword(): string
{
return $this->attendeePassword;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getModeratorPassword(): string
{
return $this->moderatorPassword;
Expand Down
56 changes: 50 additions & 6 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
* @method $this setName(string $name)
* @method string getMeetingID()
* @method $this setMeetingID(string $id)
* @method string getAttendeePW()
* @method $this setAttendeePW(string $password)
* @method string getModeratorPW()
* @method $this setModeratorPW(string $password)
* @method string getWelcome()
* @method $this setWelcome(string $welcome)
* @method string getDialNumber()
Expand Down Expand Up @@ -134,12 +130,12 @@ class CreateMeetingParameters extends MetaParameters
protected $meetingID;

/**
* @var string
* @var string|null
*/
protected $attendeePW;

/**
* @var string
* @var string|null
*/
protected $moderatorPW;

Expand Down Expand Up @@ -520,6 +516,54 @@ public function getPresentationsAsXML()
return $result;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getAttendeePW(): string
{
if (null === $this->attendeePW) {
throw new \RuntimeException(sprintf('Attendee password was not passed to "%s".', self::class));
}

return $this->attendeePW;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*
* @return $this
*/
public function setAttendeePW(string $attendeePW): self
{
$this->attendeePW = $attendeePW;

return $this;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getModeratorPW(): string
{
if (null === $this->moderatorPW) {
throw new \RuntimeException(sprintf('Moderator password was not passed to "%s".', self::class));
}

return $this->moderatorPW;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*
* @return $this
*/
public function setModeratorPW(string $moderatorPW): self
{
$this->moderatorPW = $moderatorPW;

return $this;
}

public function getHTTPQuery(): string
{
$queries = $this->getHTTPQueryArray();
Expand Down
34 changes: 30 additions & 4 deletions src/Parameters/EndMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
*
* @method string getMeetingID()
* @method $this setMeetingID(string $id)
* @method string getPassword()
* @method $this setPassword(string $password)
*/
class EndMeetingParameters extends BaseParameters
{
Expand All @@ -35,13 +33,41 @@ class EndMeetingParameters extends BaseParameters
protected $meetingID;

/**
* @var string
* @var string|null
*/
protected $password;

public function __construct(string $meetingID, string $password)
public function __construct(string $meetingID, string $password = null)
{
if (\func_num_args() === 2) {
@trigger_error(sprintf('Passing $password parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.', self::class), \E_USER_DEPRECATED);
}

$this->password = $password;
$this->meetingID = $meetingID;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getPassword(): string
{
if (null === $this->password) {
throw new \RuntimeException(sprintf('Password was not passed to "%s".', self::class));
}

return $this->password;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*
* @return $this
*/
public function setPassword(string $password): self
{
$this->password = $password;

return $this;
}
}
39 changes: 30 additions & 9 deletions src/Parameters/JoinMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
* @method $this setFullName(string $fullName)
* @method string getMeetingID()
* @method $this setMeetingID(string $id)
* @method string getPassword()
* @method $this setPassword(string $password)
* @method string getCreateTime()
* @method $this setCreateTime(string $createTime)
* @method string getUserID()
Expand Down Expand Up @@ -67,7 +65,7 @@ class JoinMeetingParameters extends UserDataParameters
protected $meetingID;

/**
* @var string
* @var string|null
*/
protected $password;

Expand Down Expand Up @@ -111,11 +109,6 @@ class JoinMeetingParameters extends UserDataParameters
*/
protected $clientURL;

/**
* @var bool
*/
protected $joinViaHtml5;

/**
* @var bool
*/
Expand All @@ -131,10 +124,38 @@ class JoinMeetingParameters extends UserDataParameters
*/
protected $excludeFromDashboard;

public function __construct(string $meetingID, string $fullName, string $password)
public function __construct(string $meetingID, string $fullName, string $password = null)
{
if (\func_num_args() === 3) {
@trigger_error(sprintf('Passing $password parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.', self::class), \E_USER_DEPRECATED);
}

$this->meetingID = $meetingID;
$this->fullName = $fullName;
$this->password = $password;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*/
public function getPassword(): string
{
if (null === $this->password) {
throw new \RuntimeException(sprintf('Password was not passed to "%s".', self::class));
}

return $this->password;
}

/**
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
*
* @return $this
*/
public function setPassword(string $password): self
{
$this->password = $password;

return $this;
}
}
20 changes: 16 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ protected function getCreateMock($params)
{
$createMeetingParams = new CreateMeetingParameters($params['meetingID'], $params['name']);

return $createMeetingParams->setAttendeePW($params['attendeePW'])
->setModeratorPW($params['moderatorPW'])
->setDialNumber($params['dialNumber'])
$createMeetingParams->setDialNumber($params['dialNumber'])
->setVoiceBridge($params['voiceBridge'])
->setWebVoice($params['webVoice'])
->setLogoutURL($params['logoutURL'])
Expand Down Expand Up @@ -194,6 +192,16 @@ protected function getCreateMock($params)
->setAllowRequestsWithoutSession($params['allowRequestsWithoutSession'])
->setVirtualBackgroundsDisabled($params['virtualBackgroundsDisabled'])
->setUserCameraCap($params['userCameraCap']);

if (isset($params['moderatorPW'])) {
$createMeetingParams->setModeratorPW($params['moderatorPW']);
}

if (isset($params['attendeePW'])) {
$createMeetingParams->setAttendeePW($params['attendeePW']);
}

return $createMeetingParams;
}

/**
Expand Down Expand Up @@ -231,7 +239,11 @@ protected function generateJoinMeetingParams()
*/
protected function getJoinMeetingMock($params)
{
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['password']);
if (isset($params['password'])) {
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['password']);
} else {
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName']);
}

return $joinMeetingParams->setUserID($params['userID'])->setWebVoiceConf($params['webVoiceConf'])
->setCreateTime($params['createTime'])->addUserData('countrycode', $params['userdata-countrycode'])
Expand Down
40 changes: 33 additions & 7 deletions tests/unit/Parameters/CreateMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* Class CreateMeetingParametersTest.
*/
class CreateMeetingParametersTest extends TestCase
final class CreateMeetingParametersTest extends TestCase
{
public function testCreateMeetingParameters()
{
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testCreateBreakoutMeeting()
$this->assertStringContainsString('freeJoin='.rawurlencode($createBreakoutMeetingParams->isFreeJoin() ? 'true' : 'false'), $params);
}

public function testCreateBreakoutMeetingWithMissingParams()
public function testCreateBreakoutMeetingWithMissingParams(): void
{
$this->expectException(Warning::class);

Expand All @@ -130,39 +130,39 @@ public function testCreateBreakoutMeetingWithMissingParams()
$params->getHTTPQuery();
}

public function testNonExistingProperty()
public function testNonExistingProperty(): void
{
$this->expectException(\BadFunctionCallException::class);

$params = new CreateMeetingParameters($this->faker->uuid, $this->faker->name);
$params->getFoobar();
}

public function testWrongMethodName()
public function testWrongMethodName(): void
{
$this->expectException(\BadFunctionCallException::class);

$params = new CreateMeetingParameters($this->faker->uuid, $this->faker->name);
$params->getname();
}

public function testGetPresentationsAsXMLWithUrl()
public function testGetPresentationsAsXMLWithUrl(): void
{
$params = $this->generateCreateParams();
$createMeetingParams = $this->getCreateMock($params);
$createMeetingParams->addPresentation('http://test-install.blindsidenetworks.com/default.pdf');
$this->assertXmlStringEqualsXmlFile(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'presentation_with_url.xml', $createMeetingParams->getPresentationsAsXML());
}

public function testGetPresentationsAsXMLWithUrlAndFilename()
public function testGetPresentationsAsXMLWithUrlAndFilename(): void
{
$params = $this->generateCreateParams();
$createMeetingParams = $this->getCreateMock($params);
$createMeetingParams->addPresentation('http://test-install.blindsidenetworks.com/default.pdf', null, 'presentation.pdf');
$this->assertXmlStringEqualsXmlFile(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'presentation_with_filename.xml', $createMeetingParams->getPresentationsAsXML());
}

public function testGetPresentationsAsXMLWithFile()
public function testGetPresentationsAsXMLWithFile(): void
{
$params = $this->generateCreateParams();
$createMeetingParams = $this->getCreateMock($params);
Expand Down Expand Up @@ -221,4 +221,30 @@ public function testGuestPolicyAskModerator(): void
$this->assertSame(GuestPolicy::ASK_MODERATOR, $createMeetingParams->getGuestPolicy());
$this->assertTrue($createMeetingParams->isGuestPolicyAskModerator());
}

/**
* @group legacy
*/
public function testCreateMeetingParametersWithoutAttendeePassword(): void
{
$params = $this->generateCreateParams();
unset($params['attendeePW']);
$createMeetingParams = $this->getCreateMock($params);

$this->expectException(\RuntimeException::class);
$createMeetingParams->getAttendeePW();
}

/**
* @group legacy
*/
public function testCreateMeetingParametersWithoutModeratorPassword(): void
{
$params = $this->generateCreateParams();
unset($params['moderatorPW']);
$createMeetingParams = $this->getCreateMock($params);

$this->expectException(\RuntimeException::class);
$createMeetingParams->getModeratorPW();
}
}
27 changes: 25 additions & 2 deletions tests/unit/Parameters/EndMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

use BigBlueButton\TestCase;

class EndMeetingParametersTest extends TestCase
final class EndMeetingParametersTest extends TestCase
{
public function testEndMeetingParameters()
public function testEndMeetingParameters(): void
{
$endMeetingParams = new EndMeetingParameters($meetingId = $this->faker->uuid, $password = $this->faker->password());

Expand All @@ -36,4 +36,27 @@ public function testEndMeetingParameters()
$this->assertEquals($newId, $endMeetingParams->getMeetingID());
$this->assertEquals($newPassword, $endMeetingParams->getPassword());
}

/**
* @group legacy
*/
public function testEndMeetingParametersWithoutPassword(): void
{
$endMeetingParams = new EndMeetingParameters($this->faker->uuid);

$this->expectException(\RuntimeException::class);

$endMeetingParams->getPassword();
}

/**
* @group legacy
*/
public function testEndMeetingParametersWithSetPassword(): void
{
$endMeetingParams = new EndMeetingParameters($this->faker->uuid);

$endMeetingParams->setPassword($password = $this->faker->password);
$this->assertSame($password, $endMeetingParams->getPassword());
}
}
Loading

0 comments on commit 265bb21

Please sign in to comment.