Skip to content

Commit

Permalink
fixup! feat!: improve deserialization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 2, 2024
1 parent e709e52 commit 65373b0
Showing 1 changed file with 79 additions and 7 deletions.
86 changes: 79 additions & 7 deletions test/core/thing_description_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
});
});
Expand Down

0 comments on commit 65373b0

Please sign in to comment.