@@ -102,6 +102,46 @@ describe("sentry auth login --token", () => {
102102 } ) ;
103103} ) ;
104104
105+ describe ( "sentry auth whoami" , ( ) => {
106+ test ( "requires authentication" , async ( ) => {
107+ const result = await ctx . run ( [ "auth" , "whoami" ] ) ;
108+
109+ const output = result . stdout + result . stderr ;
110+ expect ( output ) . toMatch ( / n o t a u t h e n t i c a t e d / i) ;
111+ expect ( result . exitCode ) . toBe ( 1 ) ;
112+ } ) ;
113+
114+ test ( "shows current user identity" , async ( ) => {
115+ await ctx . setAuthToken ( TEST_TOKEN ) ;
116+
117+ const result = await ctx . run ( [ "auth" , "whoami" ] ) ;
118+
119+ expect ( result . exitCode ) . toBe ( 0 ) ;
120+ expect ( result . stdout ) . toContain ( "test@example.com" ) ;
121+ } ) ;
122+
123+ test ( "supports --json output" , async ( ) => {
124+ await ctx . setAuthToken ( TEST_TOKEN ) ;
125+
126+ const result = await ctx . run ( [ "auth" , "whoami" , "--json" ] ) ;
127+
128+ expect ( result . exitCode ) . toBe ( 0 ) ;
129+ const json = JSON . parse ( result . stdout ) ;
130+ expect ( json . id ) . toBe ( "12345" ) ;
131+ expect ( json . email ) . toBe ( "test@example.com" ) ;
132+ expect ( json . username ) . toBe ( "testuser" ) ;
133+ } ) ;
134+
135+ test ( "sentry whoami top-level alias works" , async ( ) => {
136+ await ctx . setAuthToken ( TEST_TOKEN ) ;
137+
138+ const result = await ctx . run ( [ "whoami" ] ) ;
139+
140+ expect ( result . exitCode ) . toBe ( 0 ) ;
141+ expect ( result . stdout ) . toContain ( "test@example.com" ) ;
142+ } ) ;
143+ } ) ;
144+
105145describe ( "sentry auth logout" , ( ) => {
106146 test (
107147 "clears stored auth" ,
0 commit comments