2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								'use strict' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  async  =  require ( 'async' ) ;  
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:28:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  assert  =  require ( 'assert' ) ;  
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  nconf  =  require ( 'nconf' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  request  =  require ( '../src/request' ) ;  
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  db  =  require ( './mocks/databasemock' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  categories  =  require ( '../src/categories' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  topics  =  require ( '../src/topics' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  user  =  require ( '../src/user' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  groups  =  require ( '../src/groups' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  helpers  =  require ( './helpers' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  meta  =  require ( '../src/meta' ) ;  
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Admin Controllers' ,  ( )  =>  {  
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									let  tid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									let  cid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									let  pid ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									let  regularPid ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									let  adminUid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									let  regularUid ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									let  regular2Uid ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									let  moderatorUid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									let  jar ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									before ( ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										async . series ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											category :  function  ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												categories . create ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													name :  'Test Category' , 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-17 19:31:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													description :  'Test category created by testing script' , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												} ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 13:02:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											adminUid :  function  ( next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-18 12:30:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												user . create ( {  username :  'admin' ,  password :  'barbar'  } ,  next ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 13:02:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											regularUid :  function  ( next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												user . create ( {  username :  'regular' ,  password :  'regularpwd'  } ,  next ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-17 19:31:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											regular2Uid :  function  ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												user . create ( {  username :  'regular2'  } ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											moderatorUid :  function  ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												user . create ( {  username :  'moderator' ,  password :  'modmod'  } ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ,  async  ( err ,  results )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  done ( err ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 13:02:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											adminUid  =  results . adminUid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											regularUid  =  results . regularUid ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											regular2Uid  =  results . regular2Uid ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											moderatorUid  =  results . moderatorUid ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											cid  =  results . category . cid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  adminPost  =  await  topics . post ( {  uid :  adminUid ,  title :  'test topic title' ,  content :  'test topic content' ,  cid :  results . category . cid  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . ifError ( err ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											tid  =  adminPost . topicData . tid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											pid  =  adminPost . postData . pid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  regularPost  =  await  topics . post ( {  uid :  regular2Uid ,  title :  'regular user\'s test topic title' ,  content :  'test topic content' ,  cid :  results . category . cid  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											regularPid  =  regularPost . postData . pid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 16:07:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should 403 if user is not admin' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( {  jar  }  =  await  helpers . loginUser ( 'admin' ,  'barbar' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 16:07:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											jar :  jar , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 16:07:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 16:07:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load admin dashboard' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										await  groups . join ( 'administrators' ,  adminUid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-02 14:55:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  today  =  new  Date ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  end  =  ` ${ today . getFullYear ( ) } - ${ String ( today . getMonth ( )  +  1 ) . padStart ( 2 ,  '0' ) } - ${ String ( today . getDate ( ) ) . padStart ( 2 ,  '0' ) } ` ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										today . setDate ( today . getDate ( )  -  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  start  =  ` ${ today . getFullYear ( ) } - ${ String ( today . getMonth ( )  +  1 ) . padStart ( 2 ,  '0' ) } - ${ String ( today . getDate ( ) ) . padStart ( 2 ,  '0' ) } ` ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  dashboards  =  [ 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-02 14:55:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											'/admin' ,  '/admin/dashboard/logins' ,  '/admin/dashboard/users' ,  '/admin/dashboard/topics' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											'/admin/dashboard/searches' ,  ` /admin/dashboard/searches?start= ${ start } &end= ${ end } ` , 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										await  async . each ( dashboards ,  async  ( url )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } ${ url } ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . equal ( response . statusCode ,  200 ,  url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 00:13:54 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load admin analytics' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/analytics?units=hours ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . query ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . result ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load groups page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/groups ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load groups detail page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/groups/administrators ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load global privileges page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/privileges ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-26 11:13:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load admin privileges page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/privileges/admin ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-28 20:18:36 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load privileges page for category 1' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/privileges/1 ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 23:28:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load manage digests' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/digest ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-26 11:13:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load manage uploads' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/manage/uploads ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-26 11:13:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load general settings page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 19:16:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/settings/general ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load email settings page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/settings/email ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load user settings page' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin/settings/user ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 15:16:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load info page for a user' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/user/regular/info ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . history ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( Array . isArray ( body . history . flags ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( Array . isArray ( body . history . bans ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( Array . isArray ( body . sessions ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 13:02:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should 404 for edit/email page if user does not exist' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/user/doesnotexist/edit/email ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-24 11:02:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/settings/homepage' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/settings/general ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . routes ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 14:34:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/database' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/database ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( nconf . get ( 'redis' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . redis ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  if  ( nconf . get ( 'mongo' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . mongo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  if  ( nconf . get ( 'postgres' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . postgres ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 14:34:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/extend/plugins' ,  async  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-28 14:40:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										this . timeout ( 50000 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/extend/plugins ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . hasOwnProperty ( 'installed' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . hasOwnProperty ( 'upgradeCount' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . hasOwnProperty ( 'download' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . hasOwnProperty ( 'incompatible' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-01 14:34:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/users' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/users ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . users . length  >  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 13:14:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/users?filters=banned' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/users?filters=banned ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . users . length ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 14:02:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/users?filters=banned&filters=verified' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/users?filters=banned&filters=verified ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . users . length ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/users?query=admin' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/users?query=admin ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . users [ 0 ] . username ,  'admin' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 13:14:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return empty results if query is too short' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/users?query=a ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . users . length ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 13:26:23 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 13:14:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/registration' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/registration ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should 404 if users is not privileged' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/registration-queue ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-29 13:11:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /api/registration-queue' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/registration-queue ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-29 13:11:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/admins-mods' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/admins-mods ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-05 14:44:18 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/users/csv' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 16:07:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  socketAdmin  =  require ( '../src/socket.io/admin' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										socketAdmin . user . exportUsersCSV ( {  uid :  adminUid  } ,  { } ,  ( err )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . ifError ( err ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											setTimeout ( async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/users/csv ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 16:07:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													jar :  jar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													headers :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-03 23:59:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														referer :  ` ${ nconf . get ( 'url' ) } /admin/manage/users ` , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 16:07:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 16:07:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ,  2000 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return 403 if no referer' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/groups/administrators/csv ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( body ,  '[[error:invalid-origin]]' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return 403 if referer is not /api/admin/groups/administrators/csv' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/groups/administrators/csv ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											jar :  jar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											headers :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												referer :  '/topic/1/test' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( body ,  '[[error:invalid-origin]]' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /api/admin/groups/administrators/csv' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/groups/administrators/csv ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											jar :  jar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											headers :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-03 23:59:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												referer :  ` ${ nconf . get ( 'url' ) } /admin/manage/groups ` , 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-10 13:12:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/hooks' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/hooks ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-22 22:23:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/cache' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/cache ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /api/admin/advanced/cache/dump and 404 with no query param' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/cache/dump ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 15:20:44 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /api/admin/advanced/cache/dump' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/cache/dump?name=post ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 15:20:44 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/errors' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/errors ` ,  {  jar :  jar ,  json :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/errors/export' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										await  meta . errors . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/errors/export ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body ,  '' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/logs' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  fs  =  require ( 'fs' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										await  fs . promises . appendFile ( meta . logs . path ,  'dummy log' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/logs ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/settings/navigation' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  navigation  =  require ( '../src/navigation/admin' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  data  =  require ( '../install/data/navigation.json' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										await  navigation . save ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-24 13:25:47 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/settings/navigation ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . available ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . enabled ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/development/info' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/development/info ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/development/logger' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/development/logger ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/advanced/events' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/advanced/events ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/categories' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/categories ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/categories/1' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/categories/1 ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 18:18:02 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/catgories?cid=<cid>' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  cid :  rootCid  }  =  await  categories . create ( {  name :  'parent category'  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  cid :  childCid  }  =  await  categories . create ( {  name :  'child category' ,  parentCid :  rootCid  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  helpers . request ( 'get' ,  ` /api/admin/manage/categories?cid= ${ rootCid } ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 18:18:02 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											jar :  jar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											json :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . strictEqual ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 18:18:02 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . strictEqual ( body . categoriesTree [ 0 ] . cid ,  rootCid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . categoriesTree [ 0 ] . children [ 0 ] . cid ,  childCid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . breadcrumbs [ 0 ] . text ,  '[[admin/manage/categories:top-level]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( body . breadcrumbs [ 1 ] . text ,  'parent category' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/categories/1/analytics' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/categories/1/analytics ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/extend/rewards' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/extend/rewards ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/extend/widgets' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/extend/widgets ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/manage/tags' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/manage/tags ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 12:59:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( '/post-queue should 404 for regular user' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/post-queue ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 12:59:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /post-queue' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/post-queue ` ,  {  jar :  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( '/ip-blacklist should 404 for regular user' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/ip-blacklist ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-10 16:27:44 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /ip-blacklist' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/ip-blacklist ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-10 16:27:44 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/appearance/themes' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/appearance/themes ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 19:16:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/appearance/skins' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/appearance/skins ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /admin/appearance/customise' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/appearance/customise ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should load /recent in maintenance mode' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 14:37:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										meta . config . maintenanceMode  =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/recent ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										meta . config . maintenanceMode  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-22 14:37:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-07 14:45:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( 'mods page' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										let  moderatorJar ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										let  regularJar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										before ( async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											moderatorJar  =  ( await  helpers . loginUser ( 'moderator' ,  'modmod' ) ) . jar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											regularJar  =  ( await  helpers . loginUser ( 'regular' ,  'regularpwd' ) ) . jar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											await  groups . join ( ` cid: ${ cid } :privileges:moderate ` ,  moderatorUid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should error with no privileges' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/flags ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . deepStrictEqual ( body ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												status :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													code :  'not-authorised' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													message :  'A valid login session was not found. Please log in and try again.' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												response :  { } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should load flags page data' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/flags ` ,  {  jar :  moderatorJar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . flags ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . filters ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . equal ( body . filters . cid . indexOf ( cid ) ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should return a 404 if flag does not exist' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  response  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/flags/123123123 ` ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 17:06:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												jar :  moderatorJar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												headers :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													Accept :  'text/html, application/json' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( response . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should error when you attempt to flag a privileged user\'s post' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  {  response ,  body  }  =  await  helpers . request ( 'post' ,  '/api/v3/flags' ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												jar :  regularJar , 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												body :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													id :  pid , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													type :  'post' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													reason :  'spam' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( response . statusCode ,  400 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( body . status . code ,  'bad-request' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( body . status . message ,  'You are not allowed to flag the profiles or content of privileged users (moderators/global moderators/admins)' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 15:45:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should error with not enough reputation to flag' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  oldValue  =  meta . config [ 'min:rep:flag' ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-12 17:29:47 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											meta . config [ 'min:rep:flag' ]  =  1000 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  {  response ,  body  }  =  await  helpers . request ( 'post' ,  '/api/v3/flags' ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												jar :  regularJar , 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												body :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													id :  regularPid , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													type :  'post' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													reason :  'spam' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( response . statusCode ,  400 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( body . status . code ,  'bad-request' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 13:46:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( body . status . message ,  'You need 1000 reputation to flag this post' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											meta . config [ 'min:rep:flag' ]  =  oldValue ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should return flag details' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  oldValue  =  meta . config [ 'min:rep:flag' ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-12 17:29:47 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											meta . config [ 'min:rep:flag' ]  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											await  helpers . request ( 'post' ,  '/api/v3/flags' ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												jar :  regularJar , 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												body :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													id :  regularPid , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													type :  'post' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													reason :  'spam' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											meta . config [ 'min:rep:flag' ]  =  oldValue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  flagsResult  =  await  helpers . request ( 'get' ,  ` /api/flags ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												json :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												jar :  moderatorJar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( flagsResult . body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( Array . isArray ( flagsResult . body . flags ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  flagId  }  =  flagsResult . body . flags [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  {  body  }  =  await  helpers . request ( 'get' ,  ` /api/flags/ ${ flagId } ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												jar :  moderatorJar , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( body . reports ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( Array . isArray ( body . reports ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( body . reports [ 0 ] . reporter . username ,  'regular' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-09 14:31:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-26 10:32:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should escape special characters in config' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  plugins  =  require ( '../src/plugins' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-26 10:32:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										function  onConfigGet ( config ,  callback )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											config . someValue  =  '"foo"' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											config . otherValue  =  "'123'" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											config . script  =  '</script>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											callback ( null ,  config ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-27 17:36:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										plugins . hooks . register ( 'somePlugin' ,  {  hook :  'filter:config.get' ,  method :  onConfigGet  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  {  response ,  body  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /admin ` ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( response . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . includes ( '"someValue":"\\\\"foo\\\\""' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . includes ( '"otherValue":"\\\'123\\\'"' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body . includes ( '"script":"<\\/script>"' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  response :  res2 ,  body :  body2  }  =  await  request . get ( nconf . get ( 'url' ) ,  {  jar  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . equal ( res2 . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body2 . includes ( '"someValue":"\\\\"foo\\\\""' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body2 . includes ( '"otherValue":"\\\'123\\\'"' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( body2 . includes ( '"script":"<\\/script>"' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										plugins . hooks . unregister ( 'somePlugin' ,  'filter:config.get' ,  onConfigGet ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-26 10:32:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:28:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( 'admin page privileges' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										let  uid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  privileges  =  require ( '../src/privileges' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  requestOpts  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 19:23:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										before ( async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											uid  =  await  user . create ( {  username :  'regularjoe' ,  password :  'barbar'  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											requestOpts . jar  =  ( await  helpers . loginUser ( 'regularjoe' ,  'barbar' ) ) . jar ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:28:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										describe ( 'routeMap parsing' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											it ( 'should allow normal user access to admin pages' ,  async  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												this . timeout ( 50000 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-07 10:08:16 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												const  uploadRoutes  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'category/uploadpicture' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadfavicon' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadTouchIcon' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadMaskableIcon' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadlogo' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadOgImage' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'uploadDefaultAvatar' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												const  adminRoutes  =  Object . keys ( privileges . admin . routeMap ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													. filter ( route  =>  ! uploadRoutes . includes ( route ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												for  ( const  route  of  adminRoutes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													/* eslint-disable no-await-in-loop */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													let  {  response :  res  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/ ${ route } ` ,  requestOpts ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . give ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													( {  response :  res  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/ ${ route } ` ,  requestOpts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-07 10:08:16 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												for  ( const  route  of  adminRoutes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													/* eslint-disable no-await-in-loop */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													let  {  response :  res  }  =  await  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin ` ,  requestOpts ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . give ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													( {  response :  res  }  =  await  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin ` ,  requestOpts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  200 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routeMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										describe ( 'routePrefixMap parsing' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											it ( 'should allow normal user access to admin pages' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												for  ( const  route  of  Object . keys ( privileges . admin . routePrefixMap ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													/* eslint-disable no-await-in-loop */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routePrefixMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													let  {  response :  res  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/ ${ route } foobar/derp ` ,  requestOpts ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . give ( [ privileges . admin . routePrefixMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 12:08:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													( {  response :  res  }  =  await  request . get ( ` ${ nconf . get ( 'url' ) } /api/admin/ ${ route } foobar/derp ` ,  requestOpts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 13:53:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													assert . strictEqual ( res . statusCode ,  404 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													await  privileges . admin . rescind ( [ privileges . admin . routePrefixMap [ route ] ] ,  uid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:28:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-28 20:18:36 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should list all admin privileges' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  privs  =  await  privileges . admin . getPrivilegeList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . deepStrictEqual ( privs ,  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:dashboard' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:categories' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:privileges' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:admins-mods' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:users' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:groups' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:tags' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:settings' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:dashboard' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:categories' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:privileges' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:admins-mods' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:users' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:groups' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:tags' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:settings' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should list user admin privileges' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  privs  =  await  privileges . admin . userPrivileges ( adminUid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . deepStrictEqual ( privs ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:dashboard' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:categories' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:privileges' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:admins-mods' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:users' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:groups' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:tags' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'admin:settings' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should check if group has admin group privilege' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											await  groups . create ( {  name :  'some-special-group' ,  private :  1 ,  hidden :  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											await  privileges . admin . give ( [ 'groups:admin:users' ,  'groups:admin:groups' ] ,  'some-special-group' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  can  =  await  privileges . admin . canGroup ( 'admin:users' ,  'some-special-group' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( can ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  privs  =  await  privileges . admin . groupPrivileges ( 'some-special-group' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . deepStrictEqual ( privs ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:dashboard' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:categories' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:privileges' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:admins-mods' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:users' :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:groups' :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:tags' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'groups:admin:settings' :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-28 20:47:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should not have admin:privileges' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  res  =  await  privileges . admin . list ( regularUid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( res . keys . users . includes ( 'admin:privileges' ) ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( res . keys . groups . includes ( 'admin:privileges' ) ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-24 21:28:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-31 13:52:26 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ) ;