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

Function TestAuthToken_IsValid

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

Source from the content-addressed store, hash-verified

21)
22
23func TestAuthToken_IsValid(t *testing.T) {
24 tests := []struct {
25 name string
26 token *AuthToken
27 expected bool
28 }{
29 {
30 name: "nil token",
31 token: nil,
32 expected: false,
33 },
34 {
35 name: "empty ticket",
36 token: &AuthToken{
37 Ticket: "",
38 ExpiresAt: time.Now().Add(1 * time.Hour),
39 },
40 expected: false,
41 },
42 {
43 name: "expired token",
44 token: &AuthToken{
45 Ticket: "valid-ticket",
46 ExpiresAt: time.Now().Add(-1 * time.Hour),
47 },
48 expected: false,
49 },
50 {
51 name: "valid token",
52 token: &AuthToken{
53 Ticket: "valid-ticket",
54 ExpiresAt: time.Now().Add(1 * time.Hour),
55 },
56 expected: true,
57 },
58 }
59
60 for _, tt := range tests {
61 t.Run(tt.name, func(t *testing.T) {
62 assert.Equal(t, tt.expected, tt.token.IsValid())
63 })
64 }
65}
66
67func TestNewAuthManagerWithPassword(t *testing.T) {
68 httpClient := &HTTPClient{baseURL: "https://test.example.com"}

Callers

nothing calls this directly

Calls 2

RunMethod · 0.80
IsValidMethod · 0.80

Tested by

no test coverage detected