diff --git a/test/core/thing_description_test.dart b/test/core/thing_description_test.dart index c156d7a9..20c72926 100644 --- a/test/core/thing_description_test.dart +++ b/test/core/thing_description_test.dart @@ -74,21 +74,93 @@ void main() { ); }); - test("use the correct @context entry as the default prefix value", () { - final thingDescription = { + test("reject invalid ComboSecuritySchemes", () { + final invalidThingDescription1 = { "@context": [ "https://www.w3.org/2022/wot/td/v1.1", ], "title": "Invalid TD with missing security field.", - "security": "nosec_sc", + "security": "combo_sc", "securityDefinitions": { - "nosec_sc": {"scheme": "nosec"}, + "combo_sc": {"scheme": "combo"}, }, - }.toThingDescription(); + }; expect( - thingDescription.prefixMapping.defaultPrefixValue, - "https://www.w3.org/2022/wot/td/v1.1", + invalidThingDescription1.toThingDescription, + throwsFormatException, + ); + + final invalidThingDescription2 = { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + ], + "title": "Invalid TD with missing security field.", + "security": "combo_sc", + "securityDefinitions": { + "nosec_sc1": {"scheme": "nosec"}, + "nosec_sc2": {"scheme": "nosec"}, + "combo_sc": { + "scheme": "combo", + "oneOf": [ + "nosec_sc1", + "nosec_sc2", + ], + "allOf": [ + "nosec_sc1", + "nosec_sc2", + ], + }, + }, + }; + + expect( + invalidThingDescription2.toThingDescription, + throwsFormatException, + ); + + final invalidThingDescription3 = { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + ], + "title": "Invalid TD with missing security field.", + "security": "combo_sc", + "securityDefinitions": { + "nosec_sc1": {"scheme": "nosec"}, + "combo_sc": { + "scheme": "combo", + "oneOf": [ + "nosec_sc1", + ], + }, + }, + }; + + expect( + invalidThingDescription3.toThingDescription, + throwsFormatException, + ); + + final invalidThingDescription4 = { + "@context": [ + "https://www.w3.org/2022/wot/td/v1.1", + ], + "title": "Invalid TD with missing security field.", + "security": "combo_sc", + "securityDefinitions": { + "nosec_sc1": {"scheme": "nosec"}, + "combo_sc": { + "scheme": "combo", + "allOf": [ + "nosec_sc1", + ], + }, + }, + }; + + expect( + invalidThingDescription4.toThingDescription, + throwsFormatException, ); }); });