forked from gentlero/bitbucket-api
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
152 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: "Continuous Integration" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
phpunit: | ||
name: Test Suite | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: [7.1, 7.2, 7.3, 7.4, 8.0] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install PHP ${{ matrix.php }} | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: "none" | ||
ini-values: "memory_limit=-1, phar.readonly=0" | ||
php-version: ${{ matrix.php }} | ||
|
||
- name: "Determine composer cache directory" | ||
id: "determine-composer-cache-directory" | ||
run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/cache@v1" | ||
with: | ||
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" | ||
key: "php-${{ matrix.php }}-ci" | ||
restore-keys: "php-${{ matrix.php }}" | ||
|
||
- name: "Install dependencies" | ||
run: composer update --no-progress -o --prefer-dist | ||
|
||
- name: "Run PHPUnit" | ||
run: ./vendor/bin/phpunit | ||
|
||
- name: "Run PHPStan" | ||
run: ./vendor/bin/phpstan analyze lib test --level=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ vendor/ | |
report/ | ||
build/ | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,35 @@ | |
|
||
namespace Bitbucket\Tests\API\Http\Plugin; | ||
|
||
use Bitbucket\API\Exceptions\ForbiddenAccessException; | ||
use Bitbucket\API\Http\ClientInterface; | ||
use Bitbucket\Tests\API as Tests; | ||
use Bitbucket\API\Http\Plugin\OAuth2Plugin; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use Http\Client\Promise\HttpFulfilledPromise; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* @author Alexandru G. <[email protected]> | ||
*/ | ||
class OAuth2PluginTest extends Tests\TestCase | ||
{ | ||
/** @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
/** @var ClientInterface|MockObject */ | ||
private $httpClient; | ||
|
||
protected function setUp() | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->httpClient = $this->getMockBuilder(ClientInterface::class)->getMock(); | ||
} | ||
|
||
/** | ||
* @expectedException \Bitbucket\API\Exceptions\ForbiddenAccessException | ||
*/ | ||
public function testGetAccessTokenShouldFailWithInvalidJson() | ||
{ | ||
$this->expectException(ForbiddenAccessException::class); | ||
|
||
$oauth_params = [ | ||
'client_id' => 'aaa', | ||
'client_secret' => 'bbb' | ||
|
@@ -61,11 +62,10 @@ public function testGetAccessTokenShouldFailWithInvalidJson() | |
}); | ||
} | ||
|
||
/** | ||
* @expectedException \Bitbucket\API\Exceptions\ForbiddenAccessException | ||
*/ | ||
public function testGetAccessTokenFail() | ||
{ | ||
$this->expectException(ForbiddenAccessException::class); | ||
|
||
$responseBody = '{"error_description": "Invalid OAuth client credentials", "error": "unauthorized_client"}'; | ||
$response = new Response(200, [], $responseBody); | ||
|
||
|
@@ -111,8 +111,8 @@ public function testOauth2ListenerDoesNotReplaceExistingBearer() | |
$plugin->handleRequest($request, function (RequestInterface $request) { | ||
$authHeader = $request->getHeader('Authorization')[0]; | ||
|
||
$this->assertContains('Bearer', $authHeader); | ||
$this->assertContains('secret', $authHeader); | ||
$this->assertStringContainsString('Bearer', $authHeader); | ||
$this->assertStringContainsString('secret', $authHeader); | ||
|
||
return new HttpFulfilledPromise(new Response()); | ||
}, function () { | ||
|
@@ -148,8 +148,8 @@ public function testMakeSureRequestIncludesBearer() | |
$plugin->handleRequest($request, function (RequestInterface $request) { | ||
$authHeader = $request->getHeader('Authorization')[0]; | ||
|
||
$this->assertContains('Bearer', $authHeader); | ||
$this->assertContains('secret', $authHeader); | ||
$this->assertStringContainsString('Bearer', $authHeader); | ||
$this->assertStringContainsString('secret', $authHeader); | ||
|
||
return new HttpFulfilledPromise(new Response()); | ||
}, function () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.