@@ -510,7 +510,105 @@ testRule('Dok19', [
510510 ] ,
511511 } ,
512512] ) ;
513-
513+ testRule ( 'Dok21' , [
514+ {
515+ name : 'ogiltigt testfall - security saknas helt' ,
516+ document : {
517+ openapi : '3.1.0' ,
518+ info : { version : '1.0' } ,
519+ servers : [ { url : 'https://example.com/my-api/v1' } ] ,
520+ paths : {
521+ '/pets' : {
522+ get : {
523+ description : 'Retrieve all pets' ,
524+ } ,
525+ } ,
526+ } ,
527+ } ,
528+ errors : [
529+ {
530+ message : 'Krav på autentisering SKALL anges i specifikationen.' ,
531+ severity : DiagnosticSeverity . Error ,
532+ } ,
533+ ] ,
534+ } ,
535+ {
536+ name : 'giltigt testfall - security finns på rootnivå och består utav en tom array' ,
537+ document : {
538+ openapi : '3.1.0' ,
539+ info : { version : '1.0' } ,
540+ servers : [ { url : 'https://example.com/my-api/v1' } ] ,
541+ security : [ ] ,
542+ paths : {
543+ '/pets' : {
544+ get : {
545+ description : 'Retrieve all pets' ,
546+ } ,
547+ } ,
548+ } ,
549+ } ,
550+ errors : [ ] ,
551+ } ,
552+ {
553+ name : 'giltigt testfall - security finns på rootnivå och innehåller ett objekt' ,
554+ document : {
555+ openapi : '3.1.0' ,
556+ info : { version : '1.0' } ,
557+ servers : [ { url : 'https://example.com/my-api/v1' } ] ,
558+ security : [
559+ {
560+ OAuth2 : [ ] ,
561+ } ,
562+ ] ,
563+ paths : {
564+ '/pets' : {
565+ get : {
566+ description : 'Retrieve all pets' ,
567+ } ,
568+ } ,
569+ } ,
570+ } ,
571+ errors : [ ] ,
572+ } ,
573+ {
574+ name : 'giltigt testfall - security finns på operationsnivå och består utav en tom array' ,
575+ document : {
576+ openapi : '3.1.0' ,
577+ info : { version : '1.0' } ,
578+ servers : [ { url : 'https://example.com/my-api/v1' } ] ,
579+ paths : {
580+ '/pets' : {
581+ get : {
582+ description : 'Retrieve all pets' ,
583+ security : [ ] ,
584+ } ,
585+ } ,
586+ } ,
587+ } ,
588+ errors : [ ] ,
589+ } ,
590+ {
591+ name : 'giltigt testfall - security finns på operationsnivå och innehåller ett objekt' ,
592+ document : {
593+ openapi : '3.1.0' ,
594+ info : { version : '1.0' } ,
595+ servers : [ { url : 'https://example.com/my-api/v1' } ] ,
596+ paths : {
597+ '/pets' : {
598+ get : {
599+ description : 'Retrieve all pets' ,
600+ security : [
601+ {
602+ OAuth2 : [ ] ,
603+ } ,
604+ ] ,
605+ } ,
606+ } ,
607+ } ,
608+ } ,
609+ errors : [ ] ,
610+ } ,
611+ ] ) ;
514612testRule ( 'Dok01' , [
515613 {
516614 name : 'giltigt testfall' ,
0 commit comments