@@ -6,8 +6,8 @@ import { sql } from "drizzle-orm";
66import { createEnvKeyCredentialCipher } from "@intx/crypto" ;
77import { createDB , runMigrations , schema } from "@intx/db" ;
88import { credentialAad } from "@intx/types" ;
9- import { connectTriage , createAutomation , grantEnabledKinds } from "../github/automation.js" ;
10- import { patchCorbitsTriage , repoRecords , triageNs } from "../github/tenant-config.js" ;
9+ import { connectTriage , createAutomation } from "../github/automation.js" ;
10+ import { repoRecords , triageNs } from "../github/tenant-config.js" ;
1111import { WEBHOOK_EVENTS } from "./client.js" ;
1212import { createBitbucketIntegration } from "./integration.js" ;
1313import { HOOK_CREDENTIAL , TOKEN_CREDENTIAL } from "./records.js" ;
@@ -94,49 +94,6 @@ test("PostgreSQL: enabling a Bitbucket repository grants comment, the one enable
9494 } ) ;
9595} , 120_000 ) ;
9696
97- test ( "PostgreSQL: a Bitbucket repository named as a GitHub one, in any case, is enabled and the GitHub labels grant stays" , async ( ) => {
98- await withDatabase ( async function sameName ( db , cipher ) {
99- const integration = createBitbucketIntegration ( {
100- db, cipher, onKeyMoved : noKeyPush , async authorize ( ) { return true ; } ,
101- async stockFetch ( ) { return new Response ( null , { status : 500 } ) ; } ,
102- publicOrigin : "https://hub.test" , fetchImpl : instanceFetch ( 201 ) , lookup : lookupBitbucket ,
103- onEnabled ( ) { } , async onConnectionChanged ( ) { } , onCredentialsReplaced ( ) { } , now : ( ) => new Date ( ) , log ( ) { } ,
104- } ) ;
105- const automation = createAutomation ( { db } ) ;
106- await patchCorbitsTriage ( db , TENANT , async ( ns , tx ) => {
107- await grantEnabledKinds ( tx , TENANT , "tri/Widgets" , "github" , new Date ( ) ) ;
108- return { ...ns , repos : [ { name : "tri/Widgets" , connected : true , installationId : 1 } ] } ;
109- } ) ;
110- const res = await integration . enable ( MEMBER , "TRI" , "widgets" ) ;
111- expect ( res . status ) . toBe ( 200 ) ;
112- expect ( await automation . automaticKinds ( TENANT , "TRI/widgets" , "bitbucket-datacenter" ) ) . toEqual ( [ "comment" ] ) ;
113- expect ( await automation . automaticKinds ( TENANT , "tri/Widgets" , "github" ) ) . toContain ( "labels" ) ;
114- } ) ;
115- } , 120_000 ) ;
116-
117- test ( "PostgreSQL: enabling and disabling a Bitbucket repository returns its own row when a GitHub repository has the same name" , async ( ) => {
118- await withDatabase ( async function exactName ( db , cipher ) {
119- const integration = createBitbucketIntegration ( {
120- db, cipher, onKeyMoved : noKeyPush , async authorize ( ) { return true ; } ,
121- async stockFetch ( ) { return new Response ( null , { status : 500 } ) ; } ,
122- publicOrigin : "https://hub.test" , fetchImpl : instanceFetch ( 201 ) , lookup : lookupBitbucket ,
123- onEnabled ( ) { } , async onConnectionChanged ( ) { } , onCredentialsReplaced ( ) { } , now : ( ) => new Date ( ) , log ( ) { } ,
124- } ) ;
125- const automation = createAutomation ( { db } ) ;
126- await patchCorbitsTriage ( db , TENANT , async ( ns , tx ) => {
127- await grantEnabledKinds ( tx , TENANT , "TRI/widgets" , "github" , new Date ( ) ) ;
128- return { ...ns , repos : [ { name : "TRI/widgets" , connected : true , installationId : 1 } ] } ;
129- } ) ;
130- const enabled = await integration . enable ( MEMBER , "TRI" , "widgets" ) ;
131- expect ( enabled . status ) . toBe ( 200 ) ;
132- expect ( await enabled . json ( ) ) . toMatchObject ( { repository : { source : "bitbucket-datacenter" , enabled : true } } ) ;
133- expect ( await automation . automaticKinds ( TENANT , "TRI/widgets" , "github" ) ) . toContain ( "labels" ) ;
134- const disabled = await integration . disable ( MEMBER , "TRI" , "widgets" ) ;
135- expect ( disabled . status ) . toBe ( 200 ) ;
136- expect ( await disabled . json ( ) ) . toMatchObject ( { repository : { source : "bitbucket-datacenter" } } ) ;
137- } ) ;
138- } , 120_000 ) ;
139-
14097test ( "PostgreSQL: a hand-made webhook needs use on the hook credential, its setup stays readable while triage is on, and not once it is off" , async ( ) => {
14198 await withDatabase ( async function manualWebhook ( db , cipher ) {
14299 let hookUse = false ;
0 commit comments