@@ -805,4 +805,72 @@ class WoTClientTest {
805805 // eslint-disable-next-line no-unused-expressions
806806 expect ( WoTClientTest . servient . hasClientFor ( tcf2 . scheme ) ) . to . be . not . true ;
807807 }
808+
809+ @test "ensure combo security " ( done : Mocha . Done ) {
810+ try {
811+ const ct = new ConsumedThing ( WoTClientTest . servient ) ;
812+ ct . securityDefinitions = {
813+ basic_sc : {
814+ scheme : "basic" ,
815+ } ,
816+ opcua_secure_channel_sc : {
817+ scheme : "opcua-channel-security" ,
818+ } ,
819+ opcua_authetication_sc : {
820+ scheme : "opcua-authentication" ,
821+ } ,
822+ combo_sc : {
823+ scheme : "combo" ,
824+ allOf : [ "opcua_secure_channel_sc" , "opcua_authetication_sc" ] ,
825+ } ,
826+ } ;
827+ ct . security = [ "combo_sc" ] ;
828+ const pc = new TestProtocolClient ( ) ;
829+ const form : Form = {
830+ href : "https://example.com/" ,
831+ // security: ["apikey_sc"],
832+ } ;
833+ ct . ensureClientSecurity ( pc , form ) ;
834+ expect ( pc . securitySchemes . length ) . equals ( 2 ) ;
835+ expect ( pc . securitySchemes [ 0 ] . scheme ) . equals ( "opcua-channel-security" ) ;
836+ expect ( pc . securitySchemes [ 1 ] . scheme ) . equals ( "opcua-authentication" ) ;
837+ done ( ) ;
838+ } catch ( err ) {
839+ done ( err ) ;
840+ }
841+ }
842+
843+ @test "ensure combo security in form" ( done : Mocha . Done ) {
844+ try {
845+ const ct = new ConsumedThing ( WoTClientTest . servient ) ;
846+ ct . securityDefinitions = {
847+ basic_sc : {
848+ scheme : "basic" ,
849+ } ,
850+ opcua_secure_channel_sc : {
851+ scheme : "opcua-channel-security" ,
852+ } ,
853+ opcua_authetication_sc : {
854+ scheme : "opcua-authentication" ,
855+ } ,
856+ combo_sc : {
857+ scheme : "combo" ,
858+ allOf : [ "opcua_secure_channel_sc" , "opcua_authetication_sc" ] ,
859+ } ,
860+ } ;
861+ ct . security = "basic" ;
862+ const pc = new TestProtocolClient ( ) ;
863+ const form : Form = {
864+ href : "https://example.com/" ,
865+ security : [ "combo_sc" ] ,
866+ } ;
867+ ct . ensureClientSecurity ( pc , form ) ;
868+ expect ( pc . securitySchemes . length ) . equals ( 2 ) ;
869+ expect ( pc . securitySchemes [ 0 ] . scheme ) . equals ( "opcua-channel-security" ) ;
870+ expect ( pc . securitySchemes [ 1 ] . scheme ) . equals ( "opcua-authentication" ) ;
871+ done ( ) ;
872+ } catch ( err ) {
873+ done ( err ) ;
874+ }
875+ }
808876}
0 commit comments