@@ -988,3 +988,121 @@ test.serial(
988988    t . true ( gitlab . isDone ( ) ) ; 
989989  } 
990990) ; 
991+ 
992+ test . serial ( 
993+   "Throw SemanticReleaseError for group access token with null permissions (shared_with_groups scenario)" , 
994+   async  ( t )  =>  { 
995+     const  owner  =  "test_user" ; 
996+     const  repo  =  "test_repo" ; 
997+     const  env  =  {  GL_TOKEN : "group_access_token"  } ; 
998+     const  gitlab  =  authenticate ( env ) 
999+       . get ( `/projects/${ owner } ${ repo }  ) 
1000+       . reply ( 200 ,  { 
1001+         permissions : { 
1002+           project_access : null , 
1003+           group_access : null , 
1004+         } , 
1005+         shared_with_groups : [ 
1006+           { 
1007+             group_id : 123 , 
1008+             group_name : "test_group" , 
1009+             group_full_path : "test_group" , 
1010+             group_access_level : 40 , 
1011+             expires_at : null , 
1012+           } , 
1013+         ] , 
1014+       } ) 
1015+       . get ( `/projects/${ owner } ${ repo }  ) 
1016+       . reply ( 403 ) ; 
1017+ 
1018+     const  { 
1019+       errors : [ error ,  ...errors ] , 
1020+     }  =  await  t . throwsAsync ( 
1021+       verify ( 
1022+         { } , 
1023+         {  env,  options : {  repositoryUrl : `https://gitlab.com:${ owner } ${ repo }   } ,  logger : t . context . logger  } 
1024+       ) 
1025+     ) ; 
1026+ 
1027+     t . is ( errors . length ,  0 ) ; 
1028+     t . is ( error . name ,  "SemanticReleaseError" ) ; 
1029+     t . is ( error . code ,  "EGLNOPUSHPERMISSION" ) ; 
1030+     t . true ( gitlab . isDone ( ) ) ; 
1031+   } 
1032+ ) ; 
1033+ 
1034+ test . serial ( 
1035+   "Verify token and repository access with null permissions but successful permission test (group access token)" , 
1036+   async  ( t )  =>  { 
1037+     const  owner  =  "test_user" ; 
1038+     const  repo  =  "test_repo" ; 
1039+     const  env  =  {  GL_TOKEN : "group_access_token"  } ; 
1040+     const  gitlab  =  authenticate ( env ) 
1041+       . get ( `/projects/${ owner } ${ repo }  ) 
1042+       . reply ( 200 ,  { 
1043+         permissions : { 
1044+           project_access : null , 
1045+           group_access : null , 
1046+         } , 
1047+         shared_with_groups : [ 
1048+           { 
1049+             group_id : 123 , 
1050+             group_name : "test_group" , 
1051+             group_full_path : "test_group" , 
1052+             group_access_level : 40 , 
1053+             expires_at : null , 
1054+           } , 
1055+         ] , 
1056+       } ) 
1057+       . get ( `/projects/${ owner } ${ repo }  ) 
1058+       . reply ( 200 ,  [ ] ) ; 
1059+ 
1060+     await  t . notThrowsAsync ( 
1061+       verify ( 
1062+         { } , 
1063+         {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner } ${ repo }   } ,  logger : t . context . logger  } 
1064+       ) 
1065+     ) ; 
1066+     t . true ( gitlab . isDone ( ) ) ; 
1067+   } 
1068+ ) ; 
1069+ 
1070+ test . serial ( 
1071+   "Throw SemanticReleaseError for insufficient group access level even with shared_with_groups" , 
1072+   async  ( t )  =>  { 
1073+     const  owner  =  "test_user" ; 
1074+     const  repo  =  "test_repo" ; 
1075+     const  env  =  {  GL_TOKEN : "group_access_token"  } ; 
1076+     const  gitlab  =  authenticate ( env ) 
1077+       . get ( `/projects/${ owner } ${ repo }  ) 
1078+       . reply ( 200 ,  { 
1079+         permissions : { 
1080+           project_access : null , 
1081+           group_access : {  access_level : 20  } ,  // Reporter level, insufficient for push 
1082+         } , 
1083+         shared_with_groups : [ 
1084+           { 
1085+             group_id : 123 , 
1086+             group_name : "test_group" , 
1087+             group_full_path : "test_group" , 
1088+             group_access_level : 40 , 
1089+             expires_at : null , 
1090+           } , 
1091+         ] , 
1092+       } ) ; 
1093+ 
1094+     const  { 
1095+       errors : [ error ,  ...errors ] , 
1096+     }  =  await  t . throwsAsync ( 
1097+       verify ( 
1098+         { } , 
1099+         {  env,  options : {  repositoryUrl : `https://gitlab.com/${ owner } ${ repo }   } ,  logger : t . context . logger  } 
1100+       ) 
1101+     ) ; 
1102+ 
1103+     t . is ( errors . length ,  0 ) ; 
1104+     t . is ( error . name ,  "SemanticReleaseError" ) ; 
1105+     t . is ( error . code ,  "EGLNOPUSHPERMISSION" ) ; 
1106+     t . true ( gitlab . isDone ( ) ) ; 
1107+   } 
1108+ ) ; 
0 commit comments