Skip to content

Commit

Permalink
Merge pull request #98 from cxj/4.x
Browse files Browse the repository at this point in the history
New 4.x branch for modern PHP and PHPUnit usage
  • Loading branch information
harikt authored Jul 3, 2019
2 parents 624fc81 + f0b8af4 commit 7a2ae57
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 92 deletions.
30 changes: 2 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,14 @@ language: php

matrix:
include:
- os: linux
dist: precise
sudo: false
php: 5.3
- os: linux
dist: precise
sudo: false
php: 5.4
- os: linux
dist: precise
sudo: false
php: 5.5
- os: linux
dist: precise
sudo: false
php: 5.6
env:
- TEST_COVERAGE=true
- os: linux
dist: trusty
sudo: false
php: 7
- os: linux
dist: trusty
sudo: false
php: 7.1
- os: linux
dist: trusty
sudo: false
php: hhvm
php: 7.2
- os: linux
dist: trusty
sudo: false
php: nightly
php: 7.3

before_script:
- composer self-update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Note that the purpose of this package is only to authenticate user credentials.

### Installation

This library requires PHP 5.5 or later, and has no userland dependencies. (As a special consideration, this library is compatible with PHP 5.3 and 5.4 when the [ircmaxell/password-compat](https://github.com/ircmaxell/password_compat) package is installed.)
This library requires PHP 7.2 or later, and has no userland dependencies.

It is installable and autoloadable via Composer as [aura/auth](https://packagist.org/packages/aura/auth).

Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.0"
"php": ">=7.2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -32,9 +32,12 @@
}
}
},

"minimum-stability": "dev",
"require-dev": {
"aura/di": "~2.0",
"phpunit/phpunit": "~5.7 || ~4.8"
"acclimate/container": "^2",
"aura/di": "~4.0",
"phpunit/phpunit": "~7"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -44,7 +47,6 @@
},
"suggest": {
"ext/ldap": "For LDAP integration.",
"ext/imap": "For IMAP/POP/NNTP integration.",
"ircmaxell/password-compat": "Provides password_verify() for PHP versions earlier than 5.5"
"ext/imap": "For IMAP/POP/NNTP integration."
}
}
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<phpunit bootstrap="./phpunit.php">
<testsuites>
<testsuite>
<testsuite name="tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="session.gc_maxlifetime" value="3600"/>
<ini name="session.gc_maxlifetime" value="86400"/>
</php>
</phpunit>
4 changes: 2 additions & 2 deletions src/AuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public function newLogoutService(AdapterInterface $adapter = null)
*/
public function newResumeService(
AdapterInterface $adapter = null,
$idle_ttl = 1440,
$expire_ttl = 14400
$idle_ttl = 3600, // 1 hour
$expire_ttl = 86400 // 24 hours
) {

$adapter = $this->fixAdapter($adapter);
Expand Down
12 changes: 6 additions & 6 deletions src/Session/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Timer
* @var int
*
*/
protected $idle_ttl = 1440;
protected $idle_ttl = 3600; // 1 hour

/**
*
Expand All @@ -52,7 +52,7 @@ class Timer
* @var int
*
*/
protected $expire_ttl = 14400;
protected $expire_ttl = 86400; // 24 hours

/**
*
Expand All @@ -68,10 +68,10 @@ class Timer
*
*/
public function __construct(
$ini_gc_maxlifetime = 1440,
$ini_gc_maxlifetime = 86401, // 24 hours plus 1 second
$ini_cookie_lifetime = 0,
$idle_ttl = 1440,
$expire_ttl = 14400
$idle_ttl = 3600, // 1 hour
$expire_ttl = 86400 // 24 hours
) {
$this->ini_gc_maxlifetime = $ini_gc_maxlifetime;
$this->ini_cookie_lifetime = $ini_cookie_lifetime;
Expand All @@ -94,7 +94,7 @@ public function __construct(
public function setIdleTtl($idle_ttl)
{
if ($this->ini_gc_maxlifetime < $idle_ttl) {
throw new Exception("session.gc_maxlifetime $this->ini_gc_maxlifetime less than idle time $idle_ttl");
throw new Exception("session.gc_maxlifetime {$this->ini_gc_maxlifetime} less than idle time $idle_ttl");
}
$this->idle_ttl = $idle_ttl;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Adapter/HtpasswdAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aura\Auth\Verifier\HtpasswdVerifier;

class HtpasswdAdapterTest extends \PHPUnit_Framework_TestCase
class HtpasswdAdapterTest extends \PHPUnit\Framework\TestCase
{
protected $adapter;

Expand All @@ -21,7 +21,7 @@ protected function setAdapter($file)
public function testLogin_fileNotReadable()
{
$this->setAdapter('no-such-file');
$this->setExpectedException('Aura\Auth\Exception\FileNotReadable');
$this->expectException('Aura\Auth\Exception\FileNotReadable');
$this->adapter->login(array(
'username' => 'boshag',
'password' => '123456',
Expand All @@ -40,21 +40,21 @@ public function testLogin_success()

public function testLogin_usernameMissing()
{
$this->setExpectedException('Aura\Auth\Exception\UsernameMissing');
$this->expectException('Aura\Auth\Exception\UsernameMissing');
$this->adapter->login(array());
}

public function testLogin_passwordMissing()
{
$this->setExpectedException('Aura\Auth\Exception\PasswordMissing');
$this->expectException('Aura\Auth\Exception\PasswordMissing');
$this->adapter->login(array(
'username' => 'boshag',
));
}

public function testLogin_usernameNotFound()
{
$this->setExpectedException('Aura\Auth\Exception\UsernameNotFound');
$this->expectException('Aura\Auth\Exception\UsernameNotFound');
$this->adapter->login(array(
'username' => 'nouser',
'password' => 'nopass',
Expand All @@ -63,10 +63,10 @@ public function testLogin_usernameNotFound()

public function testLogin_passwordIncorrect()
{
$this->setExpectedException('Aura\Auth\Exception\PasswordIncorrect');
$this->expectException('Aura\Auth\Exception\PasswordIncorrect');
$this->adapter->login(array(
'username' => 'boshag',
'password' => '------',
));
}
}
}
4 changes: 2 additions & 2 deletions tests/Adapter/ImapAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aura\Auth\Phpfunc;

class ImapAdapterTest extends \PHPUnit_Framework_TestCase
class ImapAdapterTest extends \PHPUnit\Framework\TestCase
{
protected $phpfunc;

Expand Down Expand Up @@ -63,7 +63,7 @@ public function testLogin_connectionFailed()
->with('{mailbox.example.com:143/imap/secure}')
->will($this->returnValue(false));

$this->setExpectedException('Aura\Auth\Exception\ConnectionFailed');
$this->expectException('Aura\Auth\Exception\ConnectionFailed');
$this->adapter->login(array(
'username' => 'someusername',
'password' => 'secretpassword'
Expand Down
6 changes: 3 additions & 3 deletions tests/Adapter/LdapAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aura\Auth\Phpfunc;

class LdapAdapterTest extends \PHPUnit_Framework_TestCase
class LdapAdapterTest extends \PHPUnit\Framework\TestCase
{
protected $adapter;

Expand Down Expand Up @@ -84,7 +84,7 @@ public function testLogin_connectionFailed()
->with('ldaps://ldap.example.com:636')
->will($this->returnValue(false));

$this->setExpectedException('Aura\Auth\Exception\ConnectionFailed');
$this->expectException('Aura\Auth\Exception\ConnectionFailed');
$this->adapter->login($input);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public function testLogin_bindFailed()
->method('ldap_unbind')
->will($this->returnValue(true));

$this->setExpectedException('Aura\Auth\Exception\BindFailed');
$this->expectException('Aura\Auth\Exception\BindFailed');
$this->adapter->login(array(
'username' => 'someusername',
'password' => 'secretpassword'
Expand Down
2 changes: 1 addition & 1 deletion tests/Adapter/NullAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aura\Auth\Adapter;

class NullAdapterTest extends \PHPUnit_Framework_TestCase
class NullAdapterTest extends \PHPUnit\Framework\TestCase
{
protected $adapter;

Expand Down
16 changes: 8 additions & 8 deletions tests/Adapter/PdoAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use PDO;
use Aura\Auth\Verifier\PasswordVerifier;

class PdoAdapterTest extends \PHPUnit_Framework_TestCase
class PdoAdapterTest extends \PHPUnit\Framework\TestCase
{
protected $adapter;

Expand Down Expand Up @@ -73,7 +73,7 @@ protected function buildTable()

public function test_usernameColumnNotSpecified()
{
$this->setExpectedException('Aura\Auth\Exception\UsernameColumnNotSpecified');
$this->expectException('Aura\Auth\Exception\UsernameColumnNotSpecified');
$this->adapter = new PdoAdapter(
$this->pdo,
new PasswordVerifier('md5'),
Expand All @@ -84,7 +84,7 @@ public function test_usernameColumnNotSpecified()

public function test_passwordColumnNotSpecified()
{
$this->setExpectedException('Aura\Auth\Exception\PasswordColumnNotSpecified');
$this->expectException('Aura\Auth\Exception\PasswordColumnNotSpecified');
$this->adapter = new PdoAdapter(
$this->pdo,
new PasswordVerifier('md5'),
Expand All @@ -106,21 +106,21 @@ public function testLogin()

public function testLogin_usernameMissing()
{
$this->setExpectedException('Aura\Auth\Exception\UsernameMissing');
$this->expectException('Aura\Auth\Exception\UsernameMissing');
$this->adapter->login(array());
}

public function testLogin_passwordMissing()
{
$this->setExpectedException('Aura\Auth\Exception\PasswordMissing');
$this->expectException('Aura\Auth\Exception\PasswordMissing');
$this->adapter->login(array(
'username' => 'boshag',
));
}

public function testLogin_usernameNotFound()
{
$this->setExpectedException('Aura\Auth\Exception\UsernameNotFound');
$this->expectException('Aura\Auth\Exception\UsernameNotFound');
$this->adapter->login(array(
'username' => 'missing',
'password' => '------',
Expand All @@ -129,7 +129,7 @@ public function testLogin_usernameNotFound()

public function testLogin_passwordIncorrect()
{
$this->setExpectedException('Aura\Auth\Exception\PasswordIncorrect');
$this->expectException('Aura\Auth\Exception\PasswordIncorrect');
$this->adapter->login(array(
'username' => 'boshag',
'password' => '------',
Expand All @@ -138,7 +138,7 @@ public function testLogin_passwordIncorrect()

public function testLogin_multipleMatches()
{
$this->setExpectedException('Aura\Auth\Exception\MultipleMatches');
$this->expectException('Aura\Auth\Exception\MultipleMatches');
$this->adapter->login(array(
'username' => 'repeat',
'password' => '234567',
Expand Down
2 changes: 1 addition & 1 deletion tests/AuthFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Aura\Auth\Session\Segment;
use Aura\Auth\Verifier\FakeVerifier;

class AuthFactoryTest extends \PHPUnit_Framework_TestCase
class AuthFactoryTest extends \PHPUnit\Framework\TestCase
{
protected $factory;

Expand Down
2 changes: 1 addition & 1 deletion tests/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Aura\Auth\Session\FakeSegment;
use Aura\Auth\Status;

class AuthTest extends \PHPUnit_Framework_TestCase
class AuthTest extends \PHPUnit\Framework\TestCase
{
protected $auth;

Expand Down
2 changes: 1 addition & 1 deletion tests/ContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aura\Auth;

use Aura\Di\_Config\AbstractContainerTest;
use Aura\Di\ContainerTest as AbstractContainerTest;

class ContainerTest extends AbstractContainerTest
{
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpfuncTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aura\Auth;

class PhpfuncTest extends \PHPUnit_Framework_TestCase
class PhpfuncTest extends \PHPUnit\Framework\TestCase
{
protected $phpfunc;

Expand Down
2 changes: 1 addition & 1 deletion tests/Service/LoginServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Aura\Auth\Auth;
use Aura\Auth\Status;

class LoginServiceTest extends \PHPUnit_Framework_TestCase
class LoginServiceTest extends \PHPUnit\Framework\TestCase
{
protected $segment;

Expand Down
2 changes: 1 addition & 1 deletion tests/Service/LogoutServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Aura\Auth\Auth;
use Aura\Auth\Status;

class LogoutServiceTest extends \PHPUnit_Framework_TestCase
class LogoutServiceTest extends \PHPUnit\Framework\TestCase
{
protected $session;

Expand Down
Loading

0 comments on commit 7a2ae57

Please sign in to comment.