diff --git a/.travis.yml b/.travis.yml index 3af172bab..f3d786d6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,21 +20,12 @@ matrix: dist: trusty env: LARAVEL='5.4.*' XDEBUG=1 group: edge - - php: 5.5.9 - dist: trusty - env: LARAVEL='5.1.*' - php: 5.5.9 dist: trusty env: LARAVEL='5.2.*' - - php: 5.5 - dist: trusty - env: LARAVEL='5.1.*' - php: 5.5 dist: trusty env: LARAVEL='5.2.*' - - php: 5.6 - dist: trusty - env: LARAVEL='5.1.*' - php: 5.6 dist: trusty env: LARAVEL='5.2.*' @@ -44,8 +35,6 @@ matrix: - php: 5.6 dist: trusty env: LARAVEL='5.4.*' - - php: 7.0 - env: LARAVEL='5.1.*' - php: 7.0 env: LARAVEL='5.2.*' - php: 7.0 @@ -54,8 +43,6 @@ matrix: env: LARAVEL='5.4.*' - php: 7.0 env: LARAVEL='5.5.*' - - php: 7.1 - env: LARAVEL='5.1.*' - php: 7.1 env: LARAVEL='5.2.*' - php: 7.1 @@ -70,8 +57,6 @@ matrix: env: LARAVEL='5.7.*' - php: 7.1 env: LARAVEL='5.8.*' - - php: 7.2 - env: LARAVEL='5.1.*' - php: 7.2 env: LARAVEL='5.2.*' - php: 7.2 @@ -88,8 +73,8 @@ matrix: env: LARAVEL='5.8.*' - php: 7.2 env: LARAVEL='6.*' - - php: 7.3 - env: LARAVEL='5.1.*' XDEBUG=1 + - php: 7.2 + env: LARAVEL='7.*' - php: 7.3 env: LARAVEL='5.2.*' XDEBUG=1 - php: 7.3 @@ -106,6 +91,8 @@ matrix: env: LARAVEL='5.8.*' XDEBUG=1 - php: 7.3 env: COVERAGE=1 LARAVEL='6.*' XDEBUG=1 + - php: 7.3 + env: COVERAGE=1 LARAVEL='7.*' XDEBUG=1 fast_finish: true @@ -115,17 +102,10 @@ before_install: - travis_retry composer require "illuminate/contracts:${LARAVEL}" --no-interaction --no-update install: - - travis_retry composer install --prefer-dist --no-interaction --no-suggest + - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction --no-suggest script: - - | - if [[ $LARAVEL == '6.*' ]]; then - composer test:ci -- --exclude-group sentinel-2 - elif [[ $LARAVEL == '5.1.*' ]]; then - composer test:ci -- --exclude-group laravel-5.2 - else - composer test:ci - fi + - composer test:ci after_success: - if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/composer.json b/composer.json index 5b92a002a..19e3d9a61 100644 --- a/composer.json +++ b/composer.json @@ -24,19 +24,18 @@ ], "require": { "php": "^5.5.9|^7.0", - "illuminate/auth": "^5.1|^6", - "illuminate/contracts": "^5.1|^6", - "illuminate/http": "^5.1|^6", - "illuminate/support": "^5.1|^6", + "illuminate/auth": "^5.2|^6|^7", + "illuminate/contracts": "^5.2|^6|^7", + "illuminate/http": "^5.2|^6|^7", + "illuminate/support": "^5.2|^6|^7", "lcobucci/jwt": "^3.2", "namshi/jose": "^7.0", "nesbot/carbon": "^1.0|^2.0" }, "require-dev": { - "cartalyst/sentinel": "^2|^3", - "illuminate/console": "^5.1|^6", - "illuminate/database": "^5.1|^6", - "illuminate/routing": "^5.1|^6", + "illuminate/console": "^5.2|^6|^7", + "illuminate/database": "^5.2|^6|^7", + "illuminate/routing": "^5.2|^6|^7", "mockery/mockery": ">=0.9.9", "phpunit/phpunit": "~4.8|~6.0" }, diff --git a/src/Providers/Auth/Sentinel.php b/src/Providers/Auth/Sentinel.php deleted file mode 100644 index 1807b78ae..000000000 --- a/src/Providers/Auth/Sentinel.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Tymon\JWTAuth\Providers\Auth; - -use Cartalyst\Sentinel\Sentinel as SentinelAuth; -use Tymon\JWTAuth\Contracts\Providers\Auth; - -class Sentinel implements Auth -{ - /** - * The sentinel authentication. - * - * @var \Cartalyst\Sentinel\Sentinel - */ - protected $sentinel; - - /** - * Constructor. - * - * @param \Cartalyst\Sentinel\Sentinel $sentinel - * - * @return void - */ - public function __construct(SentinelAuth $sentinel) - { - $this->sentinel = $sentinel; - } - - /** - * Check a user's credentials. - * - * @param array $credentials - * - * @return mixed - */ - public function byCredentials(array $credentials) - { - return $this->sentinel->stateless($credentials); - } - - /** - * Authenticate a user via the id. - * - * @param mixed $id - * - * @return bool - */ - public function byId($id) - { - if ($user = $this->sentinel->getUserRepository()->findById($id)) { - $this->sentinel->setUser($user); - - return true; - } - - return false; - } - - /** - * Get the currently authenticated user. - * - * @return \Cartalyst\Sentinel\Users\UserInterface - */ - public function user() - { - return $this->sentinel->getUser(); - } -} diff --git a/tests/JWTGuardTest.php b/tests/JWTGuardTest.php index a2f7c6b10..25078ec68 100644 --- a/tests/JWTGuardTest.php +++ b/tests/JWTGuardTest.php @@ -48,7 +48,6 @@ public function setUp() /** * @test - * @group laravel-5.2 */ public function it_should_get_the_request() { @@ -57,7 +56,6 @@ public function it_should_get_the_request() /** * @test - * @group laravel-5.2 */ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provided() { @@ -92,7 +90,6 @@ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provide /** * @test - * @group laravel-5.2 */ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provided_and_not_throw_an_exception() { @@ -124,7 +121,6 @@ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provide /** * @test - * @group laravel-5.2 */ public function it_should_return_null_if_an_invalid_token_is_provided() { @@ -140,7 +136,6 @@ public function it_should_return_null_if_an_invalid_token_is_provided() /** * @test - * @group laravel-5.2 */ public function it_should_return_null_if_no_token_is_provided() { @@ -156,7 +151,6 @@ public function it_should_return_null_if_no_token_is_provided() /** * @test - * @group laravel-5.2 * @expectedException \Tymon\JWTAuth\Exceptions\UserNotDefinedException * @expectedExceptionMessage An error occurred */ @@ -174,7 +168,6 @@ public function it_should_throw_an_exception_if_an_invalid_token_is_provided() /** * @test - * @group laravel-5.2 * @expectedException \Tymon\JWTAuth\Exceptions\UserNotDefinedException * @expectedExceptionMessage An error occurred */ @@ -192,7 +185,6 @@ public function it_should_throw_an_exception_if_no_token_is_provided() /** * @test - * @group laravel-5.2 */ public function it_should_return_a_token_if_credentials_are_ok_and_user_is_found() { @@ -232,7 +224,6 @@ public function it_should_return_a_token_if_credentials_are_ok_and_user_is_found /** * @test - * @group laravel-5.2 */ public function it_should_return_true_if_credentials_are_ok_and_user_is_found_when_choosing_not_to_login() { @@ -255,7 +246,6 @@ public function it_should_return_true_if_credentials_are_ok_and_user_is_found_wh /** * @test - * @group laravel-5.2 */ public function it_should_return_false_if_credentials_are_invalid() { @@ -277,7 +267,6 @@ public function it_should_return_false_if_credentials_are_invalid() /** * @test - * @group laravel-5.2 */ public function it_should_magically_call_the_jwt_instance() { @@ -287,7 +276,6 @@ public function it_should_magically_call_the_jwt_instance() /** * @test - * @group laravel-5.2 */ public function it_should_logout_the_user_by_invalidating_the_token() { @@ -302,7 +290,6 @@ public function it_should_logout_the_user_by_invalidating_the_token() /** * @test - * @group laravel-5.2 */ public function it_should_refresh_the_token() { @@ -315,7 +302,6 @@ public function it_should_refresh_the_token() /** * @test - * @group laravel-5.2 */ public function it_should_invalidate_the_token() { @@ -328,7 +314,6 @@ public function it_should_invalidate_the_token() /** * @test - * @group laravel-5.2 * @expectedException \Tymon\JWTAuth\Exceptions\JWTException * @expectedExceptionMessage Token could not be parsed from the request. */ @@ -343,7 +328,6 @@ public function it_should_throw_an_exception_if_there_is_no_token_present_when_r /** * @test - * @group laravel-5.2 */ public function it_should_generate_a_token_by_id() { @@ -364,7 +348,6 @@ public function it_should_generate_a_token_by_id() /** * @test - * @group laravel-5.2 */ public function it_should_not_generate_a_token_by_id() { @@ -378,7 +361,6 @@ public function it_should_not_generate_a_token_by_id() /** * @test - * @group laravel-5.2 */ public function it_should_authenticate_the_user_by_credentials_and_return_true_if_valid() { @@ -400,7 +382,6 @@ public function it_should_authenticate_the_user_by_credentials_and_return_true_i /** * @test - * @group laravel-5.2 */ public function it_should_attempt_to_authenticate_the_user_by_credentials_and_return_false_if_invalid() { @@ -422,7 +403,6 @@ public function it_should_attempt_to_authenticate_the_user_by_credentials_and_re /** * @test - * @group laravel-5.2 */ public function it_should_authenticate_the_user_by_id_and_return_boolean() { @@ -439,7 +419,6 @@ public function it_should_authenticate_the_user_by_id_and_return_boolean() /** * @test - * @group laravel-5.2 */ public function it_should_not_authenticate_the_user_by_id_and_return_false() { @@ -454,7 +433,6 @@ public function it_should_not_authenticate_the_user_by_id_and_return_false() /** * @test - * @group laravel-5.2 */ public function it_should_create_a_token_from_a_user_object() { @@ -477,7 +455,6 @@ public function it_should_create_a_token_from_a_user_object() /** * @test - * @group laravel-5.2 */ public function it_should_get_the_payload() { @@ -489,7 +466,6 @@ public function it_should_get_the_payload() /** * @test - * @group laravel-5.2 */ public function it_should_be_macroable() { diff --git a/tests/Providers/Auth/SentinelTest.php b/tests/Providers/Auth/SentinelTest.php deleted file mode 100644 index d709002bc..000000000 --- a/tests/Providers/Auth/SentinelTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Tymon\JWTAuth\Test\Providers\Auth; - -use Cartalyst\Sentinel\Sentinel; -use Mockery; -use Tymon\JWTAuth\Providers\Auth\Sentinel as Auth; -use Tymon\JWTAuth\Test\AbstractTestCase; -use Tymon\JWTAuth\Test\Stubs\SentinelStub; - -class SentinelTest extends AbstractTestCase -{ - /** - * @var \Mockery\MockInterface|\Cartalyst\Sentinel\Sentinel - */ - protected $sentinel; - - /** - * @var \Tymon\JWTAuth\Providers\Auth\Sentinel - */ - protected $auth; - - public function setUp() - { - parent::setUp(); - - $this->sentinel = Mockery::mock(Sentinel::class); - $this->auth = new Auth($this->sentinel); - } - - /** @test */ - public function it_should_return_true_if_credentials_are_valid() - { - $this->sentinel->shouldReceive('stateless')->once()->with(['email' => 'foo@bar.com', 'password' => 'foobar'])->andReturn(true); - $this->assertTrue($this->auth->byCredentials(['email' => 'foo@bar.com', 'password' => 'foobar'])); - } - - /** - * @test - * @group sentinel-2 - */ - public function it_should_return_true_if_user_is_found() - { - $stub = new SentinelStub; - $this->sentinel->shouldReceive('getUserRepository->findById')->once()->with(123)->andReturn($stub); - $this->sentinel->shouldReceive('setUser')->once()->with($stub); - - $this->assertTrue($this->auth->byId(123)); - } - - /** @test */ - public function it_should_return_false_if_user_is_not_found() - { - $this->sentinel->shouldReceive('getUserRepository->findById')->once()->with(321)->andReturn(null); - $this->sentinel->shouldReceive('setUser')->never(); - - $this->assertFalse($this->auth->byId(321)); - } - - /** - * @test - * @group sentinel-2 - */ - public function it_should_return_the_currently_authenticated_user() - { - $this->sentinel->shouldReceive('getUser')->once()->andReturn(new SentinelStub); - $this->assertSame($this->auth->user()->getUserId(), 123); - } -} diff --git a/tests/Stubs/SentinelStub.php b/tests/Stubs/SentinelStub.php deleted file mode 100644 index 51517db6d..000000000 --- a/tests/Stubs/SentinelStub.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Tymon\JWTAuth\Test\Stubs; - -use Cartalyst\Sentinel\Users\UserInterface; - -class SentinelStub implements UserInterface -{ - public function getUserId() - { - return 123; - } - - public function getUserLogin() - { - return 'foo'; - } - - public function getUserLoginName() - { - return 'bar'; - } - - public function getUserPassword() - { - return 'baz'; - } -}