From 06c62a24eb9272063acf8f5c03a0516296585c14 Mon Sep 17 00:00:00 2001 From: Tomas Vik Date: Wed, 9 Apr 2025 15:59:19 +0200 Subject: [PATCH] chore: remove legacy token format validation --- api/default.go | 9 --------- api/default_test.go | 37 ---------------------------------- commands/auth/status/status.go | 3 --- 3 files changed, 49 deletions(-) delete mode 100644 api/default_test.go diff --git a/api/default.go b/api/default.go index e426b1657..ac3519ab9 100644 --- a/api/default.go +++ b/api/default.go @@ -1,12 +1,3 @@ package api var DefaultListLimit = 30 - -// IsValidToken checks if a token provided is valid. -// The token string must be 26 characters in length and have the 'glpat-' -// prefix or just be 20 characters long to be recognized as a valid personal access token. -// token can be 64 characters to include oauth tokens -// TODO: check if token has minimum scopes required by glab -func IsValidToken(token string) bool { - return (len(token) == 26 && token[:6] == "glpat-") || len(token) == 20 || len(token) == 64 -} diff --git a/api/default_test.go b/api/default_test.go deleted file mode 100644 index d21d95e53..000000000 --- a/api/default_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package api - -import "testing" - -func TestIsValidToken(t *testing.T) { - type args struct { - token string - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "Token Is Valid", - args: args{token: "xxxxxxxxxxxxxxxxxxxx"}, - want: true, - }, - { - name: "Oauth token is valid", - args: args{token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}, - want: true, - }, - { - name: "Token Is inValid", - args: args{token: "123"}, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsValidToken(tt.args.token); got != tt.want { - t.Errorf("IsValidToken() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/commands/auth/status/status.go b/commands/auth/status/status.go index 30e208399..33af7bea8 100644 --- a/commands/auth/status/status.go +++ b/commands/auth/status/status.go @@ -124,9 +124,6 @@ func statusRun(opts *StatusOpts) error { tokenDisplay = token } addMsg("%s Token: %s", c.GreenCheck(), tokenDisplay) - if !api.IsValidToken(token) { - addMsg("%s Invalid token provided in configuration file.", c.WarnIcon()) - } } else { addMsg("%s No token provided in configuration file.", c.WarnIcon()) } -- GitLab