From db13f5fb6ef6887065d6580badea94aa5f1c42e2 Mon Sep 17 00:00:00 2001 From: Gerry Hall Date: Sat, 14 Mar 2015 15:32:21 +0000 Subject: [PATCH 01/33] add new test which validate correct Exception in Resository::create this thrown if $params fails. --- .../Tests/API/Repositories/RepositoryTest.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php index 19debcc..7f097a9 100644 --- a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php +++ b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php @@ -25,6 +25,46 @@ public function testGetRepository() $this->assertEquals($expectedResult, $actual); } + /** + * @return array of invalid value for repo creations parameter + */ + public function invalidCreateProvider() + { + return array( + array(''), + array("\t"), + array("\n"), + array(' '), + array("{ 'bar': 'baz' }"), + array('{ repo: "company", }'), + array('{ repo: "company" }'), + array( + substr( + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + mt_rand( 0 ,50 ) ,1 ) .substr( md5( time() ), 1) + ) + ); + + } + + /** + * @param $check + * @param $expectation + * @return mixed + * @expectedException \InvalidArgumentException + * @dataProvider invalidCreateProvider + */ + public function testInvalidCreate($check) + { + + $client = $this->getHttpClientMock(); + + /** @var \Bitbucket\API\Repositories\Repository $repo */ + $repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client); + $this->setExpectedException('\InvalidArgumentException'); + $repo->create('gentle', 'new-repo', $check); + } + public function testCreateRepositoryFromJSON() { $endpoint = 'repositories/gentle/new-repo'; From 1d555027cf60a99384c8717a3422362a65661b12 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 18 May 2015 15:23:15 +0300 Subject: [PATCH 02/33] Updated badges in README [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 267af84..8bbb2e5 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![Latest Version](https://img.shields.io/packagist/v/gentle/bitbucket-api.svg?style=flat-square)](https://packagist.org/packages/gentle/bitbucket-api) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/gentlero/bitbucket-api/blob/master/LICENSE) [![Build Status](http://img.shields.io/travis/gentlero/bitbucket-api/master.svg?style=flat-square)](https://travis-ci.org/gentlero/bitbucket-api) -[![Coverage Status](https://img.shields.io/scrutinizer/coverage/b/gentlero/bitbucket-api/master.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=master) -[![Code quality](http://img.shields.io/scrutinizer/b/gentlero/bitbucket-api/master.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=master) +[![Coverage Status](https://img.shields.io/scrutinizer/coverage/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) +[![Code quality](http://img.shields.io/scrutinizer/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) Simple Bitbucket API wrapper for PHP >= 5.3.2. From ce1708afa9eca5cc69e80253c1ae5f4d41c25b94 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 18 May 2015 19:10:15 +0300 Subject: [PATCH 03/33] Updated badges in docs [ci skip] --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 7784c21..2220349 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,8 +9,8 @@ title: Introduction [![Latest Version](https://img.shields.io/packagist/v/gentle/bitbucket-api.svg?style=flat-square)](https://packagist.org/packages/gentle/bitbucket-api) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/gentlero/bitbucket-api/blob/master/LICENSE) [![Build Status](http://img.shields.io/travis/gentlero/bitbucket-api/master.svg?style=flat-square)](https://travis-ci.org/gentlero/bitbucket-api) -[![Coverage Status](https://img.shields.io/scrutinizer/coverage/b/gentlero/bitbucket-api/master.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=master) -[![Code quality](http://img.shields.io/scrutinizer/b/gentlero/bitbucket-api/master.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=master) +[![Coverage Status](https://img.shields.io/scrutinizer/coverage/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) +[![Code quality](http://img.shields.io/scrutinizer/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) ### What is this ? From f9d60171faf8b4f5ce288fb4fa9efeb52a5f12d3 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 11:04:45 +0300 Subject: [PATCH 04/33] updated phpunit config --- phpunit.xml.dist | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1a98591..1a38b6b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,16 +13,20 @@ > - ./test/Bitbucket/Tests/API/ + test/ - ./lib/Bitbucket/API/ + lib/ + + + + From 6a8abcd0662486fd82d0e1dd45b05b10c5847c16 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 11:05:25 +0300 Subject: [PATCH 05/33] updated composer.json: added test script --- composer.json | 3 +++ composer.lock | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c97e928..196e0bc 100644 --- a/composer.json +++ b/composer.json @@ -29,5 +29,8 @@ }, "autoload": { "psr-0": { "Bitbucket\\": "lib/" } + }, + "scripts": { + "test": "vendor/bin/phpunit" } } diff --git a/composer.lock b/composer.lock index 0358fa4..20c40b1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fb85915a2200e1d6a996625a116283af", + "hash": "241640db17ed33fb8d97ab700c3fee1b", "packages": [ { "name": "jacobkiers/oauth", From c7be1e6f7068e2ed15f3c443cac9b36b7372f4f1 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 11:06:42 +0300 Subject: [PATCH 06/33] updated composer.json: added ocular --- composer.json | 3 +- composer.lock | 678 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 679 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 196e0bc..63bfad2 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "jacobkiers/oauth": "~1.0.10" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*", + "scrutinizer/ocular": "~1.1" }, "conflict": { "eabay/bitbucket-repo-sync": "*" diff --git a/composer.lock b/composer.lock index 20c40b1..0336e7e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "241640db17ed33fb8d97ab700c3fee1b", + "hash": "6065882ec9120ab2692e9ab31fcf26ba", "packages": [ { "name": "jacobkiers/oauth", @@ -115,6 +115,479 @@ } ], "packages-dev": [ + { + "name": "doctrine/annotations", + "version": "v1.2.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/b5202eb9e83f8db52e0e58867e0a46e63be8332e", + "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2014-12-23 22:40:37" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09 13:34:57" + }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "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" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-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": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, + { + "name": "jms/metadata", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/metadata.git", + "reference": "22b72455559a25777cfd28c4ffda81ff7639f353" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/22b72455559a25777cfd28c4ffda81ff7639f353", + "reference": "22b72455559a25777cfd28c4ffda81ff7639f353", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "doctrine/cache": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Metadata\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache" + ], + "authors": [ + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Class/method/property metadata management in PHP", + "keywords": [ + "annotations", + "metadata", + "xml", + "yaml" + ], + "time": "2014-07-12 07:13:19" + }, + { + "name": "jms/parser-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/parser-lib.git", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "shasum": "" + }, + "require": { + "phpoption/phpoption": ">=0.9,<2.0-dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "description": "A library for easily creating recursive-descent parsers.", + "time": "2012-11-18 18:08:43" + }, + { + "name": "jms/serializer", + "version": "0.16.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/serializer.git", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/c8a171357ca92b6706e395c757f334902d430ea9", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "jms/metadata": "~1.1", + "jms/parser-lib": "1.*", + "php": ">=5.3.2", + "phpcollection/phpcollection": "~0.1" + }, + "require-dev": { + "doctrine/orm": "~2.1", + "doctrine/phpcr-odm": "~1.0.1", + "jackalope/jackalope-doctrine-dbal": "1.0.*", + "propel/propel1": "~1.7", + "symfony/filesystem": "2.*", + "symfony/form": "~2.1", + "symfony/translation": "~2.0", + "symfony/validator": "~2.0", + "symfony/yaml": "2.*", + "twig/twig": ">=1.8,<2.0-dev" + }, + "suggest": { + "symfony/yaml": "Required if you'd like to serialize data to YAML format." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.15-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\Serializer": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.", + "homepage": "http://jmsyst.com/libs/serializer", + "keywords": [ + "deserialization", + "jaxb", + "json", + "serialization", + "xml" + ], + "time": "2014-03-18 08:39:00" + }, + { + "name": "phpcollection/phpcollection", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-collection.git", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/b8bf55a0a929ca43b01232b36719f176f86c7e83", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83", + "shasum": "" + }, + "require": { + "phpoption/phpoption": "1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpCollection": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "General-Purpose Collection Library for PHP", + "keywords": [ + "collection", + "list", + "map", + "sequence", + "set" + ], + "time": "2014-03-11 13:46:42" + }, + { + "name": "phpoption/phpoption", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpOption\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "time": "2014-01-09 22:37:17" + }, { "name": "phpunit/php-code-coverage", "version": "1.2.18", @@ -481,6 +954,209 @@ ], "time": "2013-01-13 10:24:48" }, + { + "name": "scrutinizer/ocular", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/scrutinizer-ci/ocular.git", + "reference": "8e0a8c7f085bc4857bd52132833679dcfd504fc1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/scrutinizer-ci/ocular/zipball/8e0a8c7f085bc4857bd52132833679dcfd504fc1", + "reference": "8e0a8c7f085bc4857bd52132833679dcfd504fc1", + "shasum": "" + }, + "require": { + "guzzle/guzzle": "~3.0", + "jms/serializer": "~0.13", + "phpoption/phpoption": "~1.0", + "symfony/console": "~2.0", + "symfony/process": "~2.3" + }, + "require-dev": { + "symfony/filesystem": "~2.0" + }, + "bin": [ + "bin/ocular" + ], + "type": "library", + "autoload": { + "psr-0": { + "Scrutinizer\\Ocular\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "time": "2014-04-12 20:46:35" + }, + { + "name": "symfony/console", + "version": "v2.6.7", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272", + "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.6.7", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02", + "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + }, + { + "name": "symfony/process", + "version": "v2.6.7", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", + "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + }, { "name": "symfony/yaml", "version": "v2.6.4", From 558d54f9f1528f63be0dce141bd9389e49dca731 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 11:13:21 +0300 Subject: [PATCH 07/33] updated travis config --- .travis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f2fea6..7a6582b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,15 +7,20 @@ php: - hhvm matrix: + fast_finish: true allow_failures: - php: 5.3 + include: + - php: 5.4 + env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' before_script: - curl -s http://getcomposer.org/installer | php - - php composer.phar install --prefer-source + - travis_retry composer install ${COMPOSER_FLAGS} --no-interaction --prefer-source script: - mkdir -p build/logs - - php vendor/bin/phpunit + - php vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover after_script: + - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover From 711fb4b4cd412dd696c80035ce0b86ce090bda56 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 11:30:42 +0300 Subject: [PATCH 08/33] updated travis config: removed unneeded 5.4 custom env --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a6582b..59b6535 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,6 @@ matrix: fast_finish: true allow_failures: - php: 5.3 - include: - - php: 5.4 - env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' before_script: - curl -s http://getcomposer.org/installer | php From 656be525adb3175e3c213da33fe50b80e5f6958f Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 12:01:22 +0300 Subject: [PATCH 09/33] updated travis config: update composer before install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 59b6535..b4e0081 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: - php: 5.3 before_script: - - curl -s http://getcomposer.org/installer | php + - travis_retry composer self-update - travis_retry composer install ${COMPOSER_FLAGS} --no-interaction --prefer-source script: From 9d4dabca651c7aca7a1b991ce45fde9ff1236c40 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 12:29:35 +0300 Subject: [PATCH 10/33] removed ocular from composer.json (using phar) ; vendor dev update --- .travis.yml | 7 +- composer.json | 3 +- composer.lock | 711 ++------------------------------------------------ 3 files changed, 25 insertions(+), 696 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4e0081..4adc80b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,9 @@ before_script: - travis_retry composer install ${COMPOSER_FLAGS} --no-interaction --prefer-source script: - - mkdir -p build/logs - - php vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + - mkdir -p ./build/logs + - php vendor/bin/phpunit --coverage-clover=./build/logs/coverage.clover after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover + - travis_retry wget https://scrutinizer-ci.com/ocular.phar -O ocular.phar + - travis_retry php ocular.phar code-coverage:upload --format=php-clover ./build/logs/coverage.clover diff --git a/composer.json b/composer.json index 63bfad2..196e0bc 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,7 @@ "jacobkiers/oauth": "~1.0.10" }, "require-dev": { - "phpunit/phpunit": "3.7.*", - "scrutinizer/ocular": "~1.1" + "phpunit/phpunit": "3.7.*" }, "conflict": { "eabay/bitbucket-repo-sync": "*" diff --git a/composer.lock b/composer.lock index 0336e7e..627d222 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6065882ec9120ab2692e9ab31fcf26ba", + "hash": "241640db17ed33fb8d97ab700c3fee1b", "packages": [ { "name": "jacobkiers/oauth", @@ -115,479 +115,6 @@ } ], "packages-dev": [ - { - "name": "doctrine/annotations", - "version": "v1.2.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/b5202eb9e83f8db52e0e58867e0a46e63be8332e", - "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2014-12-23 22:40:37" - }, - { - "name": "doctrine/lexer", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "lexer", - "parser" - ], - "time": "2014-09-09 13:34:57" - }, - { - "name": "guzzle/guzzle", - "version": "v3.9.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle3.git", - "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", - "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", - "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" - }, - "suggest": { - "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.9-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": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2015-03-18 18:23:50" - }, - { - "name": "jms/metadata", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/metadata.git", - "reference": "22b72455559a25777cfd28c4ffda81ff7639f353" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/22b72455559a25777cfd28c4ffda81ff7639f353", - "reference": "22b72455559a25777cfd28c4ffda81ff7639f353", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "doctrine/cache": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Metadata\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache" - ], - "authors": [ - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Class/method/property metadata management in PHP", - "keywords": [ - "annotations", - "metadata", - "xml", - "yaml" - ], - "time": "2014-07-12 07:13:19" - }, - { - "name": "jms/parser-lib", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/parser-lib.git", - "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", - "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", - "shasum": "" - }, - "require": { - "phpoption/phpoption": ">=0.9,<2.0-dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "JMS\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "description": "A library for easily creating recursive-descent parsers.", - "time": "2012-11-18 18:08:43" - }, - { - "name": "jms/serializer", - "version": "0.16.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/serializer.git", - "reference": "c8a171357ca92b6706e395c757f334902d430ea9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/c8a171357ca92b6706e395c757f334902d430ea9", - "reference": "c8a171357ca92b6706e395c757f334902d430ea9", - "shasum": "" - }, - "require": { - "doctrine/annotations": "1.*", - "jms/metadata": "~1.1", - "jms/parser-lib": "1.*", - "php": ">=5.3.2", - "phpcollection/phpcollection": "~0.1" - }, - "require-dev": { - "doctrine/orm": "~2.1", - "doctrine/phpcr-odm": "~1.0.1", - "jackalope/jackalope-doctrine-dbal": "1.0.*", - "propel/propel1": "~1.7", - "symfony/filesystem": "2.*", - "symfony/form": "~2.1", - "symfony/translation": "~2.0", - "symfony/validator": "~2.0", - "symfony/yaml": "2.*", - "twig/twig": ">=1.8,<2.0-dev" - }, - "suggest": { - "symfony/yaml": "Required if you'd like to serialize data to YAML format." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.15-dev" - } - }, - "autoload": { - "psr-0": { - "JMS\\Serializer": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.", - "homepage": "http://jmsyst.com/libs/serializer", - "keywords": [ - "deserialization", - "jaxb", - "json", - "serialization", - "xml" - ], - "time": "2014-03-18 08:39:00" - }, - { - "name": "phpcollection/phpcollection", - "version": "0.4.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-collection.git", - "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/b8bf55a0a929ca43b01232b36719f176f86c7e83", - "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83", - "shasum": "" - }, - "require": { - "phpoption/phpoption": "1.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "PhpCollection": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "General-Purpose Collection Library for PHP", - "keywords": [ - "collection", - "list", - "map", - "sequence", - "set" - ], - "time": "2014-03-11 13:46:42" - }, - { - "name": "phpoption/phpoption", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5d099bcf0393908bf4ad69cc47dafb785d51f7f5", - "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-0": { - "PhpOption\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "time": "2014-01-09 22:37:17" - }, { "name": "phpunit/php-code-coverage", "version": "1.2.18", @@ -651,31 +178,33 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, "autoload": { "classmap": [ - "File/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -692,7 +221,7 @@ "filesystem", "iterator" ], - "time": "2013-10-10 15:34:57" + "time": "2015-04-02 05:19:05" }, { "name": "phpunit/php-text-template", @@ -955,171 +484,18 @@ "time": "2013-01-13 10:24:48" }, { - "name": "scrutinizer/ocular", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/scrutinizer-ci/ocular.git", - "reference": "8e0a8c7f085bc4857bd52132833679dcfd504fc1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/scrutinizer-ci/ocular/zipball/8e0a8c7f085bc4857bd52132833679dcfd504fc1", - "reference": "8e0a8c7f085bc4857bd52132833679dcfd504fc1", - "shasum": "" - }, - "require": { - "guzzle/guzzle": "~3.0", - "jms/serializer": "~0.13", - "phpoption/phpoption": "~1.0", - "symfony/console": "~2.0", - "symfony/process": "~2.3" - }, - "require-dev": { - "symfony/filesystem": "~2.0" - }, - "bin": [ - "bin/ocular" - ], - "type": "library", - "autoload": { - "psr-0": { - "Scrutinizer\\Ocular\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "time": "2014-04-12 20:46:35" - }, - { - "name": "symfony/console", - "version": "v2.6.7", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.6.7", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02", - "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/process", + "name": "symfony/yaml", "version": "v2.6.7", - "target-dir": "Symfony/Component/Process", + "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562" + "url": "https://github.com/symfony/Yaml.git", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", "shasum": "" }, "require": { @@ -1136,7 +512,7 @@ }, "autoload": { "psr-0": { - "Symfony\\Component\\Process\\": "" + "Symfony\\Component\\Yaml\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1153,56 +529,9 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Process Component", + "description": "Symfony Yaml Component", "homepage": "https://symfony.com", "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/yaml", - "version": "v2.6.4", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/60ed7751671113cf1ee7d7778e691642c2e9acd8", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "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 Yaml Component", - "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" } ], "aliases": [], From 643c1e13b2501635d0fd925e685c3db98f10af78 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 12:31:02 +0300 Subject: [PATCH 11/33] updated travis config: removed COMPOSER_FLAGS env --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4adc80b..0d88f2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: before_script: - travis_retry composer self-update - - travis_retry composer install ${COMPOSER_FLAGS} --no-interaction --prefer-source + - travis_retry composer install --no-interaction --prefer-source script: - mkdir -p ./build/logs From 6c21b546d758e7ef1a20985b3a1b32afdecdc2d6 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 12:48:13 +0300 Subject: [PATCH 12/33] updated travis config --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0d88f2d..41e76b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ matrix: before_script: - travis_retry composer self-update + - composer --version - travis_retry composer install --no-interaction --prefer-source script: @@ -21,4 +22,6 @@ script: after_script: - travis_retry wget https://scrutinizer-ci.com/ocular.phar -O ocular.phar + - travis_retry ocular.phar self-update + - ocular --version - travis_retry php ocular.phar code-coverage:upload --format=php-clover ./build/logs/coverage.clover From c718e070e6163a2a14d7983b77c06f334f197214 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 13:02:09 +0300 Subject: [PATCH 13/33] updated travis config (typos) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41e76b0..0c71b7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,6 @@ script: after_script: - travis_retry wget https://scrutinizer-ci.com/ocular.phar -O ocular.phar - - travis_retry ocular.phar self-update - - ocular --version + - travis_retry php ocular.phar self-update + - php ocular.phar --version - travis_retry php ocular.phar code-coverage:upload --format=php-clover ./build/logs/coverage.clover From 4076bf658128a42b142e96cf7163c2e0f1293a81 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 13:15:50 +0300 Subject: [PATCH 14/33] updated travis config: specify repository for ocular --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0c71b7a..f15506a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ after_script: - travis_retry wget https://scrutinizer-ci.com/ocular.phar -O ocular.phar - travis_retry php ocular.phar self-update - php ocular.phar --version - - travis_retry php ocular.phar code-coverage:upload --format=php-clover ./build/logs/coverage.clover + - travis_retry php ocular.phar code-coverage:upload --repository=b/gentlero/bitbucket-api --format=php-clover ./build/logs/coverage.clover From 56717b2102d39b4a840a5f45269893a5eff32c73 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 13:16:59 +0300 Subject: [PATCH 15/33] docs: typo fix --- docs/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index be17d2a..ee98aa0 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -4,7 +4,7 @@ permalink: /installation.html title: Installation --- -# Instalation +# Installation ### Requirements From 02aefa58df225aabe515c875c30882204d510dd3 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Thu, 21 May 2015 13:23:19 +0300 Subject: [PATCH 16/33] docblock update: typo in ClientListener --- lib/Bitbucket/API/Http/ClientListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Bitbucket/API/Http/ClientListener.php b/lib/Bitbucket/API/Http/ClientListener.php index cf1e456..2b306c0 100644 --- a/lib/Bitbucket/API/Http/ClientListener.php +++ b/lib/Bitbucket/API/Http/ClientListener.php @@ -97,7 +97,7 @@ public function hasListeners() /** * @access public * @param array $listeners - * @return $this; + * @return $this */ public function setListeners(array $listeners) { From e9f82304d7ca14650a3d961ef159e68c9b7819b3 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 12:12:48 +0300 Subject: [PATCH 17/33] use https for shields.io --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8bbb2e5..bc6ea36 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![Latest Version](https://img.shields.io/packagist/v/gentle/bitbucket-api.svg?style=flat-square)](https://packagist.org/packages/gentle/bitbucket-api) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/gentlero/bitbucket-api/blob/master/LICENSE) -[![Build Status](http://img.shields.io/travis/gentlero/bitbucket-api/master.svg?style=flat-square)](https://travis-ci.org/gentlero/bitbucket-api) +[![Build Status](https://img.shields.io/travis/gentlero/bitbucket-api/master.svg?style=flat-square)](https://travis-ci.org/gentlero/bitbucket-api) [![Coverage Status](https://img.shields.io/scrutinizer/coverage/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) -[![Code quality](http://img.shields.io/scrutinizer/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) +[![Code quality](https://img.shields.io/scrutinizer/b/gentlero/bitbucket-api.svg?style=flat-square)](https://scrutinizer-ci.com/b/gentlero/bitbucket-api/?branch=develop) Simple Bitbucket API wrapper for PHP >= 5.3.2. From 7ed12323f339679979761a86425970a3cf6825c7 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 15:42:48 +0300 Subject: [PATCH 18/33] bumped version to 0.7.0 --- lib/Bitbucket/API/Http/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Bitbucket/API/Http/Client.php b/lib/Bitbucket/API/Http/Client.php index 8dec8e2..4993e48 100644 --- a/lib/Bitbucket/API/Http/Client.php +++ b/lib/Bitbucket/API/Http/Client.php @@ -33,7 +33,7 @@ class Client extends ClientListener implements ClientInterface 'api_versions' => array('1.0', '2.0'), // supported versions 'format' => 'json', 'formats' => array('json', 'xml'), // supported response formats - 'user_agent' => 'bitbucket-api-php/0.6.2 (https://bitbucket.org/gentlero/bitbucket-api)', + 'user_agent' => 'bitbucket-api-php/0.7.0 (https://bitbucket.org/gentlero/bitbucket-api)', 'timeout' => 10, 'verify_peer' => false ); From 7de3c9c5ba486459c332132d033ea7141cd7a4b2 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 15:45:25 +0300 Subject: [PATCH 19/33] updated CHANGELOG: started 0.7.0 section / implemented webhooks --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28241c9..0b8f470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased][unreleased] +## [0.7.0] / [unreleased] + +### Added: + - Implemented webhooks endpoints. ## 0.6.2 / 2015-05-18 From 829c04bad5b7870216326c01e098de2418db93fd Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 15:46:06 +0300 Subject: [PATCH 20/33] implemented webhooks endpoints --- lib/Bitbucket/API/Repositories/Hooks.php | 133 +++++++++++ .../Tests/API/Repositories/HooksTest.php | 215 ++++++++++++++++++ 2 files changed, 348 insertions(+) create mode 100644 lib/Bitbucket/API/Repositories/Hooks.php create mode 100644 test/Bitbucket/Tests/API/Repositories/HooksTest.php diff --git a/lib/Bitbucket/API/Repositories/Hooks.php b/lib/Bitbucket/API/Repositories/Hooks.php new file mode 100644 index 0000000..47483ba --- /dev/null +++ b/lib/Bitbucket/API/Repositories/Hooks.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\API\Repositories; + +use Bitbucket\API; +use Buzz\Message\MessageInterface; + +/** + * @author Alexandru Guzinschi + */ +class Hooks extends API\Api +{ + /** + * @access public + * @param string $account The team or individual account owning the repository. + * @param string $repo The repository identifier. + * @param array $params Additional service parameters + * @return MessageInterface + * + * @throws \InvalidArgumentException + */ + public function create($account, $repo, array $params = array()) + { + $mandatory = array( + 'description' => 'My webhook', + 'url' => '', + 'active' => true, + 'events' => array() + ); + + $diff = array_diff(array_keys($mandatory), array_keys($params)); + + if (count($diff) > 0) { + throw new \InvalidArgumentException('Missing parameters for creating a new webhook.'); + } + + if (false === array_key_exists('events', $params) || 0 === count($params['events'])) { + throw new \InvalidArgumentException('Missing events for creating a new webhook.'); + } + + return $this->getClient()->setApiVersion('2.0')->post( + sprintf('repositories/%s/%s/hooks', $account, $repo), + json_encode($params), + array('Content-Type' => 'application/json') + ); + } + + /** + * @access public + * @param string $account The team or individual account owning the repository. + * @param string $repo The repository identifier. + * @param string $uuid The universally unique identifier of the webhook. + * @param array $params Additional service parameters + * @return MessageInterface + * + * @throws \InvalidArgumentException + */ + public function update($account, $repo, $uuid, array $params = array()) + { + $mandatory = array( + 'description' => 'My webhook', + 'url' => '', + 'active' => true, + 'events' => array() + ); + + $diff = array_diff(array_keys($mandatory), array_keys($params)); + + if (count($diff) > 0) { + throw new \InvalidArgumentException('Missing parameters for updating a webhook.'); + } + + if (false === array_key_exists('events', $params) || 0 === count($params['events'])) { + throw new \InvalidArgumentException('Missing events for updating a new webhook.'); + } + + return $this->getClient()->setApiVersion('2.0')->put( + sprintf('repositories/%s/%s/hooks/%s', $account, $repo, $uuid), + json_encode($params), + array('Content-Type' => 'application/json') + ); + } + + /** + * @access public + * @param string $account The team or individual account owning the repository. + * @param string $repo The repository identifier. + * @return MessageInterface + */ + public function all($account, $repo) + { + return $this->getClient()->setApiVersion('2.0')->get( + sprintf('repositories/%s/%s/hooks', $account, $repo) + ); + } + + /** + * @access public + * @param string $account The team or individual account owning the repository. + * @param string $repo The repository identifier. + * @param string $uuid The universally unique identifier of the webhook. + * @return MessageInterface + */ + public function get($account, $repo, $uuid) + { + return $this->getClient()->setApiVersion('2.0')->get( + sprintf('repositories/%s/%s/hooks/%s', $account, $repo, $uuid) + ); + } + + /** + * @access public + * @param string $account The team or individual account owning the repository. + * @param string $repo The repository identifier. + * @param string $uuid The universally unique identifier of the webhook. + * @return MessageInterface + */ + public function delete($account, $repo, $uuid) + { + return $this->getClient()->setApiVersion('2.0')->delete( + sprintf('repositories/%s/%s/hooks/%s', $account, $repo, $uuid) + ); + } +} diff --git a/test/Bitbucket/Tests/API/Repositories/HooksTest.php b/test/Bitbucket/Tests/API/Repositories/HooksTest.php new file mode 100644 index 0000000..114b521 --- /dev/null +++ b/test/Bitbucket/Tests/API/Repositories/HooksTest.php @@ -0,0 +1,215 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\Tests\API\Repositories; + +use Bitbucket\Tests\API as Tests; +use Bitbucket\API; + +class HooksTest extends Tests\TestCase +{ + public function invalidCreateProvider() + { + return array( + array(array( + 'dummy' => 'data', + )), + array(array( + 'description' => 'My webhook', + 'url' => '', + 'active' => true, + )), + array(array( + 'description' => 'My webhook', + 'url' => '', + 'active' => true, + 'events' => array(), + )), + array(array( + 'description' => 'My webhook', + 'url' => '', + 'events' => array( + 'event1', + 'event2', + ), + )), + array(array( + 'description' => 'My webhook', + 'active' => true, + 'events' => array( + 'event1', + 'event2', + ), + 'extra' => 'Allow user to specify custom data', + )), + ); + } + + /** + * @access public + * @param mixed $check + * @return void + * + * @expectedException \InvalidArgumentException + * @dataProvider invalidCreateProvider + */ + public function testInvalidCreate($check) + { + $client = $this->getHttpClientMock(); + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $hooks->create('gentle', 'my-repo', $check); + } + + public function testCreateSuccess() + { + $endpoint = 'repositories/gentle/eof/hooks'; + $params = array( + 'description' => 'My first webhook', + 'url' => 'http://requestb.in/xxx', + 'active' => true, + 'events' => array( + 'repo:push', + 'issue:created', + ), + ); + + $client = $this->getHttpClientMock(); + $client->expects($this->any()) + ->method('post') + ->with($endpoint, json_encode($params)) + ; + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $hooks->create('gentle', 'eof', $params); + } + + public function testCreateSuccessWithExtraParameters() + { + $endpoint = 'repositories/gentle/eof/hooks'; + $params = array( + 'description' => 'My first webhook', + 'url' => 'http://requestb.in/xxx', + 'active' => true, + 'extra' => 'User can specify additional parameters', + 'events' => array( + 'repo:push', + 'issue:created', + ), + ); + + $client = $this->getHttpClientMock(); + $client->expects($this->any()) + ->method('post') + ->with($endpoint, json_encode($params)) + ; + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $hooks->create('gentle', 'eof', $params); + } + + public function testUpdateSuccess() + { + $endpoint = 'repositories/gentle/eof/hooks/30b60aee-9cdf-407d-901c-2de106ee0c9d'; + $params = array( + 'description' => 'My first webhook', + 'url' => 'http://requestb.in/zzz', + 'active' => true, + 'events' => array( + 'repo:push', + 'issue:created', + ), + ); + + $client = $this->getHttpClientMock(); + $client->expects($this->any()) + ->method('put') + ->with($endpoint, json_encode($params)) + ; + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $hooks->update('gentle', 'eof', '30b60aee-9cdf-407d-901c-2de106ee0c9d', $params); + } + + /** + * @access public + * @param mixed $check + * @return void + * + * @expectedException \InvalidArgumentException + * @dataProvider invalidCreateProvider + */ + public function testInvalidUpdate($check) + { + $client = $this->getHttpClientMock(); + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $hooks->update('gentle', 'eof', '30b60aee-9cdf-407d-901c-2de106ee0c9d', $check); + } + + public function testGetAllHooks() + { + $endpoint = 'repositories/gentle/eof/hooks'; + $expectedResult = $this->fakeResponse(array('dummy')); + + $client = $this->getHttpClientMock(); + $client->expects($this->any()) + ->method('get') + ->with($endpoint) + ->will($this->returnValue($expectedResult)) + ; + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $actual = $hooks->all('gentle', 'eof'); + + $this->assertEquals($expectedResult, $actual); + } + + public function testGetSingleHook() + { + $endpoint = 'repositories/gentle/eof/hooks/30b60aee-9cdf-407d-901c-2de106ee0c9d'; + $expectedResult = $this->fakeResponse(array('dummy')); + + $client = $this->getHttpClientMock(); + $client->expects($this->any()) + ->method('get') + ->with($endpoint) + ->will($this->returnValue($expectedResult)) + ; + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + $actual = $hooks->get('gentle', 'eof', '30b60aee-9cdf-407d-901c-2de106ee0c9d'); + + $this->assertEquals($expectedResult, $actual); + } + + public function testDeleteSingleHook() + { + $endpoint = 'repositories/gentle/eof/hooks/30b60aee-9cdf-407d-901c-2de106ee0c9d'; + + $client = $this->getHttpClientMock(); + $client->expects($this->once()) + ->method('delete') + ->with($endpoint); + + /** @var \Bitbucket\API\Repositories\Hooks $hooks */ + $hooks = $this->getClassMock('Bitbucket\API\Repositories\Hooks', $client); + + $hooks->delete('gentle', 'eof', '30b60aee-9cdf-407d-901c-2de106ee0c9d'); + } +} From 14c33a5ce696e4b703faf6d7e0af8840455875a7 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 15:54:29 +0300 Subject: [PATCH 21/33] marked Repositories/Services as deprecated in favor of Repositories/Hooks ref #29 --- lib/Bitbucket/API/Repositories/Services.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Bitbucket/API/Repositories/Services.php b/lib/Bitbucket/API/Repositories/Services.php index 70a2220..4d4c934 100644 --- a/lib/Bitbucket/API/Repositories/Services.php +++ b/lib/Bitbucket/API/Repositories/Services.php @@ -18,6 +18,8 @@ * Provides functionality for adding, removing, and configuring brokers on your repositories * * @author Alexandru G. + * + * @deprecated Deprecated since version 0.7.0 in favor of Repositories\Hooks */ class Services extends API\Api { From 62919f24d291db7948ffe3d488e43392c01b5e2c Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 16:21:10 +0300 Subject: [PATCH 22/33] updated tests for Repositories/Repository --- .../Tests/API/Repositories/RepositoryTest.php | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php index 5b53fc6..f42c41d 100644 --- a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php +++ b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php @@ -32,6 +32,7 @@ public function invalidCreateProvider() { return array( array(''), + array(3), array("\t"), array("\n"), array(' '), @@ -41,26 +42,23 @@ public function invalidCreateProvider() array( substr( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", - mt_rand( 0 ,50 ) ,1 ) .substr( md5( time() ), 1) - ) + mt_rand(0, 50), 1).substr(md5(time()), 1), + ), ); - } /** - * @param $check - * @param $expectation - * @return mixed + * @param mixed $check * @expectedException \InvalidArgumentException - * @dataProvider invalidCreateProvider + * @dataProvider invalidCreateProvider + * @ticket 27, 26 */ public function testInvalidCreate($check) { - - $client = $this->getHttpClientMock(); + $client = $this->getHttpClientMock(); /** @var \Bitbucket\API\Repositories\Repository $repo */ - $repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client); + $repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client); $this->setExpectedException('\InvalidArgumentException'); $repo->create('gentle', 'new-repo', $check); } @@ -134,20 +132,6 @@ public function testCreateRepositoryWithDefaultParams() $repo->create('gentle', 'new-repo', array()); } - /** - * @ticket 26 - * @expectedException \InvalidArgumentException - */ - public function testCreateRepositoryWithWrongParamsType() - { - /** @var \Bitbucket\API\Repositories\Repository $repo */ - $repo = $this->getApiMock('Bitbucket\API\Repositories\Repository'); - - $repo->create('gentle', 'new-repo', ''); - $repo->create('gentle', 'new-repo', 3); - $repo->create('gentle', 'new-repo', "{ 'foo': 'bar' }"); - } - public function testCreateRepositorySuccess() { $endpoint = 'repositories'; @@ -155,7 +139,7 @@ public function testCreateRepositorySuccess() 'name' => 'secret', 'description' => 'My super secret project', 'language' => 'php', - 'is_private' => true + 'is_private' => true, ); $repository = $this->getApiMock('Bitbucket\API\Repositories\Repository'); @@ -174,7 +158,7 @@ public function testUpdateRepositorySuccess() 'description' => 'My super secret project', 'language' => 'php', 'is_private' => false, - 'main_branch' => 'master' + 'main_branch' => 'master', ); $repository = $this->getApiMock('Bitbucket\API\Repositories\Repository'); @@ -242,7 +226,7 @@ public function testForkRepositorySuccess() $endpoint = 'repositories/gentle/eof/fork'; $params = array( 'name' => 'my-eof', - 'is_private' => true + 'is_private' => true, ); $repository = $this->getApiMock('Bitbucket\API\Repositories\Repository'); @@ -263,7 +247,7 @@ public function testGetBranches() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->branches('gentle', 'eof'); @@ -280,7 +264,7 @@ public function testGetMainBranch() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->branch('gentle', 'eof'); @@ -297,7 +281,7 @@ public function testGetManifest() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->manifest('gentle', 'eof', 'develop'); @@ -314,7 +298,7 @@ public function testGetTags() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->tags('gentle', 'eof'); @@ -331,7 +315,7 @@ public function testGetRawSource() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->raw('gentle', 'eof', '1bc8345', 'lib/file.php'); @@ -348,7 +332,7 @@ public function testGetFileHistory() $repository->expects($this->once()) ->method('requestGet') ->with($endpoint) - ->will( $this->returnValue($expectedResult) ); + ->will($this->returnValue($expectedResult)); /** @var $repository \Bitbucket\API\Repositories\Repository */ $actual = $repository->filehistory('gentle', 'eof', '1bc8345', 'lib/file.php'); From a894797a05f6caa3f1cc37b2d49d6240c37a03e7 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 13 Jul 2015 17:20:29 +0300 Subject: [PATCH 23/33] updated docs: marked Repositories/Services as deprecated ; added doc for Repositories/WebHooks [ci skip] --- docs/examples/index.md | 3 +- docs/examples/repositories/webhooks.md | 82 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 docs/examples/repositories/webhooks.md diff --git a/docs/examples/index.md b/docs/examples/index.md index 1f32366..b5242dc 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -46,7 +46,8 @@ title: Examples - [Pull requests](repositories/pull-requests.html) - [Comments](repositories/pull-requests/comments.html) - [Repository](repositories/repository.html) - - [Services](repositories/services.html) + - ~~[Services](repositories/services.html)~~ (deprecated since 0.7.0 -- @see [WebHooks](repositories/webhooks.html)) + - [Hooks](repositories/webhooks.html) - [Src](repositories/src.html) - [Wiki](repositories/wiki.html) - [Teams](teams.html) diff --git a/docs/examples/repositories/webhooks.md b/docs/examples/repositories/webhooks.md new file mode 100644 index 0000000..1789053 --- /dev/null +++ b/docs/examples/repositories/webhooks.md @@ -0,0 +1,82 @@ +--- +layout: default +permalink: /examples/repositories/webhooks.html +title: WebHooks +--- + +# WebHooks + +This resource manages webhooks on a repository. The administrators of the repository are +the only users who can create, access, update, or delete the webhook. + +### Prepare: + +```php +$uuid = '30b60aee-9cdf-407d-901c-2de106ee0c9d'; // unique identifier of the webhook +$hooks = new Bitbucket\API\Repositories\Hooks(); + +$hooks->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) ); +``` + +### Get a webhook: + +```php +$hooks->get($account_name, $repo_slug, $uuid); +``` + +**HINT:** You can use `$hooks->all()` method to get a list of all available hooks and their unique identifiers. + +### Get a list of webhooks: + +```php +$hooks->all($account_name, $repo_slug); +``` + +### Create a new webhook: + +```php +$hook->create($account_name, $repo_slug, array( + 'description' => 'Webhook Description', + 'url' => 'http://requestb.in/xxx', + 'active' => true, + 'events' => array( + 'repo:push', + 'issue:created', + 'issue:updated' + ) +)); +``` + +**HINT:** For a full list of available events, see [Event Payloads](https://confluence.atlassian.com/display/BITBUCKET/Event+Payloads) page. + +### Update a webhook: + +Add a new event `pullrequest:approved` to our webhook: + +```php +$hook->update($account_name, $repo_slug, $uuid, array( + 'description' => 'Webhook Description', + 'url' => 'http://requestb.in/xxx', + 'active' => true, + 'events' => array( + 'repo:push', + 'issue:created', + 'issue:updated', + 'pullrequest:approved' + ) +)); +``` + +**HINT:** Bitbucket doesn't offer a patch endpoint, so you need to send the entire object represensation in order to update. + +### Delete a webhook: + +```php +$hook->delete($account_name, $repo_slug, $uuid); +``` + +---- + +#### Related: + * [Authentication]({{ site.url }}/examples/authentication.html) + * [BB Wiki](https://confluence.atlassian.com/display/BITBUCKET/webhooks+Resource) From 795585c62c285805f034d71b2433dc5d502df686 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Wed, 15 Jul 2015 10:43:30 +0300 Subject: [PATCH 24/33] Removed unused parameters from Changesets::all() --- lib/Bitbucket/API/Repositories/Changesets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Bitbucket/API/Repositories/Changesets.php b/lib/Bitbucket/API/Repositories/Changesets.php index 93925ee..1088b5b 100644 --- a/lib/Bitbucket/API/Repositories/Changesets.php +++ b/lib/Bitbucket/API/Repositories/Changesets.php @@ -34,7 +34,7 @@ class Changesets extends API\Api public function all($account, $repo, $start = null, $limit = 15) { return $this->requestGet( - sprintf('repositories/%s/%s/changesets', $account, $repo, $start, $limit), + sprintf('repositories/%s/%s/changesets', $account, $repo), array( 'start' => $start, 'limit' => $limit From 81df65d545ba9d057e2d8d4c13f57e1bd31cd488 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Wed, 15 Jul 2015 10:46:51 +0300 Subject: [PATCH 25/33] Fixes #2 : Toggle spam on a changeset comment --- .../API/Repositories/Changesets/Comments.php | 17 +++++++++++++++++ .../Repositories/Changesets/CommentsTest.php | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/Bitbucket/API/Repositories/Changesets/Comments.php b/lib/Bitbucket/API/Repositories/Changesets/Comments.php index a9c3cf2..99663eb 100644 --- a/lib/Bitbucket/API/Repositories/Changesets/Comments.php +++ b/lib/Bitbucket/API/Repositories/Changesets/Comments.php @@ -113,4 +113,21 @@ public function update($account, $repo, $node, $commentID, $content, array $opti array_merge(array('content' => $content), $options) ); } + + /** + * Toggle spam flag on an existing changeset comment + * + * @access public + * @param string $account The team or individual account owning the repo. + * @param string $repo The repo identifier. + * @param string $node The raw_node changeset identifier. + * @param int $commentID The comment identifier. + * @return MessageInterface + */ + public function spam($account, $repo, $node, $commentID) + { + return $this->requestPut( + sprintf('repositories/%s/%s/changesets/%s/comments/spam/%d', $account, $repo, $node, $commentID) + ); + } } diff --git a/test/Bitbucket/Tests/API/Repositories/Changesets/CommentsTest.php b/test/Bitbucket/Tests/API/Repositories/Changesets/CommentsTest.php index e24c5cc..9c0e28d 100644 --- a/test/Bitbucket/Tests/API/Repositories/Changesets/CommentsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Changesets/CommentsTest.php @@ -64,4 +64,17 @@ public function testUpdateCommentSuccess() /** @var $comments \Bitbucket\API\Repositories\Changesets\Comments */ $comments->update('gentle', 'eof', 'aea95f1', 3, 'edited comment'); } -} \ No newline at end of file + + public function testMarkCommentAsSpamSuccess() + { + $endpoint = 'repositories/gentle/eof/changesets/aea95f1/comments/spam/3'; + + $comments = $this->getApiMock('Bitbucket\API\Repositories\Changesets\Comments'); + $comments->expects($this->any()) + ->method('requestPut') + ->with($endpoint); + + /** @var $comments \Bitbucket\API\Repositories\Changesets\Comments */ + $comments->spam('gentle', 'eof', 'aea95f1', 3); + } +} From 42074bcf09d5f797a43bb5b6035c264e79110c9c Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Sat, 22 Aug 2015 08:54:27 +0300 Subject: [PATCH 26/33] forking_policy renamed to fork_policy. Parameter name was changed in API 2.0, on repository endpoint. Fixes #32 --- docs/examples/repositories/repository.md | 2 +- lib/Bitbucket/API/Repositories/Repository.php | 2 +- test/Bitbucket/Tests/API/Repositories/RepositoryTest.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/examples/repositories/repository.md b/docs/examples/repositories/repository.md index 8cdd115..10a5a25 100644 --- a/docs/examples/repositories/repository.md +++ b/docs/examples/repositories/repository.md @@ -41,7 +41,7 @@ $repo->create($account_name, $repo_slug, array( 'description' => 'My super secret project.', 'language' => 'php', 'is_private' => true, - 'forking_policy' => 'no_public_forks', + 'fork_policy' => 'no_public_forks', )); ``` diff --git a/lib/Bitbucket/API/Repositories/Repository.php b/lib/Bitbucket/API/Repositories/Repository.php index 6e4305d..b0de727 100644 --- a/lib/Bitbucket/API/Repositories/Repository.php +++ b/lib/Bitbucket/API/Repositories/Repository.php @@ -65,7 +65,7 @@ public function create($account, $repo, $params = array()) 'name' => $repo, 'is_private' => true, 'description' => 'My secret repo', - 'forking_policy' => 'no_forks', + 'fork_policy' => 'no_forks', ); // allow developer to directly specify params as json if (s)he wants. diff --git a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php index f42c41d..045814c 100644 --- a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php +++ b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php @@ -71,7 +71,7 @@ public function testCreateRepositoryFromJSON() 'name' => 'new-repo', 'is_private' => true, 'description' => 'My secret repo', - 'forking_policy' => 'no_public_forks', + 'fork_policy' => 'no_public_forks', )); $client = $this->getHttpClientMock(); @@ -93,7 +93,7 @@ public function testCreateRepositoryFromArray() 'name' => 'new-repo', 'is_private' => true, 'description' => 'My secret repo', - 'forking_policy' => 'no_public_forks', + 'fork_policy' => 'no_public_forks', ); $client = $this->getHttpClientMock(); @@ -118,7 +118,7 @@ public function testCreateRepositoryWithDefaultParams() 'name' => 'new-repo', 'is_private' => true, 'description' => 'My secret repo', - 'forking_policy' => 'no_forks', + 'fork_policy' => 'no_forks', ); $client = $this->getHttpClientMock(); From a4eb239d9fabc5edc210f5b0ee84e962372a94c9 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Sat, 22 Aug 2015 11:02:28 +0300 Subject: [PATCH 27/33] updated CHANGELOG [ci skip] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8f470..b02187e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added: - Implemented webhooks endpoints. + - Toggle spam on a changeset comment. (issue #2) + +### Changed: + - Marked Repositories/Services as deprecated in favor of Repositories/Hooks. (issue #29) + +### Fixed: + - `forking_policy` parameter renamed to `fork_policy` on repository endpoint. (issue #32) ## 0.6.2 / 2015-05-18 From 03d94cdbdebaa457e0d2440614e5e120029f976c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6nthal?= Date: Wed, 2 Sep 2015 21:38:30 +0000 Subject: [PATCH 28/33] allow php7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 196e0bc..68b1b74 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "~5.3", + "php": ">=5.3", "kriswallsmith/buzz": "~0.13", "jacobkiers/oauth": "~1.0.10" }, From 48ada3bc699e92e921f3280d383b7f07e5cefd66 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 7 Sep 2015 08:07:57 +0300 Subject: [PATCH 29/33] [DOCS] Fixed wrong class name in examples/repositories/commits $commits = new Bitbucket\API\Repositories\Commits(); instead of $commits = new Bitbucket\API\Repositories\PullRequests(); Fixes #35 --- docs/examples/repositories/commits.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/repositories/commits.md b/docs/examples/repositories/commits.md index 36cdc58..e10ba16 100644 --- a/docs/examples/repositories/commits.md +++ b/docs/examples/repositories/commits.md @@ -11,7 +11,7 @@ Retrieve and compare information about commits. ### Prepare: ```php -$commits = new Bitbucket\API\Repositories\PullRequests(); +$commits = new Bitbucket\API\Repositories\Commits(); $commits->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) ); ``` From 794fd10bf47ac32a1efbf3e0702d504ad4505bec Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 7 Sep 2015 13:26:09 +0300 Subject: [PATCH 30/33] Added support for OAuth2 Support OAuth2 through HTTP client listener. Related: #34 --- .../API/Exceptions/HttpResponseException.php | 69 +++++++++ .../API/Http/Listener/OAuth2Listener.php | 141 ++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 lib/Bitbucket/API/Exceptions/HttpResponseException.php create mode 100644 lib/Bitbucket/API/Http/Listener/OAuth2Listener.php diff --git a/lib/Bitbucket/API/Exceptions/HttpResponseException.php b/lib/Bitbucket/API/Exceptions/HttpResponseException.php new file mode 100644 index 0000000..ac719b4 --- /dev/null +++ b/lib/Bitbucket/API/Exceptions/HttpResponseException.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\API\Exceptions; + +use Buzz\Message\MessageInterface; +use Buzz\Message\RequestInterface; + +/** + * @author Alexandru G. + */ +class HttpResponseException extends \Exception +{ + /** @var MessageInterface */ + private $response; + + /** @var RequestInterface */ + private $request; + + /** + * @access public + * @return RequestInterface + */ + public function getRequest() + { + return $this->request; + } + + /** + * @access public + * @param RequestInterface $request + * @return $this + */ + public function setRequest($request) + { + $this->request = $request; + + return $this; + } + + /** + * @access public + * @return MessageInterface + */ + public function getResponse() + { + return $this->response; + } + + /** + * @access public + * @param MessageInterface $response + * @return $this + */ + public function setResponse($response) + { + $this->response = $response; + + return $this; + } +} diff --git a/lib/Bitbucket/API/Http/Listener/OAuth2Listener.php b/lib/Bitbucket/API/Http/Listener/OAuth2Listener.php new file mode 100644 index 0000000..b003e12 --- /dev/null +++ b/lib/Bitbucket/API/Http/Listener/OAuth2Listener.php @@ -0,0 +1,141 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\API\Http\Listener; + +use Bitbucket\API\Exceptions\ForbiddenAccessException; +use Bitbucket\API\Exceptions\HttpResponseException; +use Bitbucket\API\Http\Client; +use Bitbucket\API\Http\ClientInterface; +use Buzz\Message\MessageInterface; +use Buzz\Message\RequestInterface; + +/** + * @author Alexandru G. + */ +class OAuth2Listener implements ListenerInterface +{ + const ENDPOINT_ACCESS_TOKEN = 'access_token'; + const ENDPOINT_AUTHORIZE = 'authorize'; + + /** @var array */ + protected static $config = array( + 'oauth_client_id' => 'anon', + 'oauth_client_secret' => 'anon', + 'token_type' => 'bearer', + 'scopes' => array() + ); + + /** @var ClientInterface */ + private $httpClient; + + public function __construct(array $config, ClientInterface $client = null) + { + self::$config = array_merge(self::$config, $config); + $this->httpClient = (null !== $client) ? $client : new Client( + array( + 'base_url' => 'https://bitbucket.org/site', + 'api_version' => 'oauth2', + 'api_versions' => array('oauth2') + ) + ); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return 'oauth2'; + } + + /** + * {@inheritDoc} + * + * @throws ForbiddenAccessException + * @throws \InvalidArgumentException + */ + public function preSend(RequestInterface $request) + { + if (($oauth2Header = $request->getHeader('Authorization')) && + (strpos($oauth2Header, 'Bearer') !== false) + ) { + return; + } + + if (false === array_key_exists('access_token', self::$config)) { + try { + $data = $this->getAccessToken(); + self::$config['token_type'] = $data['token_type']; + self::$config['access_token'] = $data['access_token']; + } catch (HttpResponseException $e) { + throw new ForbiddenAccessException("Can't fetch access_token.", 0, $e); + } + } + + $request->addHeader( + sprintf( + 'Authorization: %s %s', + ucfirst(strtolower(self::$config['token_type'])), + self::$config['access_token'] + ) + ); + } + + /** + * {@inheritDoc} + */ + public function postSend(RequestInterface $request, MessageInterface $response) + { + } + + /** + * Fetch access token with a grant_type of client_credentials + * + * @access public + * @return array + * + * throws \InvalidArgumentException + * @throws HttpResponseException + */ + protected function getAccessToken() + { + $response = $this->httpClient + ->post( + self::ENDPOINT_ACCESS_TOKEN, + array( + 'grant_type' => 'client_credentials', + 'client_id' => self::$config['client_id'], + 'client_secret' => self::$config['client_secret'], + 'scope' => implode(',', self::$config['scopes']) + ) + ) + ; + + $data = json_decode($response->getContent(), true); + + if (json_last_error() !== JSON_ERROR_NONE) { + $ex = new HttpResponseException('[access_token] Invalid JSON: '. json_last_error_msg()); + $ex + ->setResponse($this->httpClient->getLastResponse()) + ->setRequest($this->httpClient->getLastRequest()) + ; + + throw $ex; + } + + if (false === array_key_exists('access_token', $data)) { + throw new HttpResponseException('access_token is missing from response. '. $response->getContent()); + } + + return $data; + } +} From a352e9f223a7b17709f13a425d3c97d4d771998d Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 7 Sep 2015 14:08:29 +0300 Subject: [PATCH 31/33] [DOCS] Added OAuth2 section under Authentication Basic examples for 2 and 3-legged flows. ref: #34 --- docs/examples/authentication.md | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/docs/examples/authentication.md b/docs/examples/authentication.md index c528cc5..029061f 100644 --- a/docs/examples/authentication.md +++ b/docs/examples/authentication.md @@ -44,8 +44,80 @@ http client with oauth credentials before making a request. $response = $user->get(); ``` +### OAuth2 authorization + +You can use `OAuth2Listener` in order to make authorized requests using version 2 of OAuth protocol. + +#### OAuth2 client credentials (_2-legged flow_) + + ```php + // @see: https://bitbucket.org/account/user//api + $oauth_params = array( + 'client_id' => 'aaa', + 'client_secret' => 'bbb' + ); + + $bitbucket = new \Bitbucket\API\Api(); + $bitbucket->getClient()->addListener( + new \Bitbucket\API\Http\Listener\OAuth2Listener($oauth_params) + ); + + $repositories = $bitbucket->api('Repositories'); + $response = $repositories->all('my_account'); // should include private repositories + ``` + +#### OAuth2 Authorization code (_3-legged flow_) + +You can use any 3rd party library to complete this [flow][3] and set `access_token` option when you instantiate `OAuth2Listener`. + +In the following example [PHP League's OAuth 2.0 Client][1] is used with [Bitbucket Provider][2]. + + ```php + session_start(); + + $provider = new Stevenmaguire\OAuth2\Client\Provider\Bitbucket([ + 'clientId' => $_ENV['bitbucket_consumer_key'], + 'clientSecret' => $_ENV['bitbucket_consumer_secret'], + 'redirectUri' => 'http://example.com/bitbucket_login.php' + ]); + if (!isset($_GET['code'])) { + + // If we don't have an authorization code then get one + $authUrl = $provider->getAuthorizationUrl(); + $_SESSION['oauth2state'] = $provider->getState(); + header('Location: '.$authUrl); + exit; + + // Check given state against previously stored one to mitigate CSRF attack + } elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { + + unset($_SESSION['oauth2state']); + exit('Invalid state'); + + } else { + + // Try to get an access token (using the authorization code grant) + $token = $provider->getAccessToken('authorization_code', [ + 'code' => $_GET['code'] + ]); + + $bitbucket = new Bitbucket\API\Repositories(); + $bitbucket->getClient()->addListener( + new \Bitbucket\API\Http\Listener\OAuth2Listener( + array('access_token' => $token->getToken()) + ) + ); + + echo $bitbucket->all('my_account')->getContent(); // should include private repositories + } + ``` + ---- #### Related: * [Authentication @ BB Wiki](https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs#UsetheBitbucketRESTAPIs-Authentication) * [OAuth on Bitbucket @ BB Wiki](https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket) + +[1]: http://oauth2-client.thephpleague.com/ +[2]: https://github.com/stevenmaguire/oauth2-bitbucket +[3]: http://oauthbible.com/#oauth-2-three-legged From f951f6e455bda8e3f4f835e4882b6c58b6fd6874 Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Mon, 7 Sep 2015 17:38:04 +0300 Subject: [PATCH 32/33] [DOCS] OAuth1 3-legged example Added example on how to use this library in combination with a 3rd party OAuth1 client in a 3-legged flow. Ref: #33 --- docs/examples/authentication.md | 97 ++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/docs/examples/authentication.md b/docs/examples/authentication.md index 029061f..40d8607 100644 --- a/docs/examples/authentication.md +++ b/docs/examples/authentication.md @@ -23,10 +23,11 @@ To use basic authentication, you need to attach `BasicAuthListener` to http clie $response = $user->get(); ``` -### OAuth authorization +### OAuth1 authorization This library comes with a `OAuthListener` which will sign all requests for you. All you need to do is to attach the listener to http client with oauth credentials before making a request. +#### OAuth1 1-legged ```php // OAuth 1-legged example // You can create a new consumer at: https://bitbucket.org/account/user//api @@ -44,6 +45,99 @@ http client with oauth credentials before making a request. $response = $user->get(); ``` +#### OAuth1 3-legged + +You can use any 3rd party library to complete this [flow][3] and set OAuth credentials when you instantiate `OAuthListener`. + +In the following example [PHP League's OAuth 1.0 Client][4] is used. + + ```php + session_start(); + + // @see: https://bitbucket.org/account/user//api + $oauth_params = array( + 'identifier' => 'aaa', + 'secret' => 'bbb', + 'callback_uri' => 'http://example.com/oauth1_3legged.php' + ); + + $server = new League\OAuth1\Client\Server\Bitbucket($oauth_params); + + if (array_key_exists('profile', $_GET)) { + if (false === array_key_exists('bb_credentials', $_SESSION)) { + header('Location: ' . $oauth_params['callback_uri']); + exit; + } + + $oauth_params = array_merge(unserialize($_SESSION['bb_credentials']), array( + 'oauth_consumer_key' => $oauth_params['identifier'], + 'oauth_consumer_secret' => $oauth_params['secret'], + 'oauth_callback' => $oauth_params['callback_uri'], + )); + + + $bitbucket = new \Bitbucket\API\Api(); + $bitbucket->getClient()->addListener( + new \Bitbucket\API\Http\Listener\OAuthListener($oauth_params) + ); + + /** @var \Bitbucket\API\User $user */ + $user = $bitbucket->api('User'); + + $profile = json_decode($user->get()->getContent(), true); + echo sprintf('Logout %s', $profile['user']['username']); + + // show all user repositories + echo '

My repositories:

    '; + array_walk($profile['repositories'], function($repository) { + $repositoryUrl = str_replace('/1.0/repositories/', '', $repository['resource_uri']); + echo sprintf( + '
  • %s
  • ', $repositoryUrl, $repository['name'] + ); + }); + echo '
'; + exit; + } elseif (array_key_exists('login', $_GET)) { + // Retrieve temporary credentials + $temporaryCredentials = $server->getTemporaryCredentials(); + + // Store credentials in the session, we'll need them later + $_SESSION['temporary_credentials'] = serialize($temporaryCredentials); + session_write_close(); + + // Second part of OAuth 1.0 authentication is to redirect the + // resource owner to the login screen on the server. + $server->authorize($temporaryCredentials); + exit; + } elseif (array_key_exists('oauth_token', $_GET) && array_key_exists('oauth_verifier', $_GET)) { + // Retrieve the temporary credentials we saved before + $temporaryCredentials = unserialize($_SESSION['temporary_credentials']); + + // We will now retrieve token credentials from the server + $tokenCredentials = $server->getTokenCredentials( + $temporaryCredentials, $_GET['oauth_token'], $_GET['oauth_verifier'] + ); + + $oauth_params = array( + 'oauth_token' => $tokenCredentials->getIdentifier(), + 'oauth_token_secret' => $tokenCredentials->getSecret() + ); + + unset($_SESSION['temporary_credentials'], $_SESSION['token_credentials']); + $_SESSION['bb_credentials'] = serialize($oauth_params); + session_write_close(); + + // redirect the user to the profile page, in order to fetch his/her information. + header('Location: '.$oauth_params['callback_uri'].'?profile'); + exit; + } elseif (array_key_exists('logout', $_GET)) { + unset($_SESSION['bb_credentials']); + session_write_close(); + } + + echo 'Login with BitBucket!'; + ``` + ### OAuth2 authorization You can use `OAuth2Listener` in order to make authorized requests using version 2 of OAuth protocol. @@ -121,3 +215,4 @@ In the following example [PHP League's OAuth 2.0 Client][1] is used with [Bitbuc [1]: http://oauth2-client.thephpleague.com/ [2]: https://github.com/stevenmaguire/oauth2-bitbucket [3]: http://oauthbible.com/#oauth-2-three-legged +[4]: https://github.com/thephpleague/oauth1-client From 1cb92cf7af8f9a259e2c42d599500f0feec8d82b Mon Sep 17 00:00:00 2001 From: Alexandru Guzinschi Date: Tue, 8 Sep 2015 08:28:04 +0300 Subject: [PATCH 33/33] updated CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b02187e..d08e170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,16 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [0.7.0] / [unreleased] +## [0.7.0] / 2015-09-08 ### Added: - Implemented webhooks endpoints. - Toggle spam on a changeset comment. (issue #2) + - Support for OAuth2. (issue #34) ### Changed: - Marked Repositories/Services as deprecated in favor of Repositories/Hooks. (issue #29) + - [DOCS] Added example on how to use this library in combination with a 3rd party OAuth1 client in a 3-legged flow. ### Fixed: - `forking_policy` parameter renamed to `fork_policy` on repository endpoint. (issue #32)