MCPcopy
hub / github.com/kubernetes/kubectl / TestWhoAmIRun

Function TestWhoAmIRun

pkg/cmd/auth/whoami_test.go:39–341  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37)
38
39func TestWhoAmIRun(t *testing.T) {
40 tests := []struct {
41 name string
42 o *WhoAmIOptions
43 args []string
44 serverErr error
45 alphaDisabled bool
46 betaDisabled bool
47 stableDisabled bool
48
49 expectedError error
50 expectedBodyStrings []string
51 }{
52 {
53 name: "success test",
54 o: &WhoAmIOptions{
55 resourcePrinterFunc: printTableSelfSubjectAccessReview,
56 },
57 args: []string{},
58 expectedBodyStrings: []string{
59 `ATTRIBUTE VALUE`,
60 `Username jane.doe`,
61 `UID uniq-id`,
62 `Groups [students teachers]`,
63 `Extra: skills [reading learning]`,
64 `Extra: subjects [math sports]`,
65 ``,
66 },
67 },
68 {
69 name: "JSON test",
70 o: &WhoAmIOptions{
71 resourcePrinterFunc: printers.NewTypeSetter(scheme.Scheme).ToPrinter(&printers.JSONPrinter{}).PrintObj,
72 },
73 args: []string{},
74 expectedBodyStrings: []string{
75 `{
76 "kind": "SelfSubjectReview",
77 "apiVersion": "authentication.k8s.io/v1",
78 "metadata": {},
79 "status": {
80 "userInfo": {
81 "username": "jane.doe",
82 "uid": "uniq-id",
83 "groups": [
84 "students",
85 "teachers"
86 ],
87 "extra": {
88 "skills": [
89 "reading",
90 "learning"
91 ],
92 "subjects": [
93 "math",
94 "sports"
95 ]
96 }

Callers

nothing calls this directly

Calls 7

WithNamespaceMethod · 0.80
CleanupMethod · 0.80
StringMethod · 0.65
ToPrinterMethod · 0.45
RunMethod · 0.45
ErrorMethod · 0.45
JoinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…