@@ -177,9 +177,45 @@ test('Core: CallResponser invalid call.', async t => {
177177 'OnixJS Error: RPC Call is invalid "something.really.weird.to.call.which.is.invalid"' ,
178178 ) ;
179179} ) ;
180+ // Test CallResponser not authorized call
181+ test ( 'Core: CallResponser not authorized call.' , async t => {
182+ @Component ( { } )
183+ class MyComponent {
184+ @RPC ( )
185+ testRPC ( ) {
186+ return 'ALO WORLD' ;
187+ }
188+ @Stream ( )
189+ testSTREAM ( ) { }
190+ }
191+ @Module ( {
192+ models : [ ] ,
193+ renderers : [ ] ,
194+ services : [ ] ,
195+ components : [ MyComponent ] ,
196+ } )
197+ class MyModule { }
198+ class MyApp extends Application { }
199+ const factory : AppFactory = new AppFactory ( MyApp ) ;
200+ factory . config = { network : { disabled : true } , modules : [ MyModule ] } ;
201+ factory . notifier = new AppNotifier ( ) ;
202+ await factory . setup ( ) ;
203+ const responser : CallResponser = new CallResponser ( factory ) ;
204+ const result = await responser . process ( {
205+ uuid : Utils . uuid ( ) ,
206+ type : OperationType . ONIX_REMOTE_CALL_PROCEDURE ,
207+ message : {
208+ rpc : 'MyApp.MyModule.MyComponent.testRPC' ,
209+ request : < IRequest > { } ,
210+ } ,
211+ } ) ;
212+ t . is ( result . code , 401 ) ;
213+ } ) ;
180214// Test CallResponser valid call
181215test ( 'Core: CallResponser valid call.' , async t => {
182- @Component ( { } )
216+ @Component ( {
217+ acl : [ AllowEveryone ] ,
218+ } )
183219 class MyComponent {
184220 @RPC ( )
185221 testRPC ( ) {
@@ -250,6 +286,7 @@ test('Core: CallResponser invalid call.', async t => {
250286// Test CallResponser Hooks
251287test ( 'Core: CallResponser Hooks.' , async t => {
252288 @Component ( {
289+ acl : [ AllowEveryone ] ,
253290 lifecycle : async function ( app , metadata , method ) {
254291 const methodResult = await method ( ) ;
255292 return methodResult ;
@@ -290,9 +327,10 @@ test('Core: CallResponser Hooks.', async t => {
290327 t . is ( result . text , 'Hello Responser' ) ;
291328} ) ;
292329
293- // Test CallResponser Hooks
294- test ( 'Core: CallResponser Hooks .' , async t => {
330+ // Test CallStreamer Valid
331+ test ( 'Core: CallStreamer Valid .' , async t => {
295332 @Component ( {
333+ acl : [ AllowEveryone ] ,
296334 lifecycle : async function ( app , metadata , method ) {
297335 const methodResult = await method ( ) ;
298336 return methodResult ;
@@ -319,7 +357,7 @@ test('Core: CallResponser Hooks.', async t => {
319357 factory . notifier = new AppNotifier ( ) ;
320358 await factory . setup ( ) ;
321359 const streamer : CallStreamer = new CallStreamer ( factory ) ;
322- streamer . register (
360+ await streamer . register (
323361 {
324362 uuid : Utils . uuid ( ) ,
325363 type : OperationType . ONIX_REMOTE_CALL_PROCEDURE ,
@@ -339,6 +377,56 @@ test('Core: CallResponser Hooks.', async t => {
339377 ) ;
340378} ) ;
341379
380+ // Test CallStreamer Not Authorized
381+ test ( 'Core: CallStreamer Not Authorized.' , async t => {
382+ @Component ( {
383+ lifecycle : async function ( app , metadata , method ) {
384+ const methodResult = await method ( ) ;
385+ return methodResult ;
386+ } ,
387+ } )
388+ class MyComponent {
389+ @Stream ( )
390+ test ( stream ) {
391+ return stream ( {
392+ text : 'Hello Streamer' ,
393+ } ) ;
394+ }
395+ }
396+ @Module ( {
397+ models : [ ] ,
398+ renderers : [ ] ,
399+ services : [ ] ,
400+ components : [ MyComponent ] ,
401+ } )
402+ class MyModule { }
403+ class MyApp extends Application { }
404+ const factory : AppFactory = new AppFactory ( MyApp ) ;
405+ factory . config = { network : { disabled : true } , modules : [ MyModule ] } ;
406+ factory . notifier = new AppNotifier ( ) ;
407+ await factory . setup ( ) ;
408+ const streamer : CallStreamer = new CallStreamer ( factory ) ;
409+ await streamer . register (
410+ {
411+ uuid : Utils . uuid ( ) ,
412+ type : OperationType . ONIX_REMOTE_CALL_PROCEDURE ,
413+ message : {
414+ rpc : 'MyApp.MyModule.MyComponent.test' ,
415+ request : < IRequest > {
416+ metadata : { stream : true } ,
417+ payload : { } ,
418+ } ,
419+ } ,
420+ } ,
421+ result => {
422+ console . log ( 'SOME GOD DAMN RESULT: ' , result ) ;
423+ if ( result ) {
424+ t . is ( result . code , 401 ) ;
425+ }
426+ } ,
427+ ) ;
428+ } ) ;
429+
342430// Test CallStreamer invalid call
343431test ( 'Core: CallStreamer invalid call.' , async t => {
344432 class MyComponent { }
@@ -355,7 +443,7 @@ test('Core: CallStreamer invalid call.', async t => {
355443 factory . notifier = new AppNotifier ( ) ;
356444 await factory . setup ( ) ;
357445 const streamer : CallStreamer = new CallStreamer ( factory ) ;
358- streamer . register (
446+ await streamer . register (
359447 {
360448 uuid : Utils . uuid ( ) ,
361449 type : OperationType . ONIX_REMOTE_CALL_PROCEDURE ,
0 commit comments