Skip to content

Commit f1b66be

Browse files
Deprecated password parameters (fixes #142) (#159)
* Deprecated password parameters (fixes #142) * Improved deprecation notices --------- Co-authored-by: Samuel Weirich <4281791+SamuelWei@users.noreply.github.com>
1 parent 27253fc commit f1b66be

8 files changed

Lines changed: 231 additions & 42 deletions

src/Core/Meeting.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,17 @@ public function getDialNumber(): string
213213
return $this->dialNumber;
214214
}
215215

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

224+
/**
225+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
226+
*/
221227
public function getModeratorPassword(): string
222228
{
223229
return $this->moderatorPassword;

src/Parameters/CreateMeetingParameters.php

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
* @method $this setName(string $name)
2727
* @method string getMeetingID()
2828
* @method $this setMeetingID(string $id)
29-
* @method string getAttendeePW()
30-
* @method $this setAttendeePW(string $password)
31-
* @method string getModeratorPW()
32-
* @method $this setModeratorPW(string $password)
3329
* @method string getWelcome()
3430
* @method $this setWelcome(string $welcome)
3531
* @method string getDialNumber()
@@ -134,12 +130,12 @@ class CreateMeetingParameters extends MetaParameters
134130
protected $meetingID;
135131

136132
/**
137-
* @var string
133+
* @var string|null
138134
*/
139135
protected $attendeePW;
140136

141137
/**
142-
* @var string
138+
* @var string|null
143139
*/
144140
protected $moderatorPW;
145141

@@ -543,6 +539,58 @@ public function getPresentationsAsXML()
543539
return $result;
544540
}
545541

542+
/**
543+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
544+
*/
545+
public function getAttendeePW(): string
546+
{
547+
if (null === $this->attendeePW) {
548+
throw new \RuntimeException(sprintf('Attendee password was not passed to "%s".', self::class));
549+
}
550+
551+
return $this->attendeePW;
552+
}
553+
554+
/**
555+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
556+
*
557+
* @return $this
558+
*/
559+
public function setAttendeePW(string $attendeePW): self
560+
{
561+
@trigger_error(sprintf('Passing a attendee password to "%s::setAttendeePW()" is deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the attendee password to create a meeting.', self::class), \E_USER_DEPRECATED);
562+
563+
$this->attendeePW = $attendeePW;
564+
565+
return $this;
566+
}
567+
568+
/**
569+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
570+
*/
571+
public function getModeratorPW(): string
572+
{
573+
if (null === $this->moderatorPW) {
574+
throw new \RuntimeException(sprintf('Moderator password was not passed to "%s".', self::class));
575+
}
576+
577+
return $this->moderatorPW;
578+
}
579+
580+
/**
581+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
582+
*
583+
* @return $this
584+
*/
585+
public function setModeratorPW(string $moderatorPW): self
586+
{
587+
@trigger_error(sprintf('Passing a moderator password to "%s::setModeratorPW()" is deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the moderator password to create a meeting.', self::class), \E_USER_DEPRECATED);
588+
589+
$this->moderatorPW = $moderatorPW;
590+
591+
return $this;
592+
}
593+
546594
public function getHTTPQuery(): string
547595
{
548596
$queries = $this->getHTTPQueryArray();

src/Parameters/EndMeetingParameters.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*
2525
* @method string getMeetingID()
2626
* @method $this setMeetingID(string $id)
27-
* @method string getPassword()
28-
* @method $this setPassword(string $password)
2927
*/
3028
class EndMeetingParameters extends BaseParameters
3129
{
@@ -35,13 +33,41 @@ class EndMeetingParameters extends BaseParameters
3533
protected $meetingID;
3634

3735
/**
38-
* @var string
36+
* @var string|null
3937
*/
4038
protected $password;
4139

42-
public function __construct(string $meetingID, string $password)
40+
public function __construct(string $meetingID, string $password = null)
4341
{
42+
if (\func_num_args() === 2) {
43+
@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 to end a meeting.', self::class), \E_USER_DEPRECATED);
44+
}
45+
4446
$this->password = $password;
4547
$this->meetingID = $meetingID;
4648
}
49+
50+
/**
51+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
52+
*/
53+
public function getPassword(): string
54+
{
55+
if (null === $this->password) {
56+
throw new \RuntimeException(sprintf('Password was not passed to "%s".', self::class));
57+
}
58+
59+
return $this->password;
60+
}
61+
62+
/**
63+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
64+
*
65+
* @return $this
66+
*/
67+
public function setPassword(string $password): self
68+
{
69+
$this->password = $password;
70+
71+
return $this;
72+
}
4773
}

src/Parameters/JoinMeetingParameters.php

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
* @method $this setFullName(string $fullName)
2727
* @method string getMeetingID()
2828
* @method $this setMeetingID(string $id)
29-
* @method string getPassword()
30-
* @method $this setPassword(string $password)
3129
* @method string getCreateTime()
3230
* @method $this setCreateTime(string $createTime)
3331
* @method string getUserID()
@@ -65,7 +63,7 @@ class JoinMeetingParameters extends UserDataParameters
6563
protected $meetingID;
6664

6765
/**
68-
* @var string
66+
* @var string|null
6967
*/
7068
protected $password;
7169

@@ -109,11 +107,6 @@ class JoinMeetingParameters extends UserDataParameters
109107
*/
110108
protected $clientURL;
111109

112-
/**
113-
* @var bool
114-
*/
115-
protected $joinViaHtml5;
116-
117110
/**
118111
* @var bool
119112
*/
@@ -129,23 +122,53 @@ class JoinMeetingParameters extends UserDataParameters
129122
*/
130123
protected $excludeFromDashboard;
131124

132-
public function __construct(string $meetingID, string $fullName, string $password)
125+
public function __construct(string $meetingID, string $fullName, string $password = null)
133126
{
127+
if (\func_num_args() === 3) {
128+
@trigger_error(sprintf('Passing $password parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Use "%s::setRole()" to set the designated role for the joining user instead.', self::class, self::class), \E_USER_DEPRECATED);
129+
}
130+
134131
$this->meetingID = $meetingID;
135132
$this->fullName = $fullName;
136133
$this->password = $password;
137134
}
138135

139136
/**
140-
* @deprecated old flash client parameter, not used anymore
137+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
138+
*/
139+
public function getPassword(): string
140+
{
141+
if (null === $this->password) {
142+
throw new \RuntimeException(sprintf('Password was not passed to "%s".', self::class));
143+
}
144+
145+
return $this->password;
146+
}
147+
148+
/**
149+
* @deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter.
150+
*
151+
* @return $this
152+
*/
153+
public function setPassword(string $password): self
154+
{
155+
$this->password = $password;
156+
157+
return $this;
158+
}
159+
160+
/**
161+
* @deprecated since 5.1 and will be removed in 6.0. Old BigBlueButton flash client parameter.
141162
*/
142163
public function getConfigToken(): ?string
143164
{
144165
return $this->configToken;
145166
}
146167

147168
/**
148-
* @deprecated old flash client parameter, not used anymore
169+
* @deprecated since 5.1 and will be removed in 6.0. Old BigBlueButton flash client parameter.
170+
*
171+
* @return $this
149172
*/
150173
public function setConfigToken(string $configToken): self
151174
{

tests/TestCase.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,7 @@ protected function getCreateMock($params)
160160
{
161161
$createMeetingParams = new CreateMeetingParameters($params['meetingID'], $params['name']);
162162

163-
foreach ($params['groups'] as $group) {
164-
$createMeetingParams->addBreakoutRoomsGroup($group['id'], $group['name'], $group['roster']);
165-
}
166-
167-
return $createMeetingParams->setAttendeePW($params['attendeePW'])
168-
->setModeratorPW($params['moderatorPW'])
169-
->setDialNumber($params['dialNumber'])
163+
$createMeetingParams->setDialNumber($params['dialNumber'])
170164
->setVoiceBridge($params['voiceBridge'])
171165
->setWebVoice($params['webVoice'])
172166
->setLogoutURL($params['logoutURL'])
@@ -213,6 +207,20 @@ protected function getCreateMock($params)
213207
->setAllowRequestsWithoutSession($params['allowRequestsWithoutSession'])
214208
->setVirtualBackgroundsDisabled($params['virtualBackgroundsDisabled'])
215209
->setUserCameraCap($params['userCameraCap']);
210+
211+
if (isset($params['moderatorPW'])) {
212+
$createMeetingParams->setModeratorPW($params['moderatorPW']);
213+
}
214+
215+
if (isset($params['attendeePW'])) {
216+
$createMeetingParams->setAttendeePW($params['attendeePW']);
217+
}
218+
219+
foreach ($params['groups'] as $group) {
220+
$createMeetingParams->addBreakoutRoomsGroup($group['id'], $group['name'], $group['roster']);
221+
}
222+
223+
return $createMeetingParams;
216224
}
217225

218226
/**
@@ -251,7 +259,11 @@ protected function generateJoinMeetingParams()
251259
*/
252260
protected function getJoinMeetingMock($params)
253261
{
254-
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['password']);
262+
if (isset($params['password'])) {
263+
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['password']);
264+
} else {
265+
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName']);
266+
}
255267

256268
return $joinMeetingParams
257269
->setUserID($params['userID'])

tests/unit/Parameters/CreateMeetingParametersTest.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* Class CreateMeetingParametersTest.
2727
*/
28-
class CreateMeetingParametersTest extends TestCase
28+
final class CreateMeetingParametersTest extends TestCase
2929
{
3030
public function testCreateMeetingParameters()
3131
{
@@ -121,7 +121,7 @@ public function testCreateBreakoutMeeting()
121121
$this->assertStringContainsString('freeJoin='.rawurlencode($createBreakoutMeetingParams->isFreeJoin() ? 'true' : 'false'), $params);
122122
}
123123

124-
public function testCreateBreakoutMeetingWithMissingParams()
124+
public function testCreateBreakoutMeetingWithMissingParams(): void
125125
{
126126
$this->expectException(\RuntimeException::class);
127127

@@ -130,39 +130,39 @@ public function testCreateBreakoutMeetingWithMissingParams()
130130
$params->getHTTPQuery();
131131
}
132132

133-
public function testNonExistingProperty()
133+
public function testNonExistingProperty(): void
134134
{
135135
$this->expectException(\BadFunctionCallException::class);
136136

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

141-
public function testWrongMethodName()
141+
public function testWrongMethodName(): void
142142
{
143143
$this->expectException(\BadFunctionCallException::class);
144144

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

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

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

165-
public function testGetPresentationsAsXMLWithFile()
165+
public function testGetPresentationsAsXMLWithFile(): void
166166
{
167167
$params = $this->generateCreateParams();
168168
$createMeetingParams = $this->getCreateMock($params);
@@ -221,4 +221,30 @@ public function testGuestPolicyAskModerator(): void
221221
$this->assertSame(GuestPolicy::ASK_MODERATOR, $createMeetingParams->getGuestPolicy());
222222
$this->assertTrue($createMeetingParams->isGuestPolicyAskModerator());
223223
}
224+
225+
/**
226+
* @group legacy
227+
*/
228+
public function testCreateMeetingParametersWithoutAttendeePassword(): void
229+
{
230+
$params = $this->generateCreateParams();
231+
unset($params['attendeePW']);
232+
$createMeetingParams = $this->getCreateMock($params);
233+
234+
$this->expectException(\RuntimeException::class);
235+
$createMeetingParams->getAttendeePW();
236+
}
237+
238+
/**
239+
* @group legacy
240+
*/
241+
public function testCreateMeetingParametersWithoutModeratorPassword(): void
242+
{
243+
$params = $this->generateCreateParams();
244+
unset($params['moderatorPW']);
245+
$createMeetingParams = $this->getCreateMock($params);
246+
247+
$this->expectException(\RuntimeException::class);
248+
$createMeetingParams->getModeratorPW();
249+
}
224250
}

0 commit comments

Comments
 (0)