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

Function TestValidateCopilotPAT

pkg/stringutil/pat_validation_test.go:77–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestValidateCopilotPAT(t *testing.T) {
78 tests := []struct {
79 name string
80 token string
81 expectError bool
82 errorMsg string
83 }{
84 {
85 name: "valid fine-grained PAT",
86 token: "github_pat_abc123xyz",
87 expectError: false,
88 },
89 {
90 name: "classic PAT should fail",
91 token: "ghp_abc123xyz",
92 expectError: true,
93 errorMsg: "classic personal access tokens",
94 },
95 {
96 name: "OAuth token should fail",
97 token: "gho_abc123xyz",
98 expectError: true,
99 errorMsg: "OAuth tokens",
100 },
101 {
102 name: "unknown token should fail",
103 token: "random_token",
104 expectError: true,
105 errorMsg: "unrecognized token format",
106 },
107 {
108 name: "empty token should fail",
109 token: "",
110 expectError: true,
111 errorMsg: "unrecognized token format",
112 },
113 }
114
115 for _, tt := range tests {
116 t.Run(tt.name, func(t *testing.T) {
117 err := ValidateCopilotPAT(tt.token)
118 if tt.expectError {
119 require.Error(t, err, "should return error for invalid token")
120 assert.Contains(t, err.Error(), tt.errorMsg, "error message should contain expected text")
121 } else {
122 assert.NoError(t, err, "should not return error for valid token")
123 }
124 })
125 }
126}
127
128func TestGetPATTypeDescription(t *testing.T) {
129 tests := []struct {

Callers

nothing calls this directly

Calls 3

ValidateCopilotPATFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected