-
Notifications
You must be signed in to change notification settings - Fork 30
/
AppleJwtStructFactoryTest.php
69 lines (62 loc) · 2.33 KB
/
AppleJwtStructFactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php declare(strict_types=1);
namespace Azimo\Apple\Tests\Unit\Auth\Factory;
use Azimo\Apple\Auth\Factory\AppleJwtStructFactory;
use Azimo\Apple\Auth\Struct\JwtPayload;
use DateTimeImmutable;
use Lcobucci\JWT\Token;
use Mockery\Adapter\Phpunit\MockeryTestCase;
final class AppleJwtStructFactoryTest extends MockeryTestCase
{
private AppleJwtStructFactory $appleJwtStructFactory;
protected function setUp(): void
{
parent::setUp();
$this->appleJwtStructFactory = new AppleJwtStructFactory();
}
public function testIfCreateJwtPayloadFromTokenReturnsExpectedJsonPayload(): void
{
$currentDate = new DateTimeImmutable();
self::assertEquals(
new JwtPayload(
'https://appleid.apple.com',
['com.acme.app'],
$currentDate,
$currentDate,
'foo.bar.baz',
'qGzMhtsfTCom-bl1PJYLHk',
true,
true,
1591622011,
true,
null
),
$this->appleJwtStructFactory->createJwtPayloadFromToken(
new Token\Plain(
new Token\DataSet(
[
'kid' => 'eXaunmL',
'alg' => 'RS256',
], ''
),
new Token\DataSet(
[
'iss' => 'https://appleid.apple.com',
'aud' => ['com.acme.app'],
'exp' => $currentDate,
'iat' => $currentDate,
'sub' => 'foo.bar.baz',
'c_hash' => 'qGzMhtsfTCom-bl1PJYLHk',
'email' => '[email protected]',
'email_verified' => 'true',
'is_private_email' => 'true',
'auth_time' => 1591622011,
'nonce_supported' => true
], ''
),
new Token\Signature('', '')
)
)
);
}
}