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

Function TestClassifyPAT

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

Source from the content-addressed store, hash-verified

10)
11
12func TestClassifyPAT(t *testing.T) {
13 tests := []struct {
14 name string
15 token string
16 expected PATType
17 }{
18 {
19 name: "fine-grained PAT",
20 token: "github_pat_abc123xyz",
21 expected: PATTypeFineGrained,
22 },
23 {
24 name: "classic PAT",
25 token: "ghp_abc123xyz",
26 expected: PATTypeClassic,
27 },
28 {
29 name: "OAuth token",
30 token: "gho_abc123xyz",
31 expected: PATTypeOAuth,
32 },
33 {
34 name: "unknown token - random string",
35 token: "random_token_123",
36 expected: PATTypeUnknown,
37 },
38 {
39 name: "unknown token - empty",
40 token: "",
41 expected: PATTypeUnknown,
42 },
43 {
44 name: "partial prefix - github_pa",
45 token: "github_pa_abc123",
46 expected: PATTypeUnknown,
47 },
48 {
49 name: "partial prefix - gh_",
50 token: "gh_abc123",
51 expected: PATTypeUnknown,
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 result := ClassifyPAT(tt.token)
58 assert.Equal(t, tt.expected, result, "ClassifyPAT should return correct type")
59 })
60 }
61}
62
63func TestPATType_IsFineGrained(t *testing.T) {
64 assert.True(t, PATTypeFineGrained.IsFineGrained(), "fine-grained should return true")

Callers

nothing calls this directly

Calls 2

ClassifyPATFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected