diff --git a/.travis.yml b/.travis.yml index c51e2c33d..b2be36df1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ php: - 5.5 - 5.6 - 7.0 - - hhvm + - 7.1 env: - COMPOSER_CMD="composer install" @@ -21,7 +21,7 @@ matrix: env: RUN_CS_FIXER=true COMPOSER_CMD="composer install" before_script: - - $(echo $COMPOSER_CMD) + - $COMPOSER_CMD script: - if [ "${RUN_CS_FIXER}" = "true" ]; then diff --git a/CHANGELOG.md b/CHANGELOG.md index 1628dc51c..d76f39cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.0.0 (12/06/2017) + +### Changes + +* Adds hashing and shortening to enforce max key length ([@bshaffer]) +* Fix for better PSR-6 compliance - verifies a hit before getting the cache item ([@bshaffer]) +* README fixes ([@bshaffer]) +* Change authorization header key to lowercase ([@stanley-cheung]) + ## 0.4.0 (23/04/2015) ### Changes @@ -5,4 +14,5 @@ * Export callback function to update auth metadata ([@stanley-cheung][]) * Adds an implementation of User Refresh Token auth ([@stanley-cheung][]) +[@bshaffer]: https://github.com/bshaffer [@stanley-cheung]: https://github.com/stanley-cheung diff --git a/composer.json b/composer.json index c528ada16..cfa788130 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "require": { "php": ">=5.4", "firebase/php-jwt": "~2.0|~3.0|~4.0", - "guzzlehttp/guzzle": "~5.3|~6.0", + "guzzlehttp/guzzle": "~5.3.1|~6.0", "guzzlehttp/psr7": "~1.2", "psr/http-message": "^1.0", "psr/cache": "^1.0" diff --git a/tests/CacheTraitTest.php b/tests/CacheTraitTest.php index 51152c3d6..30ba924f7 100644 --- a/tests/CacheTraitTest.php +++ b/tests/CacheTraitTest.php @@ -44,6 +44,10 @@ public function setUp() public function testSuccessfullyPullsFromCache() { $expectedValue = '1234'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -66,6 +70,10 @@ public function testSuccessfullyPullsFromCacheWithInvalidKey() $key = 'this-key-has-@-illegal-characters'; $expectedKey = 'thiskeyhasillegalcharacters'; $expectedValue = '1234'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -92,6 +100,10 @@ public function testSuccessfullyPullsFromCacheWithLongKey() $expectedKey = str_replace('-', '', $key); $expectedKey = substr(hash('sha256', $expectedKey), 0, 64); $expectedValue = '1234'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') diff --git a/tests/FetchAuthTokenCacheTest.php b/tests/FetchAuthTokenCacheTest.php index 359094a85..a027fa7bf 100644 --- a/tests/FetchAuthTokenCacheTest.php +++ b/tests/FetchAuthTokenCacheTest.php @@ -41,6 +41,10 @@ public function testUsesCachedAuthToken() { $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -73,6 +77,10 @@ public function testGetsCachedAuthTokenUsingCachePrefix() $prefix = 'test_prefix_'; $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') diff --git a/tests/Middleware/AuthTokenMiddlewareTest.php b/tests/Middleware/AuthTokenMiddlewareTest.php index a54dfcae8..e3d05e9f1 100644 --- a/tests/Middleware/AuthTokenMiddlewareTest.php +++ b/tests/Middleware/AuthTokenMiddlewareTest.php @@ -112,6 +112,10 @@ public function testUsesCachedAuthToken() { $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -151,6 +155,10 @@ public function testGetsCachedAuthTokenUsingCacheOptions() $prefix = 'test_prefix_'; $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') diff --git a/tests/Middleware/ScopedAccessTokenMiddlewareTest.php b/tests/Middleware/ScopedAccessTokenMiddlewareTest.php index 27f5a08df..b33f19335 100644 --- a/tests/Middleware/ScopedAccessTokenMiddlewareTest.php +++ b/tests/Middleware/ScopedAccessTokenMiddlewareTest.php @@ -84,6 +84,10 @@ public function testUsesCachedAuthToken() $fakeAuthFunc = function ($unused_scopes) { return ''; }; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -118,6 +122,10 @@ public function testGetsCachedAuthTokenUsingCachePrefix() $fakeAuthFunc = function ($unused_scopes) { return ''; }; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -153,7 +161,7 @@ public function testShouldSaveValueInCache() }; $this->mockCacheItem ->expects($this->once()) - ->method('get') + ->method('isHit') ->will($this->returnValue(false)); $this->mockCacheItem ->expects($this->once()) @@ -193,7 +201,7 @@ public function testShouldSaveValueInCacheWithCacheOptions() }; $this->mockCacheItem ->expects($this->once()) - ->method('get') + ->method('isHit') ->will($this->returnValue(false)); $this->mockCacheItem ->expects($this->once()) diff --git a/tests/Subscriber/AuthTokenSubscriberTest.php b/tests/Subscriber/AuthTokenSubscriberTest.php index 48f85d00d..0a97ac73f 100644 --- a/tests/Subscriber/AuthTokenSubscriberTest.php +++ b/tests/Subscriber/AuthTokenSubscriberTest.php @@ -105,6 +105,10 @@ public function testUsesCachedAuthToken() { $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -143,6 +147,10 @@ public function testGetsCachedAuthTokenUsingCachePrefix() $prefix = 'test_prefix_'; $cacheKey = 'myKey'; $cachedValue = '2/abcdef1234567890'; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') diff --git a/tests/Subscriber/ScopedAccessTokenSubscriberTest.php b/tests/Subscriber/ScopedAccessTokenSubscriberTest.php index 376a24662..829c5b27e 100644 --- a/tests/Subscriber/ScopedAccessTokenSubscriberTest.php +++ b/tests/Subscriber/ScopedAccessTokenSubscriberTest.php @@ -92,6 +92,10 @@ public function testUsesCachedAuthToken() $fakeAuthFunc = function ($unused_scopes) { return ''; }; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -123,6 +127,10 @@ public function testGetsCachedAuthTokenUsingCachePrefix() $fakeAuthFunc = function ($unused_scopes) { return ''; }; + $this->mockCacheItem + ->expects($this->once()) + ->method('isHit') + ->will($this->returnValue(true)); $this->mockCacheItem ->expects($this->once()) ->method('get') @@ -156,7 +164,7 @@ public function testShouldSaveValueInCache() }; $this->mockCacheItem ->expects($this->once()) - ->method('get') + ->method('isHit') ->will($this->returnValue(false)); $this->mockCacheItem ->expects($this->once()) @@ -191,7 +199,7 @@ public function testShouldSaveValueInCacheWithCacheOptions() }; $this->mockCacheItem ->expects($this->once()) - ->method('get') + ->method('isHit') ->will($this->returnValue(false)); $this->mockCacheItem ->expects($this->once())