MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_IsAuthError

Function TestSpec_PublicAPI_IsAuthError

pkg/gitutil/spec_test.go:74–124  ·  view source on GitHub ↗

TestSpec_PublicAPI_IsAuthError validates the documented behavior of IsAuthError as described in the package README.md. Specification: Returns true when errMsg indicates an authentication or authorization failure (GH_TOKEN, GITHUB_TOKEN, unauthorized, forbidden, SAML enforcement, etc.).

(t *testing.T)

Source from the content-addressed store, hash-verified

72// authorization failure (GH_TOKEN, GITHUB_TOKEN, unauthorized, forbidden,
73// SAML enforcement, etc.).
74func TestSpec_PublicAPI_IsAuthError(t *testing.T) {
75 tests := []struct {
76 name string
77 errMsg string
78 expected bool
79 }{
80 {
81 name: "GH_TOKEN reference returns true",
82 errMsg: "GH_TOKEN is invalid or expired",
83 expected: true,
84 },
85 {
86 name: "GITHUB_TOKEN reference returns true",
87 errMsg: "GITHUB_TOKEN: authentication failed",
88 expected: true,
89 },
90 {
91 name: "unauthorized returns true",
92 errMsg: "401: unauthorized",
93 expected: true,
94 },
95 {
96 name: "forbidden returns true",
97 errMsg: "403: forbidden",
98 expected: true,
99 },
100 {
101 name: "SAML enforcement message returns true (documented)",
102 errMsg: "Resource protected by organization SAML enforcement",
103 expected: true,
104 },
105 {
106 name: "unrelated error returns false",
107 errMsg: "404: not found",
108 expected: false,
109 },
110 {
111 name: "empty string returns false",
112 errMsg: "",
113 expected: false,
114 },
115 }
116
117 for _, tt := range tests {
118 t.Run(tt.name, func(t *testing.T) {
119 result := gitutil.IsAuthError(tt.errMsg)
120 assert.Equal(t, tt.expected, result,
121 "IsAuthError(%q) should match documented behavior", tt.errMsg)
122 })
123 }
124}
125
126// TestSpec_PublicAPI_IsHexString validates the documented behavior of
127// IsHexString as described in the package README.md.

Callers

nothing calls this directly

Calls 2

IsAuthErrorFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected