Skip to content

Commit

Permalink
Merge pull request #352 from thingweb/ege-cr-assertion-fixes
Browse files Browse the repository at this point in the history
Further assertion checks
  • Loading branch information
egekorkan authored Oct 7, 2022
2 parents f4b7c71 + 51f14c0 commit 664bb1d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
9 changes: 2 additions & 7 deletions packages/assertions/assertionTests-tm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ const mergeIdenticalResults = require("./util").mergeIdenticalResults


// Imports from playground core
// const checkUniqueness = require('@thing-description-playground/core').propUniqueness
// const checkMultiLangConsistency = require("@thing-description-playground/core").multiLangConsistency
// const checkSecurity = require("@thing-description-playground/core").security
// const checkLinksRelTypeCount = require("@thing-description-playground/core").checkLinksRelTypeCount
const checkTmOptionalPointer = require("@thing-description-playground/core").checkTmOptionalPointer
const tmSchema = require("@thing-description-playground/core/tm-schema.json")
const tmPlaceholderSchema = require("./assertions-tm/tm-placeholder.json")
const tmRefSchema = require("./assertions-tm/tm-tmRef1.json")
Expand Down Expand Up @@ -93,9 +90,7 @@ module.exports = validateTM
}

// additional checks
// results.push(...checkSecurity(tmJson))
// results.push(...checkMultiLangConsistency(tmJson))
// results.push(...checkLinksRelTypeCount(tmJson))
results.push(...checkTmOptionalPointer(tmJson))

// Iterating through assertions
for (let index = 0; index < assertions.length; index++) {
Expand Down
1 change: 0 additions & 1 deletion packages/assertions/assertions-tm/manual.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"tm-overwrite-types","null","not testable with Assertion Tester","Definitions SHOULD NOT be overwritten in such a way that possible instance values are no longer valid compared to the origin extended definitions."
"tm-placeholder-replacement","null","not testable with Assertion Tester","The placeholder labeling MUST be substituted with a concrete value (e.g., as JSON number, JSON string, JSON object, etc) when TD instance is created from the Thing Model."
"tm-ref-recursive-extensions","null","not testable with Assertion Tester","Recursive extensions leading to an infinite loop MUST NOT be defined."
"tm-tmOptional-resolver","null","not testable with Assertion Tester","The JSON Pointers of tm:optional MUST resolve to an entire interaction affordance Map definition."
"tm-tmRef-overwrite-possibility","null","not testable with Assertion Tester","If the intention is to override an existing JSON name-value pair definition from tm:ref, the same JSON name MUST be used at the same level of the tm:ref declaration that provides a new value."
"tm-tmRef-overwrite-process","null","not testable with Assertion Tester","The process to overwrite MUST follow the JSON Merge Patch algorithm as defined in [RFC7396] where the content of the referenced definition is patched with the new provided JSON name-value pairs."
"tm-tmRef-overwrite-semantic-meaning","null","not testable with Assertion Tester","Similar to tm:extends and to keep the semantic meaning, definitions SHOULD NOT be overwritten in such a way that possible instance values are no longer valid compared to the origin referenced definition."
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,9 @@ function defaultManipulation() {
*/
function extractName(pathLike) {
// remove path if existing
console.log("Before: "+pathLike)
// console.log("Before: "+pathLike)
pathLike = path.basename(pathLike)
console.log("After: "+pathLike)
// console.log("After: "+pathLike)
// remove file ending if existing
if (pathLike.indexOf(".") !== -1) {
pathLike = pathLike.split(".")
Expand Down
9 changes: 3 additions & 6 deletions packages/core/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function checkPropUniqueness(tdString) {
const tdProperties = td.properties
if (tdProperties.hasOwnProperty(interactionName)) {
// duplicate was at properties but that fails the td-unique identifiers as well
// console.log("at property");
results.push({
"ID": "td-properties_uniqueness",
"Status": "fail",
Expand Down Expand Up @@ -162,7 +161,6 @@ function checkPropUniqueness(tdString) {
const tdActions = td.actions
if (tdActions.hasOwnProperty(interactionName)) {
// duplicate was at actions but that fails the td-unique identifiers as well
// console.log("at action");
results.push({
"ID": "td-actions_uniqueness",
"Status": "fail",
Expand All @@ -189,7 +187,6 @@ function checkPropUniqueness(tdString) {
const tdEvents = td.events
if (tdEvents.hasOwnProperty(interactionName)) {
// duplicate was at events but that fails the td-unique identifiers as well
// console.log("at event");
results.push({
"ID": "td-events_uniqueness",
"Status": "fail",
Expand Down Expand Up @@ -787,7 +784,7 @@ function checkUriSecurity(td) {
if (curPropertyUriVariables.length>0){ // there are urivariables somewhere at least
// below is from https://stackoverflow.com/a/1885569/3806426
const filteredArray = curPropertyUriVariables.filter(value => securityUriVariables.includes(value))
console.log(curPropertyUriVariables,"\n",securityUriVariables,"\n",filteredArray)
// console.log(curPropertyUriVariables,"\n",securityUriVariables,"\n",filteredArray)
if(filteredArray.length>0){
uriVariablesDistinctResult = "fail"
} else {
Expand Down Expand Up @@ -828,7 +825,7 @@ function checkUriSecurity(td) {
if (curActionUriVariables.length>0){ // there are urivariables somewhere at least
// below is from https://stackoverflow.com/a/1885569/3806426
const filteredArray = curActionUriVariables.filter(value => securityUriVariables.includes(value))
console.log(curActionUriVariables,"\n",securityUriVariables,"\n",filteredArray)
// console.log(curActionUriVariables,"\n",securityUriVariables,"\n",filteredArray)
if(filteredArray.length>0){
uriVariablesDistinctResult = "fail"
} else {
Expand Down Expand Up @@ -869,7 +866,7 @@ function checkUriSecurity(td) {
if (curEventUriVariables.length>0){ // there are urivariables somewhere at least
// below is from https://stackoverflow.com/a/1885569/3806426
const filteredArray = curEventUriVariables.filter(value => securityUriVariables.includes(value))
console.log(curEventUriVariables,"\n",securityUriVariables,"\n",filteredArray)
// console.log(curEventUriVariables,"\n",securityUriVariables,"\n",filteredArray)
if(filteredArray.length>0){
uriVariablesDistinctResult = "fail"
} else {
Expand Down

0 comments on commit 664bb1d

Please sign in to comment.