Skip to content

Commit be0905d

Browse files
cuppettclaude
andcommitted
Fix callWithToken visibility and ServiceAccountToken tests
- Change callWithToken() from protected to public (required for external access) - Protected visibility triggered __call() magic method causing type errors - Add "Internal use only" warning to docblock - Add bootstrap token setup to ServiceAccountTokenIntegrationTest - All three ServiceAccountToken integration tests now pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
1 parent 23b2ca9 commit be0905d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Traits/Cluster/MakesHttpCalls.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ protected function makeRequest(string $method, string $path, string $payload = '
193193
*
194194
* WARNING: This method temporarily mutates instance authentication state and is NOT safe
195195
* for concurrent or async use (e.g., ReactPHP, Amp, Swoole). Only use in synchronous,
196-
* single-threaded contexts.
196+
* single-threaded contexts. Internal use only.
197197
*
198198
* @return \Psr\Http\Message\ResponseInterface
199199
*
200200
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesAPIException
201201
*/
202-
protected function callWithToken(string $token, string $method, string $path, string $payload = '', array $query = ['pretty' => 1], array $options = [])
202+
public function callWithToken(string $token, string $method, string $path, string $payload = '', array $query = ['pretty' => 1], array $options = [])
203203
{
204204
// Temporarily store current authentication state
205205
$originalToken = $this->token;

tests/Auth/ServiceAccountTokenIntegrationTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ private function isClusterAvailable(): bool
3131

3232
public function test_service_account_token_request()
3333
{
34+
// Set up bootstrap credentials (kubectl proxy accepts any token)
35+
$this->cluster->withToken('bootstrap-token');
36+
3437
// Create test service account
3538
$sa = $this->cluster->serviceAccount()
3639
->setName('test-token-requester')
@@ -67,6 +70,9 @@ public function test_service_account_token_request()
6770

6871
public function test_service_account_token_with_audiences()
6972
{
73+
// Set up bootstrap credentials (kubectl proxy accepts any token)
74+
$this->cluster->withToken('bootstrap-token');
75+
7076
$sa = $this->cluster->serviceAccount()
7177
->setName('test-token-audience')
7278
->setNamespace('default')
@@ -89,14 +95,18 @@ public function test_service_account_token_with_audiences()
8995

9096
public function test_convenience_method_with_service_account_token()
9197
{
98+
// Set up bootstrap credentials for service account creation
99+
$this->cluster->withToken('bootstrap-token');
100+
92101
$sa = $this->cluster->serviceAccount()
93102
->setName('test-convenience-sa')
94103
->setNamespace('default')
95104
->createOrUpdate();
96105

97106
try {
98-
// Use convenience method
107+
// Use convenience method (need bootstrap token for TokenRequest API)
99108
$newCluster = KubernetesCluster::fromUrl('http://127.0.0.1:8080')
109+
->withToken('bootstrap-token')
100110
->withServiceAccountToken('default', 'test-convenience-sa', 1800);
101111

102112
$token = $newCluster->getAuthToken();

0 commit comments

Comments
 (0)