@@ -50,6 +50,13 @@ describe("getUserInfo()", () => {
5050 } ,
5151 { once : true }
5252 ) ,
53+ http . get (
54+ "*/user/tokens/verify" ,
55+ ( ) => {
56+ return HttpResponse . json ( createFetchResult ( [ ] ) ) ;
57+ } ,
58+ { once : true }
59+ ) ,
5360 http . get (
5461 "*/accounts" ,
5562 ( { request } ) => {
@@ -71,10 +78,18 @@ describe("getUserInfo()", () => {
7178 } ) ;
7279 it ( "should say it's using an API token when one is set" , async ( ) => {
7380 vi . stubEnv ( "CLOUDFLARE_API_TOKEN" , "123456789" ) ;
74-
81+ msw . use (
82+ http . get (
83+ "*/user/tokens/verify" ,
84+ ( ) => {
85+ return HttpResponse . json ( createFetchResult ( [ ] ) ) ;
86+ } ,
87+ { once : true }
88+ )
89+ ) ;
7590 const userInfo = await getUserInfo ( ) ;
7691 expect ( userInfo ) . toEqual ( {
77- authType : "API Token" ,
92+ authType : "User API Token" ,
7893 apiToken : "123456789" ,
79948095 accounts : [
@@ -147,14 +162,14 @@ describe("getUserInfo()", () => {
147162 await getUserInfo ( ) ;
148163
149164 expect ( std . warn ) . toMatchInlineSnapshot ( `
150- "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mIt looks like you have used Wrangler v1's \`config\` command to login with an API token.[0m
165+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mIt looks like you have used Wrangler v1's \`config\` command to login with an API token.[0m
151166
152- This is no longer supported in the current version of Wrangler.
153- If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
154- environment variable.
167+ This is no longer supported in the current version of Wrangler.
168+ If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
169+ environment variable.
155170
156- "
157- ` ) ;
171+ "
172+ ` ) ;
158173 } ) ;
159174} ) ;
160175
@@ -184,22 +199,22 @@ describe("whoami", () => {
184199 ) ;
185200 await runWrangler ( `whoami --account "account-2"` ) ;
186201 expect ( std . out ) . toMatchInlineSnapshot ( `
187- "Getting User settings...
188- 👋 You are logged in with an OAuth Token, associated with the email [email protected] . 189- ┌───────────────┬────────────┐
190- │ Account Name │ Account ID │
191- ├───────────────┼────────────┤
192- │ Account One │ account-1 │
193- ├───────────────┼────────────┤
194- │ Account Two │ account-2 │
195- ├───────────────┼────────────┤
196- │ Account Three │ account-3 │
197- └───────────────┴────────────┘
198- 🔓 Token Permissions: If scopes are missing, you may need to logout and re-login.
199- Scope (Access)
200- 🎢 Membership roles in \\"Account Two\\": Contact account super admin to change your permissions.
201- - Test role"
202- ` ) ;
202+ "Getting User settings...
203+ 👋 You are logged in with an OAuth Token, associated with the email [email protected] . 204+ ┌───────────────┬────────────┐
205+ │ Account Name │ Account ID │
206+ ├───────────────┼────────────┤
207+ │ Account One │ account-1 │
208+ ├───────────────┼────────────┤
209+ │ Account Two │ account-2 │
210+ ├───────────────┼────────────┤
211+ │ Account Three │ account-3 │
212+ └───────────────┴────────────┘
213+ 🔓 Token Permissions: If scopes are missing, you may need to logout and re-login.
214+ Scope (Access)
215+ 🎢 Membership roles in \\"Account Two\\": Contact account super admin to change your permissions.
216+ - Test role"
217+ ` ) ;
203218 } ) ;
204219
205220 it ( "should display membership error on authentication error 10000" , async ( ) => {
@@ -218,20 +233,20 @@ describe("whoami", () => {
218233 ) ;
219234 await runWrangler ( `whoami --account "account-2"` ) ;
220235 expect ( std . out ) . toMatchInlineSnapshot ( `
221- "Getting User settings...
222- 👋 You are logged in with an OAuth Token, associated with the email [email protected] . 223- ┌───────────────┬────────────┐
224- │ Account Name │ Account ID │
225- ├───────────────┼────────────┤
226- │ Account One │ account-1 │
227- ├───────────────┼────────────┤
228- │ Account Two │ account-2 │
229- ├───────────────┼────────────┤
230- │ Account Three │ account-3 │
231- └───────────────┴────────────┘
232- 🔓 Token Permissions: If scopes are missing, you may need to logout and re-login.
233- Scope (Access)
234- 🎢 Unable to get membership roles. Make sure you have permissions to read the account. Are you missing the \`User->Memberships->Read\` permission?"
235- ` ) ;
236+ "Getting User settings...
237+ 👋 You are logged in with an OAuth Token, associated with the email [email protected] . 238+ ┌───────────────┬────────────┐
239+ │ Account Name │ Account ID │
240+ ├───────────────┼────────────┤
241+ │ Account One │ account-1 │
242+ ├───────────────┼────────────┤
243+ │ Account Two │ account-2 │
244+ ├───────────────┼────────────┤
245+ │ Account Three │ account-3 │
246+ └───────────────┴────────────┘
247+ 🔓 Token Permissions: If scopes are missing, you may need to logout and re-login.
248+ Scope (Access)
249+ 🎢 Unable to get membership roles. Make sure you have permissions to read the account. Are you missing the \`User->Memberships->Read\` permission?"
250+ ` ) ;
236251 } ) ;
237252} ) ;
0 commit comments