Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313664

Change subject: Update firebase/php-jwt from v3.0.0 to v4.0.0
......................................................................

Update firebase/php-jwt from v3.0.0 to v4.0.0

https://github.com/firebase/php-jwt/compare/v3.0.0...v4.0.0

Change-Id: I39d1045720bb59c9099c3342a65f2eef3ec6d87a
---
M autoload.php
M composer.json
M composer.lock
M composer/installed.json
D firebase/php-jwt/.gitignore
D firebase/php-jwt/.travis.yml
M firebase/php-jwt/README.md
D firebase/php-jwt/phpunit.xml.dist
D firebase/php-jwt/run-tests.sh
M firebase/php-jwt/src/JWT.php
D firebase/php-jwt/tests/JWTTest.php
D firebase/php-jwt/tests/autoload.php.dist
D firebase/php-jwt/tests/bootstrap.php
13 files changed, 104 insertions(+), 449 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vendor 
refs/changes/64/313664/1

diff --git a/autoload.php b/autoload.php
index 9bcfa9f..a5957bd 100644
--- a/autoload.php
+++ b/autoload.php
@@ -2,6 +2,6 @@
 
 // autoload.php @generated by Composer
 
-require_once __DIR__ . '/composer' . '/autoload_real.php';
+require_once __DIR__ . '/composer/autoload_real.php';
 
 return ComposerAutoloaderInit_mediawiki_vendor::getLoader();
diff --git a/composer.json b/composer.json
index 34f1ffa..5a1750c 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,7 @@
        "require": {
                "composer/semver": "1.4.1",
                "cssjanus/cssjanus": "1.1.2",
-               "firebase/php-jwt": "3.0.0",
+               "firebase/php-jwt": "4.0.0",
                "justinrainbow/json-schema": "3.0.0",
                "liuggio/statsd-php-client": "1.0.18",
                "mediawiki/at-ease": "1.1.0",
diff --git a/composer.lock b/composer.lock
index 05d57b9..fbe5aae 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,7 @@
         "Read more about it at 
https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";,
         "This file is @generated automatically"
     ],
-    "hash": "eb48dbe45827add41f49b7253513f912",
-    "content-hash": "d685c97157a41f98d586a2fd7df50044",
+    "content-hash": "e598cf510aafcd58fe44ace539813884",
     "packages": [
         {
             "name": "composer/semver",
@@ -106,16 +105,16 @@
         },
         {
             "name": "firebase/php-jwt",
-            "version": "v3.0.0",
+            "version": "v4.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/firebase/php-jwt.git";,
-                "reference": "fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1"
+                "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35"
             },
             "dist": {
                 "type": "zip",
-                "url": 
"https://api.github.com/repos/firebase/php-jwt/zipball/fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1";,
-                "reference": "fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1",
+                "url": 
"https://api.github.com/repos/firebase/php-jwt/zipball/dccf163dc8ed7ed6a00afc06c51ee5186a428d35";,
+                "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
                 "shasum": ""
             },
             "require": {
@@ -145,7 +144,7 @@
             ],
             "description": "A simple library to encode and decode JSON Web 
Tokens (JWT) in PHP. Should conform to the current spec.",
             "homepage": "https://github.com/firebase/php-jwt";,
-            "time": "2015-07-22 18:31:08"
+            "time": "2016-07-18 04:51:16"
         },
         {
             "name": "justinrainbow/json-schema",
diff --git a/composer/installed.json b/composer/installed.json
index d565246..8e7a34c 100644
--- a/composer/installed.json
+++ b/composer/installed.json
@@ -37,51 +37,6 @@
         "description": "Convert CSS stylesheets between left-to-right and 
right-to-left."
     },
     {
-        "name": "firebase/php-jwt",
-        "version": "v3.0.0",
-        "version_normalized": "3.0.0.0",
-        "source": {
-            "type": "git",
-            "url": "https://github.com/firebase/php-jwt.git";,
-            "reference": "fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1"
-        },
-        "dist": {
-            "type": "zip",
-            "url": 
"https://api.github.com/repos/firebase/php-jwt/zipball/fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1";,
-            "reference": "fa8a06e96526eb7c0eeaa47e4f39be59d21f16e1",
-            "shasum": ""
-        },
-        "require": {
-            "php": ">=5.3.0"
-        },
-        "time": "2015-07-22 18:31:08",
-        "type": "library",
-        "installation-source": "dist",
-        "autoload": {
-            "psr-4": {
-                "Firebase\\JWT\\": "src"
-            }
-        },
-        "notification-url": "https://packagist.org/downloads/";,
-        "license": [
-            "BSD-3-Clause"
-        ],
-        "authors": [
-            {
-                "name": "Neuman Vong",
-                "email": "[email protected]",
-                "role": "Developer"
-            },
-            {
-                "name": "Anant Narayanan",
-                "email": "[email protected]",
-                "role": "Developer"
-            }
-        ],
-        "description": "A simple library to encode and decode JSON Web Tokens 
(JWT) in PHP. Should conform to the current spec.",
-        "homepage": "https://github.com/firebase/php-jwt";
-    },
-    {
         "name": "liuggio/statsd-php-client",
         "version": "v1.0.18",
         "version_normalized": "1.0.18.0",
@@ -1967,5 +1922,50 @@
         ],
         "description": "Wait loop that reaches a condition or times out",
         "homepage": "https://www.mediawiki.org/wiki/WaitConditionLoop";
+    },
+    {
+        "name": "firebase/php-jwt",
+        "version": "v4.0.0",
+        "version_normalized": "4.0.0.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/firebase/php-jwt.git";,
+            "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/firebase/php-jwt/zipball/dccf163dc8ed7ed6a00afc06c51ee5186a428d35";,
+            "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.0"
+        },
+        "time": "2016-07-18 04:51:16",
+        "type": "library",
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "Firebase\\JWT\\": "src"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/";,
+        "license": [
+            "BSD-3-Clause"
+        ],
+        "authors": [
+            {
+                "name": "Neuman Vong",
+                "email": "[email protected]",
+                "role": "Developer"
+            },
+            {
+                "name": "Anant Narayanan",
+                "email": "[email protected]",
+                "role": "Developer"
+            }
+        ],
+        "description": "A simple library to encode and decode JSON Web Tokens 
(JWT) in PHP. Should conform to the current spec.",
+        "homepage": "https://github.com/firebase/php-jwt";
     }
 ]
diff --git a/firebase/php-jwt/.gitignore b/firebase/php-jwt/.gitignore
deleted file mode 100644
index 7c29c87..0000000
--- a/firebase/php-jwt/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-vendor
-phpunit.phar
-phpunit.phar.asc
-composer.phar
diff --git a/firebase/php-jwt/.travis.yml b/firebase/php-jwt/.travis.yml
deleted file mode 100644
index 0bd12c5..0000000
--- a/firebase/php-jwt/.travis.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-language: php
-
-php:
-  - 5.3
-  - 5.4
-  - 5.5
-  - hhvm
-
-before_script:
-  - wget -nc http://getcomposer.org/composer.phar
-  - php composer.phar install
-
-script: phpunit --configuration phpunit.xml.dist
diff --git a/firebase/php-jwt/README.md b/firebase/php-jwt/README.md
index 7f1b026..d4589b1 100644
--- a/firebase/php-jwt/README.md
+++ b/firebase/php-jwt/README.md
@@ -5,8 +5,7 @@
 
 PHP-JWT
 =======
-A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should
-conform to the [current 
spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06)
+A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming 
to [RFC 7519](https://tools.ietf.org/html/rfc7519).
 
 Installation
 ------------
@@ -65,6 +64,12 @@
 Changelog
 ---------
 
+#### 4.0.0 / 2016-07-17
+- Add support for late static binding. See 
[#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to 
[@chappy84](https://github.com/chappy84)!
+- Use static `$timestamp` instead of `time()` to improve unit testing. See 
[#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to 
[@josephmcdermott](https://github.com/josephmcdermott)!
+- Fixes to exceptions classes. See 
[#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to 
[@Maks3w](https://github.com/Maks3w)!
+- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for 
details. Thanks to [@akeeman](https://github.com/akeeman)!
+
 #### 3.0.0 / 2015-07-22
 - Minimum PHP version updated from `5.2.0` to `5.3.0`.
 - Add `\Firebase\JWT` namespace. See
diff --git a/firebase/php-jwt/phpunit.xml.dist 
b/firebase/php-jwt/phpunit.xml.dist
deleted file mode 100644
index 9f85f5b..0000000
--- a/firebase/php-jwt/phpunit.xml.dist
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit backupGlobals="false"
-         backupStaticAttributes="false"
-         colors="true"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="true"
-         convertWarningsToExceptions="true"
-         processIsolation="false"
-         stopOnFailure="false"
-         syntaxCheck="false"
-         bootstrap="tests/bootstrap.php"
->
-    <testsuites>
-        <testsuite name="PHP JSON Web Token Test Suite">
-            <directory>./tests</directory>
-        </testsuite>
-    </testsuites>
-</phpunit>
diff --git a/firebase/php-jwt/run-tests.sh b/firebase/php-jwt/run-tests.sh
deleted file mode 100755
index d37c30f..0000000
--- a/firebase/php-jwt/run-tests.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-
-#!/usr/bin/env bash
-gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
-if [ $? -ne 0 ]; then
-    echo -e "\033[33mDownloading PGP Public Key...\033[0m"
-    gpg --recv-keys D8406D0D82947747293778314AA394086372C20A
-    # Sebastian Bergmann <[email protected]>
-    gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
-    if [ $? -ne 0 ]; then
-        echo -e "\033[31mCould not download PGP public key for 
verification\033[0m"
-        exit
-    fi
-fi
-
-# Let's grab the latest release and its signature
-if [ ! -f phpunit.phar ]; then
-    wget https://phar.phpunit.de/phpunit.phar
-fi
-if [ ! -f phpunit.phar.asc ]; then
-    wget https://phar.phpunit.de/phpunit.phar.asc
-fi
-
-# Verify before running
-gpg --verify phpunit.phar.asc phpunit.phar
-if [ $? -eq 0 ]; then
-    echo
-    echo -e "\033[33mBegin Unit Testing\033[0m"
-    # Run the testing suite
-    php --version
-    php phpunit.phar --configuration phpunit.xml.dist
-else
-    echo
-    chmod -x phpunit.phar
-    mv phpunit.phar /tmp/bad-phpunit.phar
-    mv phpunit.phar.asc /tmp/bad-phpunit.phar.asc
-    echo -e "\033[31mSignature did not match! PHPUnit has been moved to 
/tmp/bad-phpunit.phar\033[0m"
-    exit 1
-fi
diff --git a/firebase/php-jwt/src/JWT.php b/firebase/php-jwt/src/JWT.php
index b3532df..6d30e94 100644
--- a/firebase/php-jwt/src/JWT.php
+++ b/firebase/php-jwt/src/JWT.php
@@ -29,6 +29,14 @@
      */
     public static $leeway = 0;
 
+    /**
+     * Allow the current timestamp to be specified.
+     * Useful for fixing a value within unit testing.
+     *
+     * Will default to PHP time() value if null.
+     */
+    public static $timestamp = null;
+
     public static $supported_algs = array(
         'HS256' => array('hash_hmac', 'SHA256'),
         'HS512' => array('hash_hmac', 'SHA512'),
@@ -39,15 +47,14 @@
     /**
      * Decodes a JWT string into a PHP object.
      *
-     * @param string            $jwt            The JWT
-     * @param string|array|null $key            The key, or map of keys.
-     *                                          If the algorithm used is 
asymmetric, this is the public key
-     * @param array             $allowed_algs   List of supported verification 
algorithms
-     *                                          Supported algorithms are 
'HS256', 'HS384', 'HS512' and 'RS256'
+     * @param string        $jwt            The JWT
+     * @param string|array  $key            The key, or map of keys.
+     *                                      If the algorithm used is 
asymmetric, this is the public key
+     * @param array         $allowed_algs   List of supported verification 
algorithms
+     *                                      Supported algorithms are 'HS256', 
'HS384', 'HS512' and 'RS256'
      *
      * @return object The JWT's payload as a PHP object
      *
-     * @throws DomainException              Algorithm was not provided
      * @throws UnexpectedValueException     Provided JWT was invalid
      * @throws SignatureInvalidException    Provided JWT was invalid because 
the signature verification failed
      * @throws BeforeValidException         Provided JWT is trying to be used 
before it's eligible as defined by 'nbf'
@@ -59,47 +66,52 @@
      */
     public static function decode($jwt, $key, $allowed_algs = array())
     {
+        $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
+
         if (empty($key)) {
             throw new InvalidArgumentException('Key may not be empty');
+        }
+        if (!is_array($allowed_algs)) {
+            throw new InvalidArgumentException('Algorithm not allowed');
         }
         $tks = explode('.', $jwt);
         if (count($tks) != 3) {
             throw new UnexpectedValueException('Wrong number of segments');
         }
         list($headb64, $bodyb64, $cryptob64) = $tks;
-        if (null === ($header = 
JWT::jsonDecode(JWT::urlsafeB64Decode($headb64)))) {
+        if (null === ($header = 
static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
             throw new UnexpectedValueException('Invalid header encoding');
         }
-        if (null === $payload = 
JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64))) {
+        if (null === $payload = 
static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
             throw new UnexpectedValueException('Invalid claims encoding');
         }
-        $sig = JWT::urlsafeB64Decode($cryptob64);
+        $sig = static::urlsafeB64Decode($cryptob64);
         
         if (empty($header->alg)) {
-            throw new DomainException('Empty algorithm');
+            throw new UnexpectedValueException('Empty algorithm');
         }
-        if (empty(self::$supported_algs[$header->alg])) {
-            throw new DomainException('Algorithm not supported');
+        if (empty(static::$supported_algs[$header->alg])) {
+            throw new UnexpectedValueException('Algorithm not supported');
         }
-        if (!is_array($allowed_algs) || !in_array($header->alg, 
$allowed_algs)) {
-            throw new DomainException('Algorithm not allowed');
+        if (!in_array($header->alg, $allowed_algs)) {
+            throw new UnexpectedValueException('Algorithm not allowed');
         }
         if (is_array($key) || $key instanceof \ArrayAccess) {
             if (isset($header->kid)) {
                 $key = $key[$header->kid];
             } else {
-                throw new DomainException('"kid" empty, unable to lookup 
correct key');
+                throw new UnexpectedValueException('"kid" empty, unable to 
lookup correct key');
             }
         }
 
         // Check the signature
-        if (!JWT::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
+        if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
             throw new SignatureInvalidException('Signature verification 
failed');
         }
 
         // Check if the nbf if it is defined. This is the time that the
         // token can actually be used. If it's not yet that time, abort.
-        if (isset($payload->nbf) && $payload->nbf > (time() + self::$leeway)) {
+        if (isset($payload->nbf) && $payload->nbf > ($timestamp + 
static::$leeway)) {
             throw new BeforeValidException(
                 'Cannot handle token prior to ' . date(DateTime::ISO8601, 
$payload->nbf)
             );
@@ -108,14 +120,14 @@
         // Check that this token has been created before 'now'. This prevents
         // using tokens that have been created for later use (and haven't
         // correctly used the nbf claim).
-        if (isset($payload->iat) && $payload->iat > (time() + self::$leeway)) {
+        if (isset($payload->iat) && $payload->iat > ($timestamp + 
static::$leeway)) {
             throw new BeforeValidException(
                 'Cannot handle token prior to ' . date(DateTime::ISO8601, 
$payload->iat)
             );
         }
 
         // Check if this token has expired.
-        if (isset($payload->exp) && (time() - self::$leeway) >= $payload->exp) 
{
+        if (isset($payload->exp) && ($timestamp - static::$leeway) >= 
$payload->exp) {
             throw new ExpiredException('Expired token');
         }
 
@@ -130,6 +142,7 @@
      *                                  If the algorithm used is asymmetric, 
this is the private key
      * @param string        $alg        The signing algorithm.
      *                                  Supported algorithms are 'HS256', 
'HS384', 'HS512' and 'RS256'
+     * @param mixed         $keyId
      * @param array         $head       An array with header elements to attach
      *
      * @return string A signed JWT
@@ -147,12 +160,12 @@
             $header = array_merge($head, $header);
         }
         $segments = array();
-        $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
-        $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload));
+        $segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
+        $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
         $signing_input = implode('.', $segments);
 
-        $signature = JWT::sign($signing_input, $key, $alg);
-        $segments[] = JWT::urlsafeB64Encode($signature);
+        $signature = static::sign($signing_input, $key, $alg);
+        $segments[] = static::urlsafeB64Encode($signature);
 
         return implode('.', $segments);
     }
@@ -171,10 +184,10 @@
      */
     public static function sign($msg, $key, $alg = 'HS256')
     {
-        if (empty(self::$supported_algs[$alg])) {
+        if (empty(static::$supported_algs[$alg])) {
             throw new DomainException('Algorithm not supported');
         }
-        list($function, $algorithm) = self::$supported_algs[$alg];
+        list($function, $algorithm) = static::$supported_algs[$alg];
         switch($function) {
             case 'hash_hmac':
                 return hash_hmac($algorithm, $msg, $key, true);
@@ -204,11 +217,11 @@
      */
     private static function verify($msg, $signature, $key, $alg)
     {
-        if (empty(self::$supported_algs[$alg])) {
+        if (empty(static::$supported_algs[$alg])) {
             throw new DomainException('Algorithm not supported');
         }
 
-        list($function, $algorithm) = self::$supported_algs[$alg];
+        list($function, $algorithm) = static::$supported_algs[$alg];
         switch($function) {
             case 'openssl':
                 $success = openssl_verify($msg, $signature, $key, $algorithm);
@@ -223,13 +236,13 @@
                 if (function_exists('hash_equals')) {
                     return hash_equals($signature, $hash);
                 }
-                $len = min(self::safeStrlen($signature), 
self::safeStrlen($hash));
+                $len = min(static::safeStrlen($signature), 
static::safeStrlen($hash));
 
                 $status = 0;
                 for ($i = 0; $i < $len; $i++) {
                     $status |= (ord($signature[$i]) ^ ord($hash[$i]));
                 }
-                $status |= (self::safeStrlen($signature) ^ 
self::safeStrlen($hash));
+                $status |= (static::safeStrlen($signature) ^ 
static::safeStrlen($hash));
 
                 return ($status === 0);
         }
@@ -263,7 +276,7 @@
         }
 
         if (function_exists('json_last_error') && $errno = json_last_error()) {
-            JWT::handleJsonError($errno);
+            static::handleJsonError($errno);
         } elseif ($obj === null && $input !== 'null') {
             throw new DomainException('Null result with non-null input');
         }
@@ -283,7 +296,7 @@
     {
         $json = json_encode($input);
         if (function_exists('json_last_error') && $errno = json_last_error()) {
-            JWT::handleJsonError($errno);
+            static::handleJsonError($errno);
         } elseif ($json === 'null' && $input !== null) {
             throw new DomainException('Null result with non-null input');
         }
diff --git a/firebase/php-jwt/tests/JWTTest.php 
b/firebase/php-jwt/tests/JWTTest.php
deleted file mode 100644
index 89de8d2..0000000
--- a/firebase/php-jwt/tests/JWTTest.php
+++ /dev/null
@@ -1,264 +0,0 @@
-<?php
-use \Firebase\JWT\JWT;
-
-class JWTTest extends PHPUnit_Framework_TestCase
-{
-    public function testEncodeDecode()
-    {
-        $msg = JWT::encode('abc', 'my_key');
-        $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 
'abc');
-    }
-
-    public function testDecodeFromPython()
-    {
-        $msg = 
'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.Iio6aHR0cDovL2FwcGxpY2F0aW9uL2NsaWNreT9ibGFoPTEuMjMmZi5vbz00NTYgQUMwMDAgMTIzIg.E_U8X2YpMT5K1cEiT_3-IvBYfrdIFIeVYeOqre_Z5Cg';
-        $this->assertEquals(
-            JWT::decode($msg, 'my_key', array('HS256')),
-            '*:http://application/clicky?blah=1.23&f.oo=456 AC000 123'
-        );
-    }
-
-    public function testUrlSafeCharacters()
-    {
-        $encoded = JWT::encode('f?', 'a');
-        $this->assertEquals('f?', JWT::decode($encoded, 'a', array('HS256')));
-    }
-
-    public function testMalformedUtf8StringsFail()
-    {
-        $this->setExpectedException('DomainException');
-        JWT::encode(pack('c', 128), 'a');
-    }
-
-    public function testMalformedJsonThrowsException()
-    {
-        $this->setExpectedException('DomainException');
-        JWT::jsonDecode('this is not valid JSON string');
-    }
-
-    public function testExpiredToken()
-    {
-        $this->setExpectedException('Firebase\JWT\ExpiredException');
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() - 20); // time in the past
-        $encoded = JWT::encode($payload, 'my_key');
-        JWT::decode($encoded, 'my_key', array('HS256'));
-    }
-
-    public function testBeforeValidTokenWithNbf()
-    {
-        $this->setExpectedException('Firebase\JWT\BeforeValidException');
-        $payload = array(
-            "message" => "abc",
-            "nbf" => time() + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        JWT::decode($encoded, 'my_key', array('HS256'));
-    }
-
-    public function testBeforeValidTokenWithIat()
-    {
-        $this->setExpectedException('Firebase\JWT\BeforeValidException');
-        $payload = array(
-            "message" => "abc",
-            "iat" => time() + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        JWT::decode($encoded, 'my_key', array('HS256'));
-    }
-
-    public function testValidToken()
-    {
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() + JWT::$leeway + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-    }
-
-    public function testValidTokenWithLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() - 20); // time in the past
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-        JWT::$leeway = 0;
-    }
-
-    public function testExpiredTokenWithLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() - 70); // time far in the past
-        $this->setExpectedException('Firebase\JWT\ExpiredException');
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-        JWT::$leeway = 0;
-    }
-
-    public function testValidTokenWithList()
-    {
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256', 'HS512'));
-        $this->assertEquals($decoded->message, 'abc');
-    }
-
-    public function testValidTokenWithNbf()
-    {
-        $payload = array(
-            "message" => "abc",
-            "iat" => time(),
-            "exp" => time() + 20, // time in the future
-            "nbf" => time() - 20);
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-    }
-
-    public function testValidTokenWithNbfLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "nbf"     => time() + 20); // not before in near (leeway) future
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-        JWT::$leeway = 0;
-    }
-
-    public function testInvalidTokenWithNbfLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "nbf"     => time() + 65); // not before too far in future
-        $encoded = JWT::encode($payload, 'my_key');
-        $this->setExpectedException('Firebase\JWT\BeforeValidException');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        JWT::$leeway = 0;
-    }
-
-    public function testValidTokenWithIatLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "iat"     => time() + 20); // issued in near (leeway) future
-        $encoded = JWT::encode($payload, 'my_key');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        $this->assertEquals($decoded->message, 'abc');
-        JWT::$leeway = 0;
-    }
-
-    public function testInvalidTokenWithIatLeeway()
-    {
-        JWT::$leeway = 60;
-        $payload = array(
-            "message" => "abc",
-            "iat"     => time() + 65); // issued too far in future
-        $encoded = JWT::encode($payload, 'my_key');
-        $this->setExpectedException('Firebase\JWT\BeforeValidException');
-        $decoded = JWT::decode($encoded, 'my_key', array('HS256'));
-        JWT::$leeway = 0;
-    }
-
-    public function testInvalidToken()
-    {
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        $this->setExpectedException('Firebase\JWT\SignatureInvalidException');
-        $decoded = JWT::decode($encoded, 'my_key2', array('HS256'));
-    }
-
-    public function testNullKeyFails()
-    {
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() + JWT::$leeway + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        $this->setExpectedException('InvalidArgumentException');
-        $decoded = JWT::decode($encoded, null, array('HS256'));
-    }
-
-    public function testEmptyKeyFails()
-    {
-        $payload = array(
-            "message" => "abc",
-            "exp" => time() + JWT::$leeway + 20); // time in the future
-        $encoded = JWT::encode($payload, 'my_key');
-        $this->setExpectedException('InvalidArgumentException');
-        $decoded = JWT::decode($encoded, '', array('HS256'));
-    }
-
-    public function testRSEncodeDecode()
-    {
-        $privKey = openssl_pkey_new(array('digest_alg' => 'sha256',
-            'private_key_bits' => 1024,
-            'private_key_type' => OPENSSL_KEYTYPE_RSA));
-        $msg = JWT::encode('abc', $privKey, 'RS256');
-        $pubKey = openssl_pkey_get_details($privKey);
-        $pubKey = $pubKey['key'];
-        $decoded = JWT::decode($msg, $pubKey, array('RS256'));
-        $this->assertEquals($decoded, 'abc');
-    }
-
-    public function testKIDChooser()
-    {
-        $keys = array('1' => 'my_key', '2' => 'my_key2');
-        $msg = JWT::encode('abc', $keys['1'], 'HS256', '1');
-        $decoded = JWT::decode($msg, $keys, array('HS256'));
-        $this->assertEquals($decoded, 'abc');
-    }
-
-    public function testArrayAccessKIDChooser()
-    {
-        $keys = new ArrayObject(array('1' => 'my_key', '2' => 'my_key2'));
-        $msg = JWT::encode('abc', $keys['1'], 'HS256', '1');
-        $decoded = JWT::decode($msg, $keys, array('HS256'));
-        $this->assertEquals($decoded, 'abc');
-    }
-
-    public function testNoneAlgorithm()
-    {
-        $msg = JWT::encode('abc', 'my_key');
-        $this->setExpectedException('DomainException');
-        JWT::decode($msg, 'my_key', array('none'));
-    }
-
-    public function testIncorrectAlgorithm()
-    {
-        $msg = JWT::encode('abc', 'my_key');
-        $this->setExpectedException('DomainException');
-        JWT::decode($msg, 'my_key', array('RS256'));
-    }
-
-    public function testMissingAlgorithm()
-    {
-        $msg = JWT::encode('abc', 'my_key');
-        $this->setExpectedException('DomainException');
-        JWT::decode($msg, 'my_key');
-    }
-
-    public function testAdditionalHeaders()
-    {
-        $msg = JWT::encode('abc', 'my_key', 'HS256', null, array('cty' => 
'test-eit;v=1'));
-        $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 
'abc');        
-    }
-
-    public function testInvalidSegmentCount()
-    {
-        $this->setExpectedException('UnexpectedValueException');
-        JWT::decode('brokenheader.brokenbody', 'my_key', array('HS256'));
-    }
-}
diff --git a/firebase/php-jwt/tests/autoload.php.dist 
b/firebase/php-jwt/tests/autoload.php.dist
deleted file mode 100644
index 2e4310a..0000000
--- a/firebase/php-jwt/tests/autoload.php.dist
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-// if the library is the project, try to use the composer's autoload for the 
tests
-$composerAutoload = __DIR__ . '/../vendor/autoload.php';
-
-if (is_file($composerAutoload)) {
-    include $composerAutoload;
-} else {
-    die('Unable to find autoload.php file, please use composer to load 
dependencies:
-
-wget http://getcomposer.org/composer.phar
-php composer.phar install
-
-Visit http://getcomposer.org/ for more information.
-
-');
-}
diff --git a/firebase/php-jwt/tests/bootstrap.php 
b/firebase/php-jwt/tests/bootstrap.php
deleted file mode 100644
index 326c216..0000000
--- a/firebase/php-jwt/tests/bootstrap.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-if (file_exists($file = __DIR__ . '/autoload.php')) {
-    require_once $file;
-} elseif (file_exists($file = __DIR__ . '/autoload.php.dist')) {
-    require_once $file;
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/313664
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39d1045720bb59c9099c3342a65f2eef3ec6d87a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vendor
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to