MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestAuthKind

Function TestAuthKind

sdk/cliproxy/auth/classification_test.go:5–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestAuthKind(t *testing.T) {
6 tests := []struct {
7 name string
8 auth *Auth
9 want string
10 }{
11 {
12 name: "explicit api key attribute",
13 auth: &Auth{Attributes: map[string]string{AttributeAuthKind: "api_key"}},
14 want: AuthKindAPIKey,
15 },
16 {
17 name: "explicit oauth attribute wins over api key fallback",
18 auth: &Auth{Attributes: map[string]string{AttributeAuthKind: "oauth", AttributeAPIKey: "k"}},
19 want: AuthKindOAuth,
20 },
21 {
22 name: "explicit oauth metadata",
23 auth: &Auth{Metadata: map[string]any{AttributeAuthKind: "oauth"}},
24 want: AuthKindOAuth,
25 },
26 {
27 name: "legacy api key attribute",
28 auth: &Auth{Attributes: map[string]string{AttributeAPIKey: "k"}},
29 want: AuthKindAPIKey,
30 },
31 {
32 name: "legacy oauth metadata",
33 auth: &Auth{Metadata: map[string]any{"access_token": "token"}},
34 want: AuthKindOAuth,
35 },
36 {
37 name: "unknown metadata shape",
38 auth: &Auth{Metadata: map[string]any{"type": "test"}},
39 want: "",
40 },
41 }
42
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 if got := tt.auth.AuthKind(); got != tt.want {
46 t.Fatalf("AuthKind() = %q, want %q", got, tt.want)
47 }
48 })
49 }
50}
51
52func TestAuthSourceKind(t *testing.T) {
53 tests := []struct {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.80
AuthKindMethod · 0.80

Tested by

no test coverage detected