-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from genkgo/fix_too_many_provider_token_updates
fix PreventTooManyProviderTokenUpdates
- Loading branch information
Showing
9 changed files
with
169 additions
and
67 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,35 @@ | ||
# .github/workflows/code_checks.yaml | ||
name: code check | ||
|
||
on: | ||
pull_request: null | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: ['7.3', '7.4'] | ||
|
||
name: PHP ${{ matrix.php }} tests | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: shivammathur/setup-php@v1 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: none | ||
|
||
- name: Download dependencies | ||
run: composer update --no-ansi --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest | ||
|
||
- name: Run tests | ||
run: ./vendor/bin/phpunit -c phpunit.xml | ||
- name: Static analysis for source | ||
run: ./vendor/bin/phpstan analyse -l max src | ||
- name: Static analysis for tests | ||
run: ./vendor/bin/phpstan analyse -l max test | ||
- name: Code Style | ||
run: ./vendor/bin/php-cs-fixer fix --dry-run --verbose --config .php_cs.dist ./src ./test |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg+DTfFvD/nyVqL2Gy | ||
hzWFoG0i1jHnhSSEy8rXKmrYfp2hRANCAARBgZTUCNDF4iB41yMoYExnL7KrVgq9 | ||
KnzGjW0FvcpwDsYgYbXGV6e4h1IUtSC4+MubOHqbEZt418DTJM17saPb | ||
-----END PRIVATE KEY----- |
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,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Genkgo\Push\Unit\Apn; | ||
|
||
use Apple\ApnPush\Protocol\Http\Request; | ||
use Genkgo\Push\AbstractTestCase; | ||
use Genkgo\Push\Apn\JwtAuthenticator; | ||
|
||
final class JwtAuthenticatorTest extends AbstractTestCase | ||
{ | ||
public function testCreateToken(): void | ||
{ | ||
$request = new Request('https://test', 'test'); | ||
$authenticator = new JwtAuthenticator(__DIR__ . '/../../Stubs/test.p8', 'AB1234', 'Q12345'); | ||
$authRequest = $authenticator->authenticate($request)->getHeaders()['Authorization']; | ||
|
||
$this->assertNotEquals('Bearer ', $authRequest); | ||
} | ||
|
||
public function testDefaultSameToken(): void | ||
{ | ||
$request = new Request('https://test', 'test'); | ||
$authenticator = new JwtAuthenticator(__DIR__ . '/../../Stubs/test.p8', 'AB1234', 'Q12345'); | ||
$authRequest1 = $authenticator->authenticate($request)->getHeaders()['Authorization']; | ||
\sleep(1); | ||
$authRequest2 = $authenticator->authenticate($request)->getHeaders()['Authorization']; | ||
|
||
$this->assertNotEquals('Bearer ', $authRequest1); | ||
$this->assertNotEquals('Bearer ', $authRequest2); | ||
$this->assertEquals($authRequest1, $authRequest2); | ||
} | ||
|
||
public function testPreventTooManyProviderTokenUpdates(): void | ||
{ | ||
$request = new Request('https://test', 'test'); | ||
$authenticator = new JwtAuthenticator(__DIR__ . '/../../Stubs/test.p8', 'AB1234', 'Q12345', 'PT1S'); | ||
$authRequest1 = $authenticator->authenticate($request)->getHeaders()['Authorization']; | ||
\sleep(2); | ||
$authRequest2 = $authenticator->authenticate($request)->getHeaders()['Authorization']; | ||
|
||
$this->assertNotEquals('Bearer ', $authRequest1); | ||
$this->assertNotEquals('Bearer ', $authRequest2); | ||
$this->assertNotEquals($authRequest1, $authRequest2); | ||
} | ||
} |