MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestAuthManager_GetValidToken_WithCachedToken

Function TestAuthManager_GetValidToken_WithCachedToken

pkg/api/auth_test.go:145–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestAuthManager_GetValidToken_WithCachedToken(t *testing.T) {
146 httpClient := &HTTPClient{baseURL: "https://test.example.com"}
147 logger := testutils.NewTestLogger()
148
149 authManager := NewAuthManagerWithPassword(httpClient, "user", "pass", logger)
150
151 // Set a valid cached token
152 cachedToken := &AuthToken{
153 Ticket: "cached-ticket",
154 CSRFToken: "cached-csrf",
155 Username: "testuser",
156 ExpiresAt: time.Now().Add(1 * time.Hour),
157 }
158 authManager.authToken = cachedToken
159
160 token, err := authManager.GetValidToken(context.Background())
161 require.NoError(t, err)
162 assert.Equal(t, cachedToken, token)
163}
164
165func TestAuthManager_GetValidToken_WithExpiredToken(t *testing.T) {
166 // Create a test server that returns a successful authentication response

Callers

nothing calls this directly

Calls 3

NewTestLoggerFunction · 0.92
GetValidTokenMethod · 0.80

Tested by

no test coverage detected