@@ -123,7 +123,7 @@ jest.mock('../src/common/typedPubsub', () => ({
123123let con : DataSource ;
124124let state : GraphQLTestingState ;
125125let client : GraphQLTestClient ;
126- let loggedUser : string = null ;
126+ let loggedUser : string | null = null ;
127127let isTeamMember = false ;
128128let isPlus = false ;
129129let roles : Roles [ ] = [ ] ;
@@ -1245,7 +1245,7 @@ describe('query post', () => {
12451245 ) ;
12461246 } ) ;
12471247
1248- it ( 'should throw not found when brief post is from other user' , async ( ) => {
1248+ it ( 'should throw when brief post is from other user' , async ( ) => {
12491249 loggedUser = '1' ;
12501250
12511251 await saveFixtures ( con , BriefPost , [
@@ -1269,6 +1269,30 @@ describe('query post', () => {
12691269 ) ;
12701270 } ) ;
12711271
1272+ it ( 'should throw for anonymous user accessing brief' , async ( ) => {
1273+ loggedUser = null ;
1274+
1275+ await saveFixtures ( con , BriefPost , [
1276+ {
1277+ id : 'pbriefanotherauthor' ,
1278+ shortId : 'pbfaa' ,
1279+ title : 'pbriefanotherauthor' ,
1280+ score : 0 ,
1281+ sourceId : BRIEFING_SOURCE ,
1282+ createdAt : new Date ( '2021-09-22T07:15:51.247Z' ) ,
1283+ private : true ,
1284+ visible : true ,
1285+ authorId : '2' ,
1286+ } ,
1287+ ] ) ;
1288+
1289+ return testQueryErrorCode (
1290+ client ,
1291+ { query : QUERY ( 'pbriefanotherauthor' ) } ,
1292+ 'FORBIDDEN' ,
1293+ ) ;
1294+ } ) ;
1295+
12721296 describe ( 'clickbaitTitleDetected' , ( ) => {
12731297 const LOCAL_QUERY = /* GraphQL */ `
12741298 query Post($id: ID!) {
0 commit comments