Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Behaviour of encrypt and decrypt methods when mcrypt is not loaded #770

Closed
wants to merge 31 commits into from

10 participants

@chefchef

Throw an exception when the mcrypt library is not loaded. Also I adapted the test for this new behaviour. Another alternative is not change the tests and fail when the mcrypt is not loaded.

elgenie and others added some commits
@elgenie elgenie Add (string) case in encodeSecureCookie call to hash_hmac
Per http://php.net/manual/en/function.hash-hmac.php, the second argument to hash_hmac is supposed to be a string. HHVM (http://www.hhvm.com) is more strict about checking the arguments.
1beca31
@codeguy codeguy Merge branch 'release-2.4.0' 02cf237
@codeguy codeguy Bump version number ff7d714
@jeremykendall jeremykendall Adds boolean $caseSensitive property
Routes can now be case insensitive if $caseSensitive is set to `false`
68b6115
@jeremykendall jeremykendall Adds `routes.case_sensitive` config setting
True by default, routes become case-insensitive when set to false.
f6331b4
@ptarjan ptarjan Try running unit tests on HHVM b1dca9a
@codeguy codeguy Set default timezone for unit tests 234e38b
Chris Gedrim Add default return value for request data
Allow overloading of the default return value of NULL when
requesting request data.

Example:
  http://host/action?foo=bar&abc=123

  $app->request->get('foo')        -- [bar]
  $app->request->get('bar')        -- [NULL]
  $app->request->get('bar', false) -- [FALSE]
456514a
@renatko renatko Controller as \class::method efb01f2
@renatko renatko [] -> array() 2938d9e
@sasezaki sasezaki .travis.yml - add PHP 5.5 74ea8f7
@dongilbert dongilbert Add property typehints for proper IDE support. dac949c
@dongilbert dongilbert Fix ordering 11519e3
@ziadoz ziadoz Pass through 'templates.path' to view object singleton. 19a1b55
@ziadoz ziadoz Remove redundant call to setTemplatesDirector method. 102ba87
@ziadoz ziadoz Allow local data to be passed into a template during rendering. 010ce33
@ptarjan ptarjan Don't rely on system setting for error_reporting level 23d9970
@trqx trqx add 418 HTTP status code 48d790d
@codeguy codeguy Remove mcrypt dependency eff1762
Renat Bilalov fix [] -> array()
change separator "::" -> ":"
7e06c84
@codeguy codeguy Bump version number 04c7e9a
@ptarjan ptarjan Try running unit tests on HHVM 0327ee9
@codeguy codeguy Set default timezone for unit tests c079e3e
@codeguy codeguy Merge branch 'release-2.4.1' of github.com:codeguy/Slim into release-…
…2.4.1
4bbf71f
@codeguy codeguy Merge pull request #697 from jeremykendall/release-2.4.1
Routes can be case-insensitive based on a config setting.
ea4d202
@codeguy codeguy Let Slim parse HTTP_CONTENT_TYPE header for PHP built-in server 32e8b03
@codeguy codeguy Let Slim read HTTP_CONTENT_TYPE header for PHP built-in server b0e2657
@codeguy codeguy Let Slim parse HTTP_CONTENT_TYPE header for PHP built-in server 71c82b0
@codeguy codeguy Merge branch 'master' of github.com:codeguy/Slim 10770de
@codeguy codeguy Version bump 3a2ac72
@chefchef chefchef Throw an exception when the mcrypt library is not loaded. Also I adap…
…ted the test for this new behaviour. Another alternative is not change the tests and fail when the mcrypt is not loaded.
ce8dfbd
@codeguy codeguy added this to the Version 3.0.0 milestone
@codeguy codeguy self-assigned this
@codeguy codeguy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2013
  1. @elgenie

    Add (string) case in encodeSecureCookie call to hash_hmac

    elgenie authored
    Per http://php.net/manual/en/function.hash-hmac.php, the second argument to hash_hmac is supposed to be a string. HHVM (http://www.hhvm.com) is more strict about checking the arguments.
Commits on Nov 29, 2013
  1. @codeguy

    Merge branch 'release-2.4.0'

    codeguy authored
  2. @codeguy

    Bump version number

    codeguy authored
Commits on Dec 12, 2013
  1. @jeremykendall

    Adds boolean $caseSensitive property

    jeremykendall authored
    Routes can now be case insensitive if $caseSensitive is set to `false`
  2. @jeremykendall

    Adds `routes.case_sensitive` config setting

    jeremykendall authored
    True by default, routes become case-insensitive when set to false.
Commits on Dec 13, 2013
  1. @ptarjan
Commits on Dec 14, 2013
  1. @codeguy
  2. @codeguy

    Add default return value for request data

    Chris Gedrim authored codeguy committed
    Allow overloading of the default return value of NULL when
    requesting request data.
    
    Example:
      http://host/action?foo=bar&abc=123
    
      $app->request->get('foo')        -- [bar]
      $app->request->get('bar')        -- [NULL]
      $app->request->get('bar', false) -- [FALSE]
  3. @renatko @codeguy

    Controller as \class::method

    renatko authored codeguy committed
  4. @renatko @codeguy

    [] -> array()

    renatko authored codeguy committed
  5. @sasezaki @codeguy

    .travis.yml - add PHP 5.5

    sasezaki authored codeguy committed
  6. @dongilbert @codeguy

    Add property typehints for proper IDE support.

    dongilbert authored codeguy committed
  7. @dongilbert @codeguy

    Fix ordering

    dongilbert authored codeguy committed
  8. @ziadoz @codeguy

    Pass through 'templates.path' to view object singleton.

    ziadoz authored codeguy committed
  9. @ziadoz @codeguy

    Remove redundant call to setTemplatesDirector method.

    ziadoz authored codeguy committed
  10. @ziadoz @codeguy
  11. @ptarjan @codeguy

    Don't rely on system setting for error_reporting level

    ptarjan authored codeguy committed
  12. @trqx @codeguy

    add 418 HTTP status code

    trqx authored codeguy committed
  13. @codeguy

    Remove mcrypt dependency

    codeguy authored
  14. @codeguy

    fix [] -> array()

    Renat Bilalov authored codeguy committed
    change separator "::" -> ":"
  15. @codeguy

    Bump version number

    codeguy authored
  16. @ptarjan @codeguy

    Try running unit tests on HHVM

    ptarjan authored codeguy committed
  17. @codeguy
  18. @codeguy
  19. @codeguy

    Merge pull request #697 from jeremykendall/release-2.4.1

    codeguy authored
    Routes can be case-insensitive based on a config setting.
Commits on Feb 16, 2014
  1. @codeguy
  2. @codeguy
  3. @codeguy
  4. @codeguy
  5. @codeguy

    Version bump

    codeguy authored
Commits on Feb 24, 2014
  1. @chefchef

    Throw an exception when the mcrypt library is not loaded. Also I adap…

    chefchef authored
    …ted the test for this new behaviour. Another alternative is not change the tests and fail when the mcrypt is not loaded.
This page is out of date. Refresh to see the latest.
Showing with 166 additions and 51 deletions.
  1. +1 −0  .travis.yml
  2. +1 −1  Slim/Environment.php
  3. +1 −1  Slim/Exception/Pass.php
  4. +1 −1  Slim/Exception/Stop.php
  5. +1 −1  Slim/Helper/Set.php
  6. +1 −1  Slim/Http/Cookies.php
  7. +2 −2 Slim/Http/Headers.php
  8. +1 −1  Slim/Http/Request.php
  9. +1 −1  Slim/Http/Response.php
  10. +14 −4 Slim/Http/Util.php
  11. +1 −1  Slim/Log.php
  12. +1 −1  Slim/LogWriter.php
  13. +1 −1  Slim/Middleware.php
  14. +1 −1  Slim/Middleware/ContentTypes.php
  15. +1 −1  Slim/Middleware/Flash.php
  16. +1 −1  Slim/Middleware/MethodOverride.php
  17. +1 −1  Slim/Middleware/PrettyExceptions.php
  18. +1 −1  Slim/Middleware/SessionCookie.php
  19. +16 −3 Slim/Route.php
  20. +1 −1  Slim/Router.php
  21. +6 −4 Slim/Slim.php
  22. +1 −1  Slim/View.php
  23. +1 −3 tests/EnvironmentTest.php
  24. +1 −1  tests/Helper/SetTest.php
  25. +1 −1  tests/Http/CookiesTest.php
  26. +1 −1  tests/Http/HeadersTest.php
  27. +27 −1 tests/Http/RequestTest.php
  28. +1 −1  tests/Http/ResponseTest.php
  29. +33 −1 tests/Http/UtilTest.php
  30. +1 −1  tests/LogTest.php
  31. +1 −1  tests/LogWriterTest.php
  32. +1 −1  tests/Middleware/ContentTypesTest.php
  33. +1 −1  tests/Middleware/FlashTest.php
  34. +1 −1  tests/Middleware/MethodOverrideTest.php
  35. +1 −1  tests/Middleware/PrettyExceptionsTest.php
  36. +1 −1  tests/Middleware/SessionCookieTest.php
  37. +1 −1  tests/MiddlewareTest.php
  38. +15 −1 tests/RouteTest.php
  39. +1 −1  tests/RouterTest.php
  40. +17 −1 tests/SlimTest.php
  41. +1 −1  tests/ViewTest.php
  42. +3 −0  tests/bootstrap.php
View
1  .travis.yml
@@ -4,5 +4,6 @@ php:
- 5.3
- 5.4
- 5.5
+ - hhvm
script: phpunit --coverage-text
View
2  Slim/Environment.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Exception/Pass.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Exception/Stop.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Helper/Set.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Http/Cookies.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
4 Slim/Http/Headers.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
@@ -72,7 +72,7 @@ public static function extract($data)
foreach ($data as $key => $value) {
$key = strtoupper($key);
if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) {
- if ($key === 'HTTP_CONTENT_TYPE' || $key === 'HTTP_CONTENT_LENGTH') {
+ if ($key === 'HTTP_CONTENT_LENGTH') {
continue;
}
$results[$key] = $value;
View
2  Slim/Http/Request.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Http/Response.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
18 Slim/Http/Util.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
@@ -88,10 +88,15 @@ protected static function stripSlashes($rawData)
* @param string $iv The encryption initialization vector
* @param array $settings Optional key-value array with custom algorithm and mode
* @return string
+ * @throws \RuntimeException
*/
public static function encrypt($data, $key, $iv, $settings = array())
{
- if ($data === '' || !extension_loaded('mcrypt')) {
+ if (!extension_loaded('mcrypt')) {
+ throw new \RuntimeException("The extension mcrypt is not loaded");
+ }
+
+ if ($data === '') {
return $data;
}
@@ -138,10 +143,15 @@ public static function encrypt($data, $key, $iv, $settings = array())
* @param string $iv The encryption initialization vector
* @param array $settings Optional key-value array with custom algorithm and mode
* @return string
+ * @throws \RuntimeException
*/
public static function decrypt($data, $key, $iv, $settings = array())
{
- if ($data === '' || !extension_loaded('mcrypt')) {
+ if (!extension_loaded('mcrypt')) {
+ throw new \RuntimeException("The extension mcrypt is not loaded");
+ }
+
+ if ($data === '') {
return $data;
}
@@ -224,7 +234,7 @@ public static function serializeCookies(\Slim\Http\Headers &$headers, \Slim\Http
*/
public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode)
{
- $key = hash_hmac('sha1', $expires, $secret);
+ $key = hash_hmac('sha1', (string) $expires, $secret);
$iv = self::getIv($expires, $secret);
$secureString = base64_encode(
self::encrypt(
View
2  Slim/Log.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/LogWriter.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware/ContentTypes.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware/Flash.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware/MethodOverride.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware/PrettyExceptions.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
2  Slim/Middleware/SessionCookie.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
19 Slim/Route.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
@@ -91,15 +91,22 @@ class Route
protected $middleware = array();
/**
+ * @var bool Whether or not this route should be matched in a case-sensitive manner
+ */
+ protected $caseSensitive;
+
+ /**
* Constructor
* @param string $pattern The URL pattern (e.g. "/books/:id")
* @param mixed $callable Anything that returns TRUE for is_callable()
+ * @param bool $caseSensitive Whether or not this route should be matched in a case-sensitive manner
*/
- public function __construct($pattern, $callable)
+ public function __construct($pattern, $callable, $caseSensitive = true)
{
$this->setPattern($pattern);
$this->setCallable($callable);
$this->setConditions(self::getDefaultConditions());
+ $this->caseSensitive = $caseSensitive;
}
/**
@@ -362,8 +369,14 @@ public function matches($resourceUri)
$patternAsRegex .= '?';
}
+ $regex = '#^' . $patternAsRegex . '$#';
+
+ if ($this->caseSensitive === false) {
+ $regex .= 'i';
+ }
+
//Cache URL params' names and values if this route matches the current HTTP request
- if (!preg_match('#^' . $patternAsRegex . '$#', $resourceUri, $paramValues)) {
+ if (!preg_match($regex, $resourceUri, $paramValues)) {
return false;
}
foreach ($this->paramNames as $name) {
View
2  Slim/Router.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
10 Slim/Slim.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
@@ -54,7 +54,7 @@ class Slim
/**
* @const string
*/
- const VERSION = '2.3.5';
+ const VERSION = '2.4.2';
/**
* @var \Slim\Helper\Set
@@ -308,7 +308,9 @@ public static function getDefaultSettings()
'cookies.cipher' => MCRYPT_RIJNDAEL_256,
'cookies.cipher_mode' => MCRYPT_MODE_CBC,
// HTTP
- 'http.version' => '1.1'
+ 'http.version' => '1.1',
+ // Routing
+ 'routes.case_sensitive' => true
);
}
@@ -434,7 +436,7 @@ protected function mapRoute($args)
{
$pattern = array_shift($args);
$callable = array_pop($args);
- $route = new \Slim\Route($pattern, $callable);
+ $route = new \Slim\Route($pattern, $callable, $this->settings['routes.case_sensitive']);
$this->router->map($route);
if (count($args) > 0) {
$route->setMiddleware($args);
View
2  Slim/View.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
* @package Slim
*
* MIT LICENSE
View
4 tests/EnvironmentTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
@@ -277,10 +277,8 @@ public function testServerPortIsNotEmpty()
*/
public function testUnsetsContentTypeAndContentLength()
{
- $_SERVER['HTTP_CONTENT_TYPE'] = 'text/csv';
$_SERVER['HTTP_CONTENT_LENGTH'] = 150;
$env = \Slim\Environment::getInstance(true);
- $this->assertFalse(isset($env['HTTP_CONTENT_TYPE']));
$this->assertFalse(isset($env['HTTP_CONTENT_LENGTH']));
}
View
2  tests/Helper/SetTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Http/CookiesTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Http/HeadersTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
28 tests/Http/RequestTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
@@ -508,6 +508,19 @@ public function testGetContentTypeWhenExists()
}
/**
+ * Test get content type for built-in PHP server
+ */
+ public function testGetContentTypeForBuiltInServer()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'HTTP_CONTENT_TYPE' => 'application/json; charset=ISO-8859-4'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType());
+ }
+
+ /**
* Test get content type
*/
public function testGetContentTypeWhenNotExists()
@@ -518,6 +531,19 @@ public function testGetContentTypeWhenNotExists()
}
/**
+ * Test get content type with built-in server
+ */
+ public function testGetContentTypeWithBuiltInServer()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'HTTP_CONTENT_TYPE' => 'application/json; charset=ISO-8859-4'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType());
+ }
+
+ /**
* Test get media type
*/
public function testGetMediaTypeWhenExists()
View
2  tests/Http/ResponseTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
34 tests/Http/UtilTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
@@ -77,6 +77,10 @@ public function testStripSlashesFromArrayWithMagicQuotes()
*/
public function testEncryptAndDecryptWithValidData()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$data = 'foo';
$key = 'secret';
$iv = md5('initializationVector');
@@ -91,6 +95,10 @@ public function testEncryptAndDecryptWithValidData()
*/
public function testEncryptWhenDataIsEmptyString()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$data = '';
$key = 'secret';
$iv = md5('initializationVector');
@@ -103,6 +111,10 @@ public function testEncryptWhenDataIsEmptyString()
*/
public function testDecryptWhenDataIsEmptyString()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$data = '';
$key = 'secret';
$iv = md5('initializationVector');
@@ -115,6 +127,10 @@ public function testDecryptWhenDataIsEmptyString()
*/
public function testEncryptAndDecryptWhenKeyAndIvAreTooLong()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$data = 'foo';
$key = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
$iv = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
@@ -126,6 +142,10 @@ public function testEncryptAndDecryptWhenKeyAndIvAreTooLong()
public function testEncodeAndDecodeSecureCookieWithValidData()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
//Prepare cookie value
$value = 'foo';
$expires = time() + 86400;
@@ -151,6 +171,10 @@ public function testEncodeAndDecodeSecureCookieWithValidData()
*/
public function testEncodeAndDecodeSecureCookieWithOldExpiration()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$value = 'foo';
$expires = time() - 100;
$secret = 'password';
@@ -170,6 +194,10 @@ public function testEncodeAndDecodeSecureCookieWithOldExpiration()
*/
public function testEncodeAndDecodeSecureCookieWithTamperedData()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$value = 'foo';
$expires = time() + 86400;
$secret = 'password';
@@ -334,6 +362,10 @@ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAnd
*/
public function testSerializeCookiesAndDecryptWithStringExpires()
{
+ if (!extension_loaded('mcrypt')) {
+ $this->setExpectedException('RuntimeException');
+ }
+
$value = 'bar';
$headers = new \Slim\Http\Headers();
View
2  tests/LogTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/LogWriterTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Middleware/ContentTypesTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Middleware/FlashTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Middleware/MethodOverrideTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Middleware/PrettyExceptionsTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/Middleware/SessionCookieTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
2  tests/MiddlewareTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
16 tests/RouteTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
@@ -272,6 +272,20 @@ public function testMatchesOptionalParameters()
$this->assertEquals(array('year' => '2010', 'month' => '05', 'day' => '13'), $route3->getParams());
}
+ public function testMatchesIsCaseSensitiveByDefault()
+ {
+ $route = new \Slim\Route('/case/sensitive', function () {});
+ $this->assertTrue($route->matches('/case/sensitive'));
+ $this->assertFalse($route->matches('/CaSe/SensItiVe'));
+ }
+
+ public function testMatchesCanBeCaseInsensitive()
+ {
+ $route = new \Slim\Route('/Case/Insensitive', function () {}, false);
+ $this->assertTrue($route->matches('/Case/Insensitive'));
+ $this->assertTrue($route->matches('/CaSe/iNSensItiVe'));
+ }
+
public function testGetConditions()
{
$route = new \Slim\Route('/foo', function () {});
View
2  tests/RouterTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
18 tests/SlimTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
@@ -495,6 +495,22 @@ public function testRouteWithoutSlashAndUrlWithOne()
}
/**
+ * Tests if route will match in case-insensitive manner if configured to do so
+ */
+ public function testRouteMatchesInCaseInsensitiveMannerIfConfigured()
+ {
+ \Slim\Environment::mock(array(
+ 'PATH_INFO' => '/BaR', // Does not match route case
+ ));
+ $s = new \Slim\Slim(array('routes.case_sensitive' => false));
+ $route = $s->get('/bar', function () { echo "xyz"; });
+ $s->call();
+ $this->assertEquals(200, $s->response()->status());
+ $this->assertEquals('xyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ }
+
+ /**
* Test if route contains URL encoded characters
*/
public function testRouteWithUrlEncodedCharacters()
View
2  tests/ViewTest.php
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
- * @version 2.3.5
+ * @version 2.4.2
*
* MIT LICENSE
*
View
3  tests/bootstrap.php
@@ -1,6 +1,9 @@
<?php
set_include_path(dirname(__FILE__) . '/../' . PATH_SEPARATOR . get_include_path());
+// Set default timezone
+date_default_timezone_set('America/New_York');
+
require_once 'Slim/Slim.php';
// Register Slim's autoloader
Something went wrong with that request. Please try again.