File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,23 @@ Token based authentication
5151With token based authentication you need to simulate the
5252``Authorization `` header. After getting valid token setup the request::
5353
54- public function testGet()
55- {
56- $token = $this->getToken();
57- $this->configRequest([
58- 'headers' => ['Authorization' => 'Bearer ' . $token]
59- ]);
60- $this->get('/api/bookmarks');
61- $this->assertResponseOk();
62- }
54+ protected function getToken(): string
55+ {
56+ // Get a token for a known user
57+ $user = $this->fetchTable('Users')->get(1, contain: ['ApiTokens']);
58+
59+ return $user->api_tokens[0]->token;
60+ }
61+
62+ public function testGet()
63+ {
64+ $token = $this->getToken();
65+ $this->configRequest([
66+ 'headers' => ['Authorization' => 'Bearer ' . $token]
67+ ]);
68+ $this->get('/api/bookmarks');
69+ $this->assertResponseOk();
70+ }
6371
6472
6573Basic/Digest based authentication
You can’t perform that action at this time.
0 commit comments