MCPcopy Create free account
hub / github.com/cli/cli / TestMaskToken

Function TestMaskToken

pkg/cmd/auth/status/status_test.go:1162–1229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1160}
1161
1162func TestMaskToken(t *testing.T) {
1163 tests := []struct {
1164 name string
1165 token string
1166 want string
1167 }{
1168 {
1169 name: "empty token",
1170 token: "",
1171 want: "",
1172 },
1173 {
1174 name: "classic personal access token",
1175 token: "ghp_abc123",
1176 want: "ghp_******",
1177 },
1178 {
1179 name: "oauth token",
1180 token: "gho_abc123",
1181 want: "gho_******",
1182 },
1183 {
1184 name: "user-to-server token",
1185 token: "ghu_abc123",
1186 want: "ghu_******",
1187 },
1188 {
1189 name: "server-to-server token",
1190 token: "ghs_abc123",
1191 want: "ghs_******",
1192 },
1193 {
1194 name: "refresh token",
1195 token: "ghr_abc123",
1196 want: "ghr_******",
1197 },
1198 {
1199 name: "fine-grained personal access token with internal underscore",
1200 token: "github_pat_abc_123456",
1201 want: "github_pat_**********",
1202 },
1203 {
1204 name: "token with multiple internal underscores masks everything after prefix",
1205 token: "ghs_aaa_bbb_ccc",
1206 want: "ghs_***********",
1207 },
1208 {
1209 name: "unknown prefix is fully masked",
1210 token: "unknown_abc123",
1211 want: "**************",
1212 },
1213 {
1214 name: "token without underscore is fully masked",
1215 token: "abc123",
1216 want: "******",
1217 },
1218 {
1219 name: "token equal to known prefix has nothing to mask",

Callers

nothing calls this directly

Calls 3

maskTokenFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected