@@ -77,6 +77,7 @@ const repo = {
7777 name : "github.com/sourcebot-dev/sourcebot" ,
7878 displayName : "sourcebot-dev/sourcebot" ,
7979 external_codeHostType : "github" ,
80+ external_codeHostUrl : "https://github.com" ,
8081 external_id : "123" ,
8182 metadata : { } ,
8283 connections : [ ] ,
@@ -239,7 +240,7 @@ describe("repoPermissionSyncWorkload", () => {
239240 expect ( repoFindUniqueOrThrow ) . not . toHaveBeenCalled ( ) ;
240241 } ) ;
241242
242- test ( "replaces all permissions for a complete GitHub sync" , async ( ) => {
243+ test ( "uses the canonical repo issuer for a hostless GitHub Cloud sync" , async ( ) => {
243244 const githubRepo = {
244245 ...repo ,
245246 external_codeHostType : "github" ,
@@ -248,7 +249,6 @@ describe("repoPermissionSyncWorkload", () => {
248249 } ;
249250 repoFindUniqueOrThrow . mockResolvedValue ( githubRepo ) ;
250251 mocks . getAuthCredentialsForRepo . mockResolvedValue ( {
251- hostUrl : "https://github.com" ,
252252 token : "token" ,
253253 } ) ;
254254 const octokit = { } ;
@@ -292,6 +292,7 @@ describe("repoPermissionSyncWorkload", () => {
292292 const bitbucketRepo = {
293293 ...repo ,
294294 external_codeHostType : "bitbucketCloud" ,
295+ external_codeHostUrl : "https://bitbucket.org" ,
295296 external_id : "repo-uuid" ,
296297 metadata : {
297298 codeHostMetadata : {
@@ -304,7 +305,7 @@ describe("repoPermissionSyncWorkload", () => {
304305 } ;
305306 repoFindUniqueOrThrow . mockResolvedValue ( bitbucketRepo ) ;
306307 mocks . getAuthCredentialsForRepo . mockResolvedValue ( {
307- hostUrl : "https://bitbucket.org" ,
308+ hostUrl : "https://bitbucket.org/ " ,
308309 token : "token" ,
309310 connectionConfig : {
310311 user : "service-account" ,
@@ -318,6 +319,15 @@ describe("repoPermissionSyncWorkload", () => {
318319
319320 await createWorkload ( ) . process ( processContext ) ;
320321
322+ expect ( accountFindMany ) . toHaveBeenCalledWith ( {
323+ where : {
324+ providerType : "bitbucket-cloud" ,
325+ providerAccountId : {
326+ in : [ "upstream-account" ] ,
327+ } ,
328+ issuerUrl : "https://bitbucket.org" ,
329+ } ,
330+ } ) ;
321331 expect ( repoUpdate ) . toHaveBeenCalledWith ( {
322332 where : { id : 42 } ,
323333 data : {
0 commit comments