From 66bf21356bf1ecbce41cb4327f738f5d8e1f39d6 Mon Sep 17 00:00:00 2001 From: Spomky Date: Sun, 2 Nov 2014 17:32:08 +0100 Subject: [PATCH] Window added and structural changes --- .travis.yml | 2 +- composer.json | 6 +- composer.lock | 756 +++++++------------------------------------ doc/Contributing.md | 6 +- lib/HOTP.php | 17 +- lib/OTPInterface.php | 3 +- lib/TOTP.php | 17 +- phpunit.xml.dist | 2 +- tests/HOTPTest.php | 31 ++ tests/OTPTest.php | 14 - tests/TOTPTest.php | 17 + tests/bootstrap.php | 5 - 12 files changed, 205 insertions(+), 671 deletions(-) delete mode 100644 tests/bootstrap.php diff --git a/.travis.yml b/.travis.yml index e934a12d..acad57e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ script: after_script: - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --access-token="9f7c1f77406519d4acf36b843e6838dee2a5a6ae51c86fd7e96b7ea33897f513" --format=php-clover ./build/logs/clover.xml + - php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml diff --git a/composer.json b/composer.json index fbaa3d6a..173fdc4a 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,16 @@ "christian-riesen/base32": "~1.1" }, "require-dev": { - "phpunit/phpunit": "4.*", - "satooshi/php-coveralls": "0.*" + "phpunit/phpunit": "4.*" }, "suggest": { }, "autoload": { "psr-4": { "OTPHP\\": "lib/" } }, + "autoload-dev": { + "psr-4": { "OTPHP\\": "tests/" } + }, "extra": { "branch-alias": { "dev-master": "3.1.x-dev" diff --git a/composer.lock b/composer.lock index 038dbaa7..91e83e5a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,38 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "431f994b74b976500a75267f586f3a94", + "hash": "02f25814cc702569e735c23d27f56ccf", "packages": [ { "name": "christian-riesen/base32", - "version": "1.1", + "version": "1.2", "source": { "type": "git", "url": "https://github.com/ChristianRiesen/base32.git", - "reference": "1d5a90243be4daafd4b50e03b4978f1477e8dd20" + "reference": "b883c3f4bf6f3219c1e9acb7c89f197cbf7b19c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ChristianRiesen/base32/zipball/1d5a90243be4daafd4b50e03b4978f1477e8dd20", - "reference": "1d5a90243be4daafd4b50e03b4978f1477e8dd20", + "url": "https://api.github.com/repos/ChristianRiesen/base32/zipball/b883c3f4bf6f3219c1e9acb7c89f197cbf7b19c4", + "reference": "b883c3f4bf6f3219c1e9acb7c89f197cbf7b19c4", "shasum": "" }, "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "0.*" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, "autoload": { - "psr-0": { - "Base32": "src" + "psr-4": { + "Base32\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -41,7 +50,7 @@ "role": "Developer" } ], - "description": "Base32 encoder/decoder, unit tested, according to RFC 4648", + "description": "Base32 encoder/decoder according to RFC 4648", "homepage": "https://github.com/ChristianRiesen/base32", "keywords": [ "base32", @@ -49,122 +58,30 @@ "encode", "rfc4648" ], - "time": "2013-01-29 09:48:22" + "time": "2014-08-11 15:45:52" } ], "packages-dev": [ { - "name": "guzzle/guzzle", - "version": "v3.9.1", + "name": "doctrine/instantiator", + "version": "1.0.4", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle3.git", - "reference": "92d9934f2fca1da15178c91239576ae26e505e60" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/92d9934f2fca1da15178c91239576ae26e505e60", - "reference": "92d9934f2fca1da15178c91239576ae26e505e60", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", "shasum": "" }, "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "~1.3", - "monolog/monolog": "~1.0", - "phpunit/phpunit": "3.7.*", - "psr/log": "~1.0", - "symfony/class-loader": "~2.1", - "zendframework/zend-cache": "2.*,<2.3", - "zendframework/zend-log": "2.*,<2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.8-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2014-05-07 17:04:22" - }, - { - "name": "ocramius/instantiator", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/Instantiator.git", - "reference": "cc754c2289ffd4483c319f6ed6ee88ce21676f64" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/Instantiator/zipball/cc754c2289ffd4483c319f6ed6ee88ce21676f64", - "reference": "cc754c2289ffd4483c319f6ed6ee88ce21676f64", - "shasum": "" - }, - "require": { - "ocramius/lazy-map": "1.0.*", - "php": "~5.3" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", + "ext-pdo": "*", "ext-phar": "*", "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "2.0.*@ALPHA" @@ -172,12 +89,12 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-0": { - "Instantiator\\": "src" + "Doctrine\\Instantiator\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -188,101 +105,42 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/", - "role": "Developer" + "homepage": "http://ocramius.github.com/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/Ocramius/Instantiator", + "homepage": "https://github.com/doctrine/instantiator", "keywords": [ "constructor", "instantiate" ], - "time": "2014-06-15 11:44:46" - }, - { - "name": "ocramius/lazy-map", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/LazyMap.git", - "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/LazyMap/zipball/7fe3d347f5e618bcea7d39345ff83f3651d8b752", - "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "athletic/athletic": "~0.1.6", - "phpmd/phpmd": "1.5.*", - "phpunit/phpunit": ">=3.7", - "satooshi/php-coveralls": "~0.6", - "squizlabs/php_codesniffer": "1.4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "LazyMap\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/", - "role": "Developer" - } - ], - "description": "A library that provides lazy instantiation logic for a map of objects", - "homepage": "https://github.com/Ocramius/LazyMap", - "keywords": [ - "lazy", - "lazy instantiation", - "lazy loading", - "map", - "service location" - ], - "time": "2013-11-09 22:30:54" + "time": "2014-10-13 12:58:55" }, { "name": "phpunit/php-code-coverage", - "version": "2.0.10", + "version": "2.0.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6d196af48e8c100a3ae881940123e693da5a9217" + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6d196af48e8c100a3ae881940123e693da5a9217", - "reference": "6d196af48e8c100a3ae881940123e693da5a9217", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", "shasum": "" }, "require": { "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3.1", - "phpunit/php-text-template": "~1.2.0", - "phpunit/php-token-stream": "~1.2.2", - "sebastian/environment": "~1.0.0", - "sebastian/version": "~1.0.3" + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" }, "require-dev": { "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.0.14" + "phpunit/phpunit": "~4.1" }, "suggest": { "ext-dom": "*", @@ -321,7 +179,7 @@ "testing", "xunit" ], - "time": "2014-08-06 06:39:42" + "time": "2014-08-31 06:33:04" }, { "name": "phpunit/php-file-iterator", @@ -458,45 +316,44 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.2.2", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", "shasum": "" }, "require": { "ext-tokenizer": "*", "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], "description": "Wrapper around PHP's tokenizer extension.", @@ -504,20 +361,20 @@ "keywords": [ "tokenizer" ], - "time": "2014-03-03 05:10:30" + "time": "2014-08-31 06:12:13" }, { "name": "phpunit/phpunit", - "version": "4.2.0", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "58db726aa45fe26bca93f692cb3d77e9a46b7830" + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/58db726aa45fe26bca93f692cb3d77e9a46b7830", - "reference": "58db726aa45fe26bca93f692cb3d77e9a46b7830", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/23e4e0310f037aae873cc81b8658dbbb82878f71", + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71", "shasum": "" }, "require": { @@ -528,10 +385,10 @@ "ext-spl": "*", "php": ">=5.3.3", "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-file-iterator": "~1.3.2", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.2", + "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.0", "sebastian/diff": "~1.1", "sebastian/environment": "~1.0", @@ -548,7 +405,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2.x-dev" + "dev-master": "4.3.x-dev" } }, "autoload": { @@ -578,29 +435,29 @@ "testing", "xunit" ], - "time": "2014-08-08 05:13:30" + "time": "2014-10-22 11:43:12" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "42e589e08bc86e3e9bdf20d385e948347788505b" + "reference": "c63d2367247365f688544f0d500af90a11a44c65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/42e589e08bc86e3e9bdf20d385e948347788505b", - "reference": "42e589e08bc86e3e9bdf20d385e948347788505b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", "shasum": "" }, "require": { - "ocramius/instantiator": "~1.0", + "doctrine/instantiator": "~1.0,>=1.0.1", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2" }, "require-dev": { - "phpunit/phpunit": "4.2.*@dev" + "phpunit/phpunit": "~4.3" }, "suggest": { "ext-soap": "*" @@ -608,7 +465,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "2.3.x-dev" } }, "autoload": { @@ -617,9 +474,6 @@ ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -636,126 +490,20 @@ "mock", "xunit" ], - "time": "2014-08-02 13:50:58" - }, - { - "name": "psr/log", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Psr\\Log\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" - }, - { - "name": "satooshi/php-coveralls", - "version": "v0.6.1", - "source": { - "type": "git", - "url": "https://github.com/satooshi/php-coveralls.git", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": ">=3.0", - "php": ">=5.3", - "psr/log": "1.0.0", - "symfony/config": ">=2.0", - "symfony/console": ">=2.0", - "symfony/stopwatch": ">=2.2", - "symfony/yaml": ">=2.0" - }, - "require-dev": { - "apigen/apigen": "2.8.*@stable", - "pdepend/pdepend": "dev-master", - "phpmd/phpmd": "dev-master", - "phpunit/php-invoker": ">=1.1.0,<1.2.0", - "phpunit/phpunit": "3.7.*@stable", - "sebastian/finder-facade": "dev-master", - "sebastian/phpcpd": "1.4.*@stable", - "squizlabs/php_codesniffer": "1.4.*@stable", - "theseer/fdomdocument": "dev-master" - }, - "bin": [ - "composer/bin/coveralls" - ], - "type": "library", - "autoload": { - "psr-0": { - "Contrib\\Component": "src/", - "Contrib\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/satooshi/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "time": "2013-05-04 08:07:33" + "time": "2014-10-03 05:12:11" }, { "name": "sebastian/comparator", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", "shasum": "" }, "require": { @@ -782,11 +530,6 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -798,6 +541,10 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -807,29 +554,32 @@ "compare", "equality" ], - "time": "2014-05-02 07:05:58" + "time": "2014-05-11 23:00:21" }, { "name": "sebastian/diff", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -842,14 +592,13 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Kore Nordmann", "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], "description": "Diff implementation", @@ -857,32 +606,32 @@ "keywords": [ "diff" ], - "time": "2013-08-03 16:46:33" + "time": "2014-08-15 10:29:00" }, { "name": "sebastian/environment", - "version": "1.0.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "phpunit/phpunit": "~4.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -897,8 +646,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], "description": "Provides functionality to handle HHVM/PHP environments", @@ -908,27 +656,27 @@ "environment", "hhvm" ], - "time": "2014-02-18 16:17:19" + "time": "2014-10-22 06:38:05" }, { "name": "sebastian/exporter", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "phpunit/phpunit": "~4.0" }, "type": "library", "extra": { @@ -946,11 +694,6 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -959,14 +702,17 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net", - "role": "Lead" - }, { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -975,7 +721,7 @@ "export", "exporter" ], - "time": "2014-02-16 08:26:31" + "time": "2014-09-10 00:51:36" }, { "name": "sebastian/version", @@ -1012,273 +758,19 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2014-03-07 15:35:33" }, - { - "name": "symfony/config", - "version": "v2.5.3", - "target-dir": "Symfony/Component/Config", - "source": { - "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "8d044668c7ccb4ade684e368d910e3aadcff6f6c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/8d044668c7ccb4ade684e368d910e3aadcff6f6c", - "reference": "8d044668c7ccb4ade684e368d910e3aadcff6f6c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Config\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Config Component", - "homepage": "http://symfony.com", - "time": "2014-08-05 09:00:40" - }, - { - "name": "symfony/console", - "version": "v2.5.3", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/cd2d1e4bac2206b337326b0140ff475fe9ad5f63", - "reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2014-08-05 09:00:40" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.5.3", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.0", - "symfony/stopwatch": "~2.2" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2014-07-28 13:20:46" - }, - { - "name": "symfony/filesystem", - "version": "v2.5.3", - "target-dir": "Symfony/Component/Filesystem", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "c1309b0ee195ad264a4314435bdaecdfacb8ae9c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/c1309b0ee195ad264a4314435bdaecdfacb8ae9c", - "reference": "c1309b0ee195ad264a4314435bdaecdfacb8ae9c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "http://symfony.com", - "time": "2014-07-09 09:05:48" - }, - { - "name": "symfony/stopwatch", - "version": "v2.5.3", - "target-dir": "Symfony/Component/Stopwatch", - "source": { - "type": "git", - "url": "https://github.com/symfony/Stopwatch.git", - "reference": "086c8c98c3016f59f5e6e7b15b751c2384b311e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/086c8c98c3016f59f5e6e7b15b751c2384b311e5", - "reference": "086c8c98c3016f59f5e6e7b15b751c2384b311e5", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Stopwatch\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "http://symfony.com", - "time": "2014-08-06 06:44:37" - }, { "name": "symfony/yaml", - "version": "v2.5.3", + "version": "v2.5.6", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f" + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f", - "reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726", "shasum": "" }, "require": { @@ -1311,21 +803,15 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-08-05 09:00:40" + "time": "2014-10-01 05:50:18" } ], - "aliases": [ - - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": [], "prefer-stable": false, "platform": { "php": ">=5.3.2" }, - "platform-dev": [ - - ] + "platform-dev": [] } diff --git a/doc/Contributing.md b/doc/Contributing.md index 007d0dc4..5c8628de 100644 --- a/doc/Contributing.md +++ b/doc/Contributing.md @@ -19,6 +19,6 @@ May be asked to squash your commits too. This is used to "clean" your Pull Reque Run test suite ------------ -* install composer: curl -s http://getcomposer.org/installer | php -* install dependencies: php composer.phar install --dev; -* run tests: vendor/bin/phpunit +* install composer: `curl -s http://getcomposer.org/installer | php` +* install dependencies: `php composer.phar install --dev` +* run tests: `vendor/bin/phpunit` diff --git a/lib/HOTP.php b/lib/HOTP.php index 12bb2082..088a05ca 100644 --- a/lib/HOTP.php +++ b/lib/HOTP.php @@ -20,18 +20,23 @@ abstract protected function updateCounter($counter); /** * {@inheritdoc} */ - public function verify($otp, $counter) + public function verify($otp, $counter, $window = null) { if ($counter < $this->getCounter()) { return false; } - $result = $otp === $this->at($counter); - - if (true === $result) { - $this->updateCounter($counter+1); + if(!is_integer($window)) { + $window = 0; } - return $result; + for ($i=$counter; $i <= $counter+abs($window); $i++) { + if ($otp === $this->at($i)) { + $this->updateCounter($i+1); + return true; + } + } + + return false; } } diff --git a/lib/OTPInterface.php b/lib/OTPInterface.php index 2104a4fa..618ae62e 100644 --- a/lib/OTPInterface.php +++ b/lib/OTPInterface.php @@ -16,10 +16,11 @@ public function at($input); * * @param string $otp * @param integer|null $input + * @param integer|null $window * * @return boolean */ - public function verify($otp, $input); + public function verify($otp, $input, $window = null); /** * @return string The secret of the OTP diff --git a/lib/TOTP.php b/lib/TOTP.php index 037e0a8b..731c9c9b 100644 --- a/lib/TOTP.php +++ b/lib/TOTP.php @@ -23,12 +23,23 @@ public function now() /** * {@inheritdoc} */ - public function verify($otp, $timestamp = null) + public function verify($otp, $timestamp = null, $window = null) { - if($timestamp === null) + if($timestamp === null) { $timestamp = time(); + } - return $otp === $this->at($timestamp); + if(!is_integer($window)) { + return $otp === $this->at($timestamp); + } + + for ($i=-abs($window); $i <= abs($window); $i++) { + if ($otp === $this->at($i*$this->getInterval()+$timestamp)) { + return true; + } + } + + return false; } /** diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 435b7426..65465190 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="tests/bootstrap.php" + bootstrap="vendor/autoload.php" colors="true"> diff --git a/tests/HOTPTest.php b/tests/HOTPTest.php index 71da547e..f2c960c1 100644 --- a/tests/HOTPTest.php +++ b/tests/HOTPTest.php @@ -113,4 +113,35 @@ public function testVerifyCounterChanged() $otp->verify(98449994, 1100); $this->assertFalse($otp->verify(111, 1099)); } + + public function testVerifyValidInWindow() + { + $otp = $this->getMockBuilder('OTPHP\HOTP') + ->setMethods(array('getSecret', 'getDigits', 'getDigest', 'getIssuer', 'getLabel', 'isIssuerIncludedAsParameter', 'getCounter', 'updateCounter')) + ->getMock(); + + $otp->expects($this->any()) + ->method('getLabel') + ->will($this->returnValue('alice@foo.bar')); + + $otp->expects($this->any()) + ->method('getSecret') + ->will($this->returnValue('JDDK4U6G3BJLEZ7Y')); + + $otp->expects($this->any()) + ->method('getIssuer') + ->will($this->returnValue('My Project')); + + $otp->expects($this->any()) + ->method('getDigest') + ->will($this->returnValue('sha1')); + + $otp->expects($this->any()) + ->method('getDigits') + ->will($this->returnValue(8)); + + $this->assertTrue($otp->verify(59647237, 1000, 50)); + $this->assertFalse($otp->verify(51642065, 1000, 50)); + $this->assertTrue($otp->verify(51642065, 1000, 100)); + } } diff --git a/tests/OTPTest.php b/tests/OTPTest.php index 3dc027cc..82516536 100644 --- a/tests/OTPTest.php +++ b/tests/OTPTest.php @@ -27,20 +27,6 @@ public function testGenerateOtpAt() $this->assertEquals(654666, $otp->at(1500)); } - public function testHasSemicolon() - { - $otp = $this->getMockBuilder('OTPHP\OTP') - ->getMock(); - - $method = self::getMethod('hasSemicolon'); - - $this->assertTrue($method->invokeArgs($otp,array('my:test'))); - $this->assertTrue($method->invokeArgs($otp,array('my%3atest'))); - $this->assertTrue($method->invokeArgs($otp,array('my%3Atest'))); - - $this->assertFalse($method->invokeArgs($otp,array('my test'))); - } - /** * @expectedException Exception */ diff --git a/tests/TOTPTest.php b/tests/TOTPTest.php index 397dbacc..49320252 100644 --- a/tests/TOTPTest.php +++ b/tests/TOTPTest.php @@ -53,6 +53,12 @@ public function testGenerateOtpNow() $this->assertEquals($this->otp->now(), $this->otp->at(time())); } + public function testVerifyOtpNow() + { + $totp = $this->otp->at(time()); + $this->assertTrue($this->otp->verify($totp)); + } + public function testVerifyOtp() { $this->assertTrue($this->otp->verify(855783, 0)); @@ -63,4 +69,15 @@ public function testVerifyOtp() $this->assertFalse($this->otp->verify(139664, 1301012167)); $this->assertFalse($this->otp->verify(139664, 1301012197)); } + + public function testVerifyOtpInWindow() + { + $this->assertFalse($this->otp->verify(54409, 319690800, 10)); // -11 intervals + $this->assertTrue($this->otp->verify(808167, 319690800, 10)); // -10 intervals + $this->assertTrue($this->otp->verify(364393, 319690800, 10)); // -9 intervals + $this->assertTrue($this->otp->verify(762124, 319690800, 10)); // 0 intervals + $this->assertTrue($this->otp->verify(988451, 319690800, 10)); // +9 intervals + $this->assertTrue($this->otp->verify(789387, 319690800, 10)); // +10 intervals + $this->assertFalse($this->otp->verify(465009, 319690800, 10)); // +11 intervals + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 2adcc072..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ -add("OTPHP", __DIR__); -$loader->register();