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

Function TestMaskToken

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

Source from the content-addressed store, hash-verified

784}
785
786func TestMaskToken(t *testing.T) {
787 tests := []struct {
788 name string
789 token string
790 want string
791 }{
792 {
793 name: "empty token",
794 token: "",
795 want: "",
796 },
797 {
798 name: "classic personal access token",
799 token: "ghp_abc123",
800 want: "ghp_******",
801 },
802 {
803 name: "oauth token",
804 token: "gho_abc123",
805 want: "gho_******",
806 },
807 {
808 name: "user-to-server token",
809 token: "ghu_abc123",
810 want: "ghu_******",
811 },
812 {
813 name: "server-to-server token",
814 token: "ghs_abc123",
815 want: "ghs_******",
816 },
817 {
818 name: "refresh token",
819 token: "ghr_abc123",
820 want: "ghr_******",
821 },
822 {
823 name: "fine-grained personal access token with internal underscore",
824 token: "github_pat_abc_123456",
825 want: "github_pat_**********",
826 },
827 {
828 name: "token with multiple internal underscores masks everything after prefix",
829 token: "ghs_aaa_bbb_ccc",
830 want: "ghs_***********",
831 },
832 {
833 name: "unknown prefix is fully masked",
834 token: "unknown_abc123",
835 want: "**************",
836 },
837 {
838 name: "token without underscore is fully masked",
839 token: "abc123",
840 want: "******",
841 },
842 {
843 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