diff --git a/src/Guzzle/AuthenticatorSubscriber.php b/src/Guzzle/AuthenticatorSubscriber.php index 080512736..c7a3b1083 100644 --- a/src/Guzzle/AuthenticatorSubscriber.php +++ b/src/Guzzle/AuthenticatorSubscriber.php @@ -9,7 +9,7 @@ use GuzzleHttp\Message\RequestInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Wallabag\SiteConfig\Authenticator\Authenticator; +use Wallabag\SiteConfig\Authenticator\LoginFormAuthenticator; use Wallabag\SiteConfig\SiteConfig; use Wallabag\SiteConfig\SiteConfigBuilder; @@ -23,7 +23,7 @@ class AuthenticatorSubscriber implements SubscriberInterface, LoggerAwareInterfa /** @var SiteConfigBuilder */ private $configBuilder; - /** @var Authenticator */ + /** @var LoginFormAuthenticator */ private $authenticator; /** @var LoggerInterface */ @@ -32,7 +32,7 @@ class AuthenticatorSubscriber implements SubscriberInterface, LoggerAwareInterfa /** * AuthenticatorSubscriber constructor. */ - public function __construct(SiteConfigBuilder $configBuilder, Authenticator $authenticator) + public function __construct(SiteConfigBuilder $configBuilder, LoginFormAuthenticator $authenticator) { $this->configBuilder = $configBuilder; $this->authenticator = $authenticator; diff --git a/src/SiteConfig/Authenticator/Authenticator.php b/src/SiteConfig/Authenticator/Authenticator.php deleted file mode 100644 index 9623e39ab..000000000 --- a/src/SiteConfig/Authenticator/Authenticator.php +++ /dev/null @@ -1,32 +0,0 @@ -getDefaultOption('cookies')) instanceof CookieJar) { @@ -41,6 +51,13 @@ class LoginFormAuthenticator implements Authenticator return false; } + /** + * Checks from the HTML of a page if authentication is requested by a grabbed page. + * + * @param string $html + * + * @return bool + */ public function isLoginRequired(SiteConfig $siteConfig, $html) { // need to check for the login dom element ($options['not_logged_in_xpath']) in the HTML diff --git a/tests/Guzzle/AuthenticatorSubscriberTest.php b/tests/Guzzle/AuthenticatorSubscriberTest.php index 76cfadf32..8b1319c37 100644 --- a/tests/Guzzle/AuthenticatorSubscriberTest.php +++ b/tests/Guzzle/AuthenticatorSubscriberTest.php @@ -14,13 +14,13 @@ use Monolog\Logger; use PHPUnit\Framework\TestCase; use Wallabag\Guzzle\AuthenticatorSubscriber; use Wallabag\SiteConfig\ArraySiteConfigBuilder; -use Wallabag\SiteConfig\Authenticator\Authenticator; +use Wallabag\SiteConfig\Authenticator\LoginFormAuthenticator; class AuthenticatorSubscriberTest extends TestCase { public function testGetEvents() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -38,7 +38,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequiredNotRequired() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -71,7 +71,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequiredWithNotLoggedInUser() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -123,7 +123,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequestedNotRequired() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -156,7 +156,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequestedNotRequested() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -205,7 +205,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequestedRequested() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock(); @@ -263,7 +263,7 @@ class AuthenticatorSubscriberTest extends TestCase public function testLoginIfRequestedRedirect() { - $authenticator = $this->getMockBuilder(Authenticator::class) + $authenticator = $this->getMockBuilder(LoginFormAuthenticator::class) ->disableOriginalConstructor() ->getMock();