Skip to content

Commit e04f5a1

Browse files
NaktibaldaDavertMik
authored andcommitted
REST::amDigestAuthenticated throws exception if used with functional module (#4653)
1 parent e58ec76 commit e04f5a1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Codeception/Module/REST.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ public function amHttpAuthenticated($username, $password)
287287
*/
288288
public function amDigestAuthenticated($username, $password)
289289
{
290+
if ($this->isFunctional) {
291+
throw new ModuleException(__METHOD__, 'Not supported by functional modules');
292+
}
290293
$this->client->setAuth($username, $password, 'digest');
291294
}
292295

@@ -323,13 +326,13 @@ public function amBearerAuthenticated($accessToken)
323326
public function amNTLMAuthenticated($username, $password)
324327
{
325328
if ($this->isFunctional) {
326-
throw new ModuleException(__METHOD__, 'Out of scope for functional modules.');
329+
throw new ModuleException(__METHOD__, 'Not supported by functional modules');
327330
}
328331
if (!defined('\GuzzleHttp\Client::VERSION')) {
329-
throw new ModuleException(__METHOD__, 'Out of scope if not using a Guzzle client.');
332+
throw new ModuleException(__METHOD__, 'Not supported if not using a Guzzle client');
330333
}
331334
if (version_compare(\GuzzleHttp\Client::VERSION, '6.2.1', 'lt')) {
332-
throw new ModuleException(__METHOD__, 'Guzzle '.\GuzzleHttp\Client::VERSION.' found. Requires Guzzle >=6.3.0 for NTLM auth option.');
335+
throw new ModuleException(__METHOD__, 'Guzzle '.\GuzzleHttp\Client::VERSION.' found. Requires Guzzle >=6.3.0 for NTLM auth option');
333336
}
334337
$this->client->setAuth($username, $password, 'ntlm');
335338
}

tests/unit/Codeception/Module/RestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ public function testDontSeeBinaryResponseEquals()
428428
$this->module->dontSeeBinaryResponseEquals('024f615102cdb3c8c7cf75cdc5a83d15');
429429
}
430430

431+
public function testAmDigestAuthenticatedThrowsExceptionWithFunctionalModules()
432+
{
433+
$this->setExpectedException('\Codeception\Exception\ModuleException', 'Not supported by functional modules');
434+
$this->module->amDigestAuthenticated('username', 'password');
435+
}
436+
431437
protected function shouldFail()
432438
{
433439
$this->setExpectedException('PHPUnit_Framework_AssertionFailedError');

0 commit comments

Comments
 (0)