Skip to content

Commit 3a97be6

Browse files
refactor: Use array_merge for audience configuration in middleware tests
1 parent 77705b9 commit 3a97be6

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
lines changed

tests/Unit/Middleware/AuthorizeMiddlewareTest.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@
8686
$token = Generator::create($this->secret, Token::ALGO_HS256, [
8787
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
8888
"sub" => "auth0|123456",
89-
"aud" => [
90-
"https://example.com/health-api",
91-
"https://my-domain.auth0.com/userinfo",
92-
config('auth0.guards.default.clientId')
93-
],
89+
"aud" => array_merge(
90+
$this->audience,
91+
[config('auth0.guards.default.clientId')]
92+
),
9493
"azp" => config('auth0.guards.default.clientId'),
9594
"exp" => time() + 60,
9695
"iat" => time(),
@@ -115,11 +114,10 @@
115114
$token = Generator::create($this->secret, Token::ALGO_HS256, [
116115
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
117116
"sub" => "auth0|123456",
118-
"aud" => [
119-
"https://example.com/health-api",
120-
"https://my-domain.auth0.com/userinfo",
121-
config('auth0.guards.default.clientId')
122-
],
117+
"aud" => array_merge(
118+
$this->audience,
119+
[config('auth0.guards.default.clientId')]
120+
),
123121
"azp" => config('auth0.guards.default.clientId'),
124122
"exp" => time() + 60,
125123
"iat" => time(),
@@ -144,11 +142,10 @@
144142
$token = Generator::create($this->secret, Token::ALGO_HS256, [
145143
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
146144
"sub" => "auth0|123456",
147-
"aud" => [
148-
"https://example.com/health-api",
149-
"https://my-domain.auth0.com/userinfo",
150-
config('auth0.guards.default.clientId')
151-
],
145+
"aud" => array_merge(
146+
$this->audience,
147+
[config('auth0.guards.default.clientId')]
148+
),
152149
"azp" => config('auth0.guards.default.clientId'),
153150
"exp" => time() + 60,
154151
"iat" => time(),

tests/Unit/Middleware/AuthorizeOptionalMiddlewareTest.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@
6767
$token = Generator::create($this->secret, Token::ALGO_HS256, [
6868
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
6969
"sub" => "auth0|123456",
70-
"aud" => [
71-
"https://example.com/health-api",
72-
"https://my-domain.auth0.com/userinfo",
73-
config('auth0.guards.default.clientId')
74-
],
70+
"aud" => array_merge(
71+
$this->audience,
72+
[config('auth0.guards.default.clientId')]
73+
),
7574
"azp" => config('auth0.guards.default.clientId'),
7675
"exp" => time() + 60,
7776
"iat" => time(),
@@ -96,11 +95,10 @@
9695
$token = Generator::create($this->secret, Token::ALGO_HS256, [
9796
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
9897
"sub" => "auth0|123456",
99-
"aud" => [
100-
"https://example.com/health-api",
101-
"https://my-domain.auth0.com/userinfo",
102-
config('auth0.guards.default.clientId')
103-
],
98+
"aud" => array_merge(
99+
$this->audience,
100+
[config('auth0.guards.default.clientId')]
101+
),
104102
"azp" => config('auth0.guards.default.clientId'),
105103
"exp" => time() + 60,
106104
"iat" => time(),
@@ -125,11 +123,10 @@
125123
$token = Generator::create($this->secret, Token::ALGO_HS256, [
126124
"iss" => 'https://' . config('auth0.guards.default.domain') . '/',
127125
"sub" => "auth0|123456",
128-
"aud" => [
129-
"https://example.com/health-api",
130-
"https://my-domain.auth0.com/userinfo",
131-
config('auth0.guards.default.clientId')
132-
],
126+
"aud" => array_merge(
127+
$this->audience,
128+
[config('auth0.guards.default.clientId')]
129+
),
133130
"azp" => config('auth0.guards.default.clientId'),
134131
"exp" => time() + 60,
135132
"iat" => time(),

0 commit comments

Comments
 (0)