MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestIsAuthenticated

Function TestIsAuthenticated

internal/auth/auth_test.go:37–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestIsAuthenticated(t *testing.T) {
38 server := httptest.NewServer(http.NotFoundHandler())
39 defer server.Close()
40
41 t.Run("with_HEY_TOKEN", func(t *testing.T) {
42 t.Setenv("HEY_TOKEN", "tok")
43 mgr := testManager(t, server)
44 if !mgr.IsAuthenticated() {
45 t.Error("expected authenticated with HEY_TOKEN set")
46 }
47 })
48
49 t.Run("with_stored_token", func(t *testing.T) {
50 t.Setenv("HEY_TOKEN", "")
51 mgr := testManager(t, server)
52 if err := mgr.LoginWithToken("stored-tok"); err != nil {
53 t.Fatalf("LoginWithToken: %v", err)
54 }
55 if !mgr.IsAuthenticated() {
56 t.Error("expected authenticated with stored token")
57 }
58 })
59
60 t.Run("unauthenticated", func(t *testing.T) {
61 t.Setenv("HEY_TOKEN", "")
62 mgr := testManager(t, server)
63 if mgr.IsAuthenticated() {
64 t.Error("expected not authenticated with no credentials")
65 }
66 })
67}
68
69func TestNormalizeBaseURL(t *testing.T) {
70 tests := []struct {

Callers

nothing calls this directly

Calls 4

testManagerFunction · 0.85
IsAuthenticatedMethod · 0.80
LoginWithTokenMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected