@@ -935,29 +935,128 @@ describe('index', function () {
935935 ] ;
936936
937937 const pull = {
938- url : `${ API_URL_V2 } /repositories/repoIdPrefix` ,
938+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
939+ + '?q=uuid%3D%22repoIdSuffix%22' ,
939940 method : 'GET' ,
940941 json : true ,
941942 auth : {
942943 bearer : token
943944 }
944945 } ;
945- const push = {
946- url : `${ API_URL_V2 } /repositories/repoIdPrefix?role=contributor` ,
947- method : 'GET' ,
948- json : true ,
949- auth : {
950- bearer : token
946+ const pulls = [
947+ {
948+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
949+ + '?q=uuid%3D%22repoIdSuffix%22' ,
950+ method : 'GET' ,
951+ json : true ,
952+ auth : {
953+ bearer : token
954+ }
955+ } ,
956+ {
957+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
958+ + '?q=uuid%3D%22repoIdSuffix1%22' ,
959+ method : 'GET' ,
960+ json : true ,
961+ auth : {
962+ bearer : token
963+ }
964+ } ,
965+ {
966+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
967+ + '?q=uuid%3D%22repoIdSuffix2%22' ,
968+ method : 'GET' ,
969+ json : true ,
970+ auth : {
971+ bearer : token
972+ }
973+ } ,
974+ {
975+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
976+ + '?q=uuid%3D%22repoIdSuffix3%22' ,
977+ method : 'GET' ,
978+ json : true ,
979+ auth : {
980+ bearer : token
981+ }
951982 }
952- } ;
953- const admin = {
954- url : `${ API_URL_V2 } /repositories/repoIdPrefix?role=admin` ,
955- method : 'GET' ,
956- json : true ,
957- auth : {
958- bearer : token
983+ ] ;
984+ const pushes = [
985+ {
986+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
987+ + '?q=uuid%3D%22repoIdSuffix%22&role=contributor' ,
988+ method : 'GET' ,
989+ json : true ,
990+ auth : {
991+ bearer : token
992+ }
993+ } ,
994+ {
995+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
996+ + '?q=uuid%3D%22repoIdSuffix1%22&role=contributor' ,
997+ method : 'GET' ,
998+ json : true ,
999+ auth : {
1000+ bearer : token
1001+ }
1002+ } ,
1003+ {
1004+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1005+ + '?q=uuid%3D%22repoIdSuffix2%22&role=contributor' ,
1006+ method : 'GET' ,
1007+ json : true ,
1008+ auth : {
1009+ bearer : token
1010+ }
1011+ } ,
1012+ {
1013+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1014+ + '?q=uuid%3D%22repoIdSuffix3%22&role=contributor' ,
1015+ method : 'GET' ,
1016+ json : true ,
1017+ auth : {
1018+ bearer : token
1019+ }
9591020 }
960- } ;
1021+ ] ;
1022+ const admins = [
1023+ {
1024+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1025+ + '?q=uuid%3D%22repoIdSuffix%22&role=admin' ,
1026+ method : 'GET' ,
1027+ json : true ,
1028+ auth : {
1029+ bearer : token
1030+ }
1031+ } ,
1032+ {
1033+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1034+ + '?q=uuid%3D%22repoIdSuffix1%22&role=admin' ,
1035+ method : 'GET' ,
1036+ json : true ,
1037+ auth : {
1038+ bearer : token
1039+ }
1040+ } ,
1041+ {
1042+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1043+ + '?q=uuid%3D%22repoIdSuffix2%22&role=admin' ,
1044+ method : 'GET' ,
1045+ json : true ,
1046+ auth : {
1047+ bearer : token
1048+ }
1049+ } ,
1050+ {
1051+ url : `${ API_URL_V2 } /repositories/repoIdPrefix`
1052+ + '?q=uuid%3D%22repoIdSuffix3%22&role=admin' ,
1053+ method : 'GET' ,
1054+ json : true ,
1055+ auth : {
1056+ bearer : token
1057+ }
1058+ }
1059+ ] ;
9611060
9621061 const repoResponse = {
9631062 statusCode : 200 ,
@@ -968,25 +1067,50 @@ describe('index', function () {
9681067 body : 'Not found'
9691068 } ;
9701069
971- const readResponse = {
972- statusCode : 200 ,
973- body : {
974- values : [
975- { uuid : 'repoIdSuffix1' } ,
976- { uuid : 'repoIdSuffix2' } ,
977- { uuid : 'repoIdSuffix3' }
978- ]
1070+ const readResponses = [
1071+ {
1072+ statusCode : 200 ,
1073+ body : {
1074+ values : [
1075+ { uuid : 'repoIdSuffix1' }
1076+ ]
1077+ }
1078+ } ,
1079+ {
1080+ statusCode : 200 ,
1081+ body : {
1082+ values : [
1083+ { uuid : 'repoIdSuffix2' }
1084+ ]
1085+ }
1086+ } ,
1087+ {
1088+ statusCode : 200 ,
1089+ body : {
1090+ values : [
1091+ { uuid : 'repoIdSuffix3' }
1092+ ]
1093+ }
9791094 }
980- } ;
981- const writeResponse = {
982- statusCode : 200 ,
983- body : {
984- values : [
985- { uuid : 'repoIdSuffix1' } ,
986- { uuid : 'repoIdSuffix2' }
987- ]
1095+ ] ;
1096+ const writeResponses = [
1097+ {
1098+ statusCode : 200 ,
1099+ body : {
1100+ values : [
1101+ { uuid : 'repoIdSuffix1' }
1102+ ]
1103+ }
1104+ } ,
1105+ {
1106+ statusCode : 200 ,
1107+ body : {
1108+ values : [
1109+ { uuid : 'repoIdSuffix2' }
1110+ ]
1111+ }
9881112 }
989- } ;
1113+ ] ;
9901114 const adminResponse = {
9911115 statusCode : 200 ,
9921116 body : {
@@ -1004,9 +1128,32 @@ describe('index', function () {
10041128 requestMock . withArgs ( repos [ 4 ] ) . yieldsAsync ( null ,
10051129 repoNotFoundResponse , repoNotFoundResponse . body ) ;
10061130
1007- requestMock . withArgs ( pull ) . yieldsAsync ( null , readResponse , readResponse . body ) ;
1008- requestMock . withArgs ( push ) . yieldsAsync ( null , writeResponse , writeResponse . body ) ;
1009- requestMock . withArgs ( admin ) . yieldsAsync ( null , adminResponse , adminResponse . body ) ;
1131+ requestMock . withArgs ( pulls [ 0 ] )
1132+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
1133+ requestMock . withArgs ( pulls [ 1 ] )
1134+ . yieldsAsync ( null , readResponses [ 0 ] , readResponses [ 0 ] . body ) ;
1135+ requestMock . withArgs ( pulls [ 2 ] )
1136+ . yieldsAsync ( null , readResponses [ 1 ] , readResponses [ 1 ] . body ) ;
1137+ requestMock . withArgs ( pulls [ 3 ] )
1138+ . yieldsAsync ( null , readResponses [ 2 ] , readResponses [ 2 ] . body ) ;
1139+
1140+ requestMock . withArgs ( pushes [ 0 ] )
1141+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
1142+ requestMock . withArgs ( pushes [ 1 ] )
1143+ . yieldsAsync ( null , writeResponses [ 0 ] , writeResponses [ 0 ] . body ) ;
1144+ requestMock . withArgs ( pushes [ 2 ] )
1145+ . yieldsAsync ( null , writeResponses [ 1 ] , writeResponses [ 1 ] . body ) ;
1146+ requestMock . withArgs ( pushes [ 3 ] )
1147+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
1148+
1149+ requestMock . withArgs ( admins [ 0 ] )
1150+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
1151+ requestMock . withArgs ( admins [ 1 ] )
1152+ . yieldsAsync ( null , adminResponse , adminResponse . body ) ;
1153+ requestMock . withArgs ( admins [ 2 ] )
1154+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
1155+ requestMock . withArgs ( admins [ 3 ] )
1156+ . yieldsAsync ( null , repoResponse , repoResponse . body ) ;
10101157 } ) ;
10111158
10121159 it ( 'get correct admin permissions' , ( ) => {
@@ -1018,9 +1165,9 @@ describe('index', function () {
10181165 } ) . then ( ( permissions ) => {
10191166 assert . callCount ( requestMock , 4 ) ;
10201167 assert . calledWith ( requestMock , repos [ 1 ] ) ;
1021- assert . calledWith ( requestMock , pull ) ;
1022- assert . calledWith ( requestMock , push ) ;
1023- assert . calledWith ( requestMock , admin ) ;
1168+ assert . calledWith ( requestMock , pulls [ 1 ] ) ;
1169+ assert . calledWith ( requestMock , pushes [ 1 ] ) ;
1170+ assert . calledWith ( requestMock , admins [ 1 ] ) ;
10241171 assert . deepEqual ( permissions , {
10251172 admin : true ,
10261173 push : true ,
@@ -1038,9 +1185,9 @@ describe('index', function () {
10381185 } ) . then ( ( permissions ) => {
10391186 assert . callCount ( requestMock , 4 ) ;
10401187 assert . calledWith ( requestMock , repos [ 2 ] ) ;
1041- assert . calledWith ( requestMock , pull ) ;
1042- assert . calledWith ( requestMock , push ) ;
1043- assert . calledWith ( requestMock , admin ) ;
1188+ assert . calledWith ( requestMock , pulls [ 2 ] ) ;
1189+ assert . calledWith ( requestMock , pushes [ 2 ] ) ;
1190+ assert . calledWith ( requestMock , admins [ 2 ] ) ;
10441191 assert . deepEqual ( permissions , {
10451192 admin : false ,
10461193 push : true ,
@@ -1058,9 +1205,9 @@ describe('index', function () {
10581205 } ) . then ( ( permissions ) => {
10591206 assert . callCount ( requestMock , 4 ) ;
10601207 assert . calledWith ( requestMock , repos [ 3 ] ) ;
1061- assert . calledWith ( requestMock , pull ) ;
1062- assert . calledWith ( requestMock , push ) ;
1063- assert . calledWith ( requestMock , admin ) ;
1208+ assert . calledWith ( requestMock , pulls [ 3 ] ) ;
1209+ assert . calledWith ( requestMock , pushes [ 3 ] ) ;
1210+ assert . calledWith ( requestMock , admins [ 3 ] ) ;
10641211 assert . deepEqual ( permissions , {
10651212 admin : false ,
10661213 push : false ,
0 commit comments