@@ -168,7 +168,7 @@ scenario(
168168) ;
169169
170170scenario (
171- "First-party OAuth · Google offers Calendar and Sheets but refuses Gmail scopes" ,
171+ "First-party OAuth · Google offers Gmail modify but refuses full Gmail and Drive scopes" ,
172172 { } ,
173173 Effect . scoped (
174174 Effect . gen ( function * ( ) {
@@ -184,6 +184,7 @@ scenario(
184184 expect ( google ?. origin . kind ) . toBe ( "first_party" ) ;
185185 if ( google ?. origin . kind !== "first_party" ) return ;
186186 expect ( google . origin . allowedScopes ) . toContain ( "https://www.googleapis.com/auth/calendar" ) ;
187+ expect ( google . origin . allowedScopes ) . toContain ( "https://www.googleapis.com/auth/gmail.modify" ) ;
187188 expect ( google . origin . allowedScopes ) . toContain ( "https://www.googleapis.com/auth/spreadsheets" ) ;
188189 expect ( google . origin . allowedScopes ) . not . toContain ( "https://mail.google.com/" ) ;
189190 expect ( google . origin . allowedScopes ) . not . toContain ( "https://www.googleapis.com/auth/drive" ) ;
@@ -229,19 +230,50 @@ scenario(
229230 "openid" ,
230231 "email" ,
231232 "profile" ,
232- "https://mail.google .com/" ,
233+ "https://www.googleapis .com/auth/gmail.modify " ,
233234 ] ) ,
234235 slug : gmail ,
235236 } ,
236237 } ) ;
238+ const gmailStarted = yield * client . oauth . start ( {
239+ payload : {
240+ client : OAuthClientSlug . make ( "first-party:google" ) ,
241+ clientOwner : "org" ,
242+ owner : "org" ,
243+ name : ConnectionName . make ( "gmail" ) ,
244+ integration : gmail ,
245+ template : AuthTemplateSlug . make ( "oauth" ) ,
246+ } ,
247+ } ) ;
248+ expect ( gmailStarted . status ) . toBe ( "redirect" ) ;
249+ const gmailAuthorizationUrl =
250+ gmailStarted . status === "redirect" ? gmailStarted . authorizationUrl : "" ;
251+ expect (
252+ new Set ( new URL ( gmailAuthorizationUrl ) . searchParams . get ( "scope" ) ?. split ( " " ) ?? [ ] ) ,
253+ ) . toEqual (
254+ new Set ( [ "openid" , "email" , "profile" , "https://www.googleapis.com/auth/gmail.modify" ] ) ,
255+ ) ;
256+
257+ const fullGmail = IntegrationSlug . make ( unique ( "google_gmail_full" ) ) ;
258+ yield * client . openapi . addSpec ( {
259+ payload : {
260+ ...googleShapedIntegrationSpec ( [
261+ "openid" ,
262+ "email" ,
263+ "profile" ,
264+ "https://mail.google.com/" ,
265+ ] ) ,
266+ slug : fullGmail ,
267+ } ,
268+ } ) ;
237269 const blocked = yield * client . oauth
238270 . start ( {
239271 payload : {
240272 client : OAuthClientSlug . make ( "first-party:google" ) ,
241273 clientOwner : "org" ,
242274 owner : "org" ,
243- name : ConnectionName . make ( "gmail" ) ,
244- integration : gmail ,
275+ name : ConnectionName . make ( "gmail-full " ) ,
276+ integration : fullGmail ,
245277 template : AuthTemplateSlug . make ( "oauth" ) ,
246278 } ,
247279 } )
0 commit comments