@@ -156,8 +156,15 @@ describe('API V2 authz tests', () => {
156156 'deleteCloudtty' ,
157157 // Other
158158 'createTeam' ,
159+ // Git migration
160+ 'migrateGitSettings' ,
161+ // API status
162+ 'getApiStatus' ,
159163 ]
160164
165+ // Reset locked state so a prior git migration test does not bleed into subsequent tests
166+ otomiStack . locked = false
167+
161168 // Mock all methods with default return values
162169 v2Methods . forEach ( ( method ) => {
163170 if ( typeof ( otomiStack as any ) [ method ] === 'function' ) {
@@ -1109,6 +1116,66 @@ describe('API V2 authz tests', () => {
11091116 } )
11101117 } )
11111118
1119+ describe ( 'V2 Git Migration Endpoint' , ( ) => {
1120+ const gitBody = {
1121+ repoUrl : 'https://new.example.com/repo.git' ,
1122+ username : 'user' ,
1123+ password : 'pass' ,
1124+ email : 'admin@example.com' ,
1125+ branch : 'main' ,
1126+ }
1127+
1128+ describe ( 'Platform Admin' , ( ) => {
1129+ test ( 'platform admin can migrate git' , async ( ) => {
1130+ await agent . put ( '/v2/git' ) . send ( gitBody ) . set ( 'Authorization' , `Bearer ${ platformAdminToken } ` ) . expect ( 200 )
1131+ } )
1132+ } )
1133+
1134+ describe ( 'Team Admin' , ( ) => {
1135+ test ( 'team admin cannot migrate git' , async ( ) => {
1136+ await agent . put ( '/v2/git' ) . send ( gitBody ) . set ( 'Authorization' , `Bearer ${ teamAdminToken } ` ) . expect ( 403 )
1137+ } )
1138+ } )
1139+
1140+ describe ( 'Team Member' , ( ) => {
1141+ test ( 'team member cannot migrate git' , async ( ) => {
1142+ await agent . put ( '/v2/git' ) . send ( gitBody ) . set ( 'Authorization' , `Bearer ${ teamMemberToken } ` ) . expect ( 403 )
1143+ } )
1144+ } )
1145+
1146+ describe ( 'Unauthenticated' , ( ) => {
1147+ test ( 'anonymous user cannot migrate git' , async ( ) => {
1148+ await agent . put ( '/v2/git' ) . send ( gitBody ) . expect ( 401 )
1149+ } )
1150+ } )
1151+ } )
1152+
1153+ describe ( 'V2 API Status Endpoint' , ( ) => {
1154+ describe ( 'Platform Admin' , ( ) => {
1155+ test ( 'platform admin can get api status' , async ( ) => {
1156+ await agent . get ( '/v2/status' ) . set ( 'Authorization' , `Bearer ${ platformAdminToken } ` ) . expect ( 200 )
1157+ } )
1158+ } )
1159+
1160+ describe ( 'Team Admin' , ( ) => {
1161+ test ( 'team admin can get api status' , async ( ) => {
1162+ await agent . get ( '/v2/status' ) . set ( 'Authorization' , `Bearer ${ teamAdminToken } ` ) . expect ( 200 )
1163+ } )
1164+ } )
1165+
1166+ describe ( 'Team Member' , ( ) => {
1167+ test ( 'team member can get api status' , async ( ) => {
1168+ await agent . get ( '/v2/status' ) . set ( 'Authorization' , `Bearer ${ teamMemberToken } ` ) . expect ( 200 )
1169+ } )
1170+ } )
1171+
1172+ describe ( 'Unauthenticated' , ( ) => {
1173+ test ( 'anonymous user cannot get api status' , async ( ) => {
1174+ await agent . get ( '/v2/status' ) . expect ( 401 )
1175+ } )
1176+ } )
1177+ } )
1178+
11121179 test ( 'team member cannot create its own services when disabled' , async ( ) => {
11131180 jest . spyOn ( otomiStack , 'createService' ) . mockResolvedValue ( { } as any )
11141181 await agent
0 commit comments