From e5ffc25d3428f9e841181d5729c19f09cf82a609 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 6 Apr 2020 15:41:42 +0200 Subject: [PATCH] Adding and fixing rules --- .../validations/validators/TestRules.java | 6 +++--- src/test/resources/rules/ICProxy/ICProxy-query.csv | 3 +++ .../resources/rules/ICProxy/ICProxy-query.json | 12 ++++++++++++ src/test/resources/rules/ICProxy/ICProxy-read.csv | 14 ++++++++++++++ src/test/resources/rules/ICProxy/ICProxy-read.json | 12 ++++++++++++ .../SmartExecutor-getAvailablePlugins.csv | 3 ++- .../SmartExecutor-getAvailablePlugins.json | 2 +- .../SmartExecutor-getScheduledExecution.csv | 4 +++- .../SmartExecutor-getScheduledExecution.json | 2 +- .../SmartExecutor/SmartExecutor-getState.json | 2 +- .../SocialNetworking/SocialNetworking-all.csv | 3 ++- .../SocialNetworking/SocialNetworking-all.json | 2 +- .../resources/rules/Thredds/Thredds_OTHER.json | 2 +- .../cmems-importer-service-OTHER.csv | 1 + .../cmems-importer-service-OTHER.json | 12 ++++++++++++ src/test/resources/rules/gcat/gcat-OTHER.json | 2 +- .../rules/gcat/gcat-collection-instance.csv | 7 ++++++- .../rules/gcat/gcat-collection-instance.json | 2 +- .../rules/gcat/gcat-resource-instance.json | 2 +- src/test/resources/rules/gcat/gcat-resources.json | 2 +- 20 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 src/test/resources/rules/ICProxy/ICProxy-query.csv create mode 100644 src/test/resources/rules/ICProxy/ICProxy-query.json create mode 100644 src/test/resources/rules/ICProxy/ICProxy-read.csv create mode 100644 src/test/resources/rules/ICProxy/ICProxy-read.json create mode 100644 src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.csv create mode 100644 src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.json diff --git a/src/test/java/org/gcube/accounting/datamodel/validations/validators/TestRules.java b/src/test/java/org/gcube/accounting/datamodel/validations/validators/TestRules.java index 6fa3d39..4eb7702 100644 --- a/src/test/java/org/gcube/accounting/datamodel/validations/validators/TestRules.java +++ b/src/test/java/org/gcube/accounting/datamodel/validations/validators/TestRules.java @@ -219,8 +219,8 @@ public class TestRules extends ContextTest { public void testSingleRule() throws Exception { allRules(); File rulesDirectory = getRulesDirectory(); - File rulesDirFile = new File(rulesDirectory, "StorageHub"); - File ruleFile = new File(rulesDirFile, "StorageHub-createItem(FILE).json"); + File rulesDirFile = new File(rulesDirectory, "SmartExecutor"); + File ruleFile = new File(rulesDirFile, "SmartExecutor-getAvailablePlugins.json"); testRule(ruleFile); } @@ -228,7 +228,7 @@ public class TestRules extends ContextTest { public void testAllRuleInAdirectory() throws Exception { allRules(); File rulesDirectory = getRulesDirectory(); - File rulesDirFile = new File(rulesDirectory, "StorageHub"); + File rulesDirFile = new File(rulesDirectory, "SmartExecutor"); FilenameFilter filenameFilter = new FilenameFilter() { @Override diff --git a/src/test/resources/rules/ICProxy/ICProxy-query.csv b/src/test/resources/rules/ICProxy/ICProxy-query.csv new file mode 100644 index 0000000..ccf719a --- /dev/null +++ b/src/test/resources/rules/ICProxy/ICProxy-query.csv @@ -0,0 +1,3 @@ +InformationSystem,ICProxy,/gcube/service/GCoreEndpoint/Application/perform-service +InformationSystem,ICProxy,/gcube/service/GCoreEndpoint/InformationSystem/ICProxy +InformationSystem,ICProxy,/gcube/service/HostingNode \ No newline at end of file diff --git a/src/test/resources/rules/ICProxy/ICProxy-query.json b/src/test/resources/rules/ICProxy/ICProxy-query.json new file mode 100644 index 0000000..c457209 --- /dev/null +++ b/src/test/resources/rules/ICProxy/ICProxy-query.json @@ -0,0 +1,12 @@ +{ + "match": { + "serviceClassRegex": "InformationSystem", + "serviceNameRegex": "ICProxy", + "calledMethodRegex": "^(\/){0,1}gcube\/service\/(GCoreEndpoint|HostingNode|RuntimeResource|GenericResource).*" + }, + "replace": { + "serviceClass": "InformationSystem", + "serviceName": "ICProxy", + "calledMethod": "query" + } +} \ No newline at end of file diff --git a/src/test/resources/rules/ICProxy/ICProxy-read.csv b/src/test/resources/rules/ICProxy/ICProxy-read.csv new file mode 100644 index 0000000..bcf2683 --- /dev/null +++ b/src/test/resources/rules/ICProxy/ICProxy-read.csv @@ -0,0 +1,14 @@ +InformationSystem,ICProxy,/gcube/service/&gcube-token=d730d65f-073a-4600-8c7b-326752d61ebf-98187548 +InformationSystem,ICProxy,/gcube/service/23d827cd-ba8e-4d8c-9ab4-6303bdb7d1db +InformationSystem,ICProxy,/gcube/service/56ec4876-999f-4afc-a9e3-efbda5f5c8bc +InformationSystem,ICProxy,/gcube/service/78fb3c26-0411-49e3-a244-581591413fa3 +InformationSystem,ICProxy,/gcube/service/9151fd89-ae33-4ddb-ac6b-c4e4c85376d6-98187548 +InformationSystem,ICProxy,/gcube/service/a074d80d-d339-490c-a9bb-1055576530a9 +InformationSystem,ICProxy,/gcube/service/ab9d32c9-... +InformationSystem,ICProxy,/gcube/service/ab9d32c9-9425-42f1-99d7-50d68e651e9c +InformationSystem,ICProxy,/gcube/service/c96d4477-236c-4f98-ba7d-7897991ef412 +InformationSystem,ICProxy,/gcube/service/cdc52c27-6d7b-4d55-b4cd-314d7cc2e224 +InformationSystem,ICProxy,/gcube/service/dc8cc938-24f9-4aaf-aac2-397817b8798a +InformationSystem,ICProxy,/gcube/service/df24b57c-0a9d-40fe-846e-ef0a94b89389 +InformationSystem,ICProxy,/gcube/service/resource/c96d4477-236c-4f98-ba7d-7897991ef412 +InformationSystem,ICProxy,/gcube/service/Resource/c0594b4e-107c-4c9f-bd00-818b68298aa4 \ No newline at end of file diff --git a/src/test/resources/rules/ICProxy/ICProxy-read.json b/src/test/resources/rules/ICProxy/ICProxy-read.json new file mode 100644 index 0000000..81c60c6 --- /dev/null +++ b/src/test/resources/rules/ICProxy/ICProxy-read.json @@ -0,0 +1,12 @@ +{ + "match": { + "serviceClassRegex": "InformationSystem", + "serviceNameRegex": "ICProxy", + "calledMethodRegex": "^(\/){0,1}gcube\/service\/(?!GCoreEndpoint|HostingNode|RuntimeResource|GenericResource).*" + }, + "replace": { + "serviceClass": "InformationSystem", + "serviceName": "ICProxy", + "calledMethod": "read" + } +} \ No newline at end of file diff --git a/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.csv b/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.csv index f8d3545..8209a12 100644 --- a/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.csv +++ b/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.csv @@ -3,4 +3,5 @@ VREManagement,SmartExecutor,GET /plugins VREManagement,SmartExecutor,GET /plugins/ VREManagement,smart-executor,getAvailablePlugins VREManagement,smart-executor,GET /plugins -VREManagement,smart-executor,GET /plugins/ \ No newline at end of file +VREManagement,smart-executor,GET /plugins/ +VREManagement,SmartExecutor,/plugins diff --git a/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.json b/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.json index dffd014..8f8b83b 100644 --- a/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.json +++ b/src/test/resources/rules/SmartExecutor/SmartExecutor-getAvailablePlugins.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "VREManagement", "serviceNameRegex": "(SmartExecutor)|(smart-executor)", - "calledMethodRegex": ".*((getAvailablePlugins.*)|(GET \/plugins(\/){0,1}$))" + "calledMethodRegex": ".*((getAvailablePlugins.*)|(^(GET ){0,1}(\/){0,1}plugins(\/){0,1}$))" }, "replace": { "serviceClass": "VREManagement", diff --git a/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.csv b/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.csv index 077cda5..98169ae 100644 --- a/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.csv +++ b/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.csv @@ -5,4 +5,6 @@ VREManagement,smart-executor,getScheduledExecution VREManagement,smart-executor,GET /plugins/accounting-dashboard-harvester-se-plugin/executions VREManagement,smart-executor,GET /plugins/accounting-dashboard-harvester-se-plugin/executions/ VREManagement,SmartExecutor,/rest/plugins/HelloWorld -VREManagement,SmartExecutor,/plugins/HelloWorld \ No newline at end of file +VREManagement,SmartExecutor,/plugins/HelloWorld +VREManagement,SmartExecutor,/plugins/social-data-indexer-plugin/executions +VREManagement,SmartExecutor,/plugins/social-data-indexer-plugin/executions/ORPHAN \ No newline at end of file diff --git a/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.json b/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.json index 8748379..47fee2a 100644 --- a/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.json +++ b/src/test/resources/rules/SmartExecutor/SmartExecutor-getScheduledExecution.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "VREManagement", "serviceNameRegex": "(SmartExecutor)|(smart-executor)", - "calledMethodRegex": ".*((getScheduledExecution.*)|(GET .*executions(\/){0,1}$))|((GET ){0,1}(\/){0,1}(rest\/){0,1}plugins\/[a-zA-Z]{1,})" + "calledMethodRegex": ".*((getScheduledExecution.*)|((GET ){0,1}.*executions(\/(ORPHAN){0,1}){0,1}()$))|((GET ){0,1}(\/){0,1}(rest\/){0,1}plugins\/[0-9a-zA-Z%\\-_]{1,})" }, "replace": { "serviceClass": "VREManagement", diff --git a/src/test/resources/rules/SmartExecutor/SmartExecutor-getState.json b/src/test/resources/rules/SmartExecutor/SmartExecutor-getState.json index e9a9218..4ae4a51 100644 --- a/src/test/resources/rules/SmartExecutor/SmartExecutor-getState.json +++ b/src/test/resources/rules/SmartExecutor/SmartExecutor-getState.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "VREManagement", "serviceNameRegex": "(SmartExecutor)|(smart-executor)", - "calledMethodRegex": ".*((getStateEvolution)|(getState)|(GET .*executions\/.{1,})).*|((GET ){0,1}(\/){0,1}(rest\/){0,1}plugins\/[a-zA-Z]{1,}\/.*)" + "calledMethodRegex": ".*((getStateEvolution)|(getState)|(GET .*executions\/(?!executions).{1,})).*|((GET ){0,1}(\/){0,1}(rest\/){0,1}plugins\/[0-9a-zA-Z%\\-_]{1,}\/(?!executions).*)" }, "replace": { "serviceClass": "VREManagement", diff --git a/src/test/resources/rules/SocialNetworking/SocialNetworking-all.csv b/src/test/resources/rules/SocialNetworking/SocialNetworking-all.csv index f514a20..072ecaf 100644 --- a/src/test/resources/rules/SocialNetworking/SocialNetworking-all.csv +++ b/src/test/resources/rules/SocialNetworking/SocialNetworking-all.csv @@ -70,4 +70,5 @@ Portal,SocialNetworking,/rest/2/users/user-exists Portal,SocialNetworking,/rest/2/vres/get-my-vres Portal,SocialNetworking,/rest/messages/writeMessageToUsers Portal,SocialNetworking,/rest/users/getUserEmail -Portal,SocialNetworking,/rest/users/getUserFullname \ No newline at end of file +Portal,SocialNetworking,/rest/users/getUserFullname +Portal,SocialNetworking,/gcube/service/&gcube-token=d730d65f-073a-4600-8c7b-326752d61ebf-98187548 \ No newline at end of file diff --git a/src/test/resources/rules/SocialNetworking/SocialNetworking-all.json b/src/test/resources/rules/SocialNetworking/SocialNetworking-all.json index 2c07b2a..0b6e824 100644 --- a/src/test/resources/rules/SocialNetworking/SocialNetworking-all.json +++ b/src/test/resources/rules/SocialNetworking/SocialNetworking-all.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "Portal", "serviceNameRegex": "SocialNetworking", - "calledMethodRegex": "\/{0,1}rest\/((1|2)\/){0,1}(((users(\/2){0,1})|comments|full-text-search|hashtags|messages|notifications|people|posts|tokens|vres|vers)\/){0,1}(?[a-zA-Z\\-]*(\/){0,1})" + "calledMethodRegex": "\/{0,1}rest\/((1|2)\/){0,1}(((people){0,1}(users(\/2){0,1})|comments|full-text-search|hashtags|messages|notifications|people|posts|tokens|vres|vers)\/){0,1}(?[a-zA-Z\\-]*(\/){0,1})" }, "replace": { "serviceClass": "Portal", diff --git a/src/test/resources/rules/Thredds/Thredds_OTHER.json b/src/test/resources/rules/Thredds/Thredds_OTHER.json index b9d3b7c..2938d28 100644 --- a/src/test/resources/rules/Thredds/Thredds_OTHER.json +++ b/src/test/resources/rules/Thredds/Thredds_OTHER.json @@ -1,6 +1,6 @@ { "match": { - "serviceClassRegex": "SDI", + "serviceClassRegex": "SDI|DataAnalysis", "serviceNameRegex": "Thredds", "calledMethodRegex": "^(?!.*((\/public\/netcdf\/)|(::))).*$" }, diff --git a/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.csv b/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.csv new file mode 100644 index 0000000..0b61dd3 --- /dev/null +++ b/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.csv @@ -0,0 +1 @@ +DataAnalysis,data-analytics-visualization,/ \ No newline at end of file diff --git a/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.json b/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.json new file mode 100644 index 0000000..475de22 --- /dev/null +++ b/src/test/resources/rules/data-analytics-visualization/cmems-importer-service-OTHER.json @@ -0,0 +1,12 @@ +{ + "match": { + "serviceClassRegex": "DataAnalysis", + "serviceNameRegex": "data-analytics-visualization", + "calledMethodRegex": ".*" + }, + "replace": { + "serviceClass": "DataAnalysis", + "serviceName": "data-analytics-visualization", + "calledMethod": "OTHER" + } +} \ No newline at end of file diff --git a/src/test/resources/rules/gcat/gcat-OTHER.json b/src/test/resources/rules/gcat/gcat-OTHER.json index 60ab3c8..bd3d800 100644 --- a/src/test/resources/rules/gcat/gcat-OTHER.json +++ b/src/test/resources/rules/gcat/gcat-OTHER.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "(DataCatalogue)|(DataPublishing)", "serviceNameRegex": "(science-catalogue)|(gcat)|(gCat)", - "calledMethodRegex": "(\/index)|OTHER|UNKNOWN" + "calledMethodRegex": "(^\/index$)|OTHER|UNKNOWN" }, "replace": { "serviceClass": "DataPublishing", diff --git a/src/test/resources/rules/gcat/gcat-collection-instance.csv b/src/test/resources/rules/gcat/gcat-collection-instance.csv index 53a46b0..ce09a89 100644 --- a/src/test/resources/rules/gcat/gcat-collection-instance.csv +++ b/src/test/resources/rules/gcat/gcat-collection-instance.csv @@ -8,6 +8,11 @@ DataCatalogue,science-catalogue,/items/restful_transaction_model DataCatalogue,science-catalogue,/organizations/algorithms DataCatalogue,science-catalogue,/organizations/aquamaps1 DataCatalogue,science-catalogue,/profiles/Empty%20Profile -DataCatalogue,science-catalogue,/rest/api/items/create +DataCatalogue,gcat,/profiles/SoBigData.eu%3A%20Application%20Metadata +DataCatalogue,gcat,/profiles/SoBigData.eu%3A%20Dataset%20Metadata +DataCatalogue,gcat,/profiles/SoBigData.eu%3A%20Method%20Metadata +DataCatalogue,gcat,/profiles/SoBigData.eu%3A%2520Dataset%2520Metadata +DataCatalogue,gcat,/profiles/SoBigData.eu%3A+Dataset+Metadata +DataCatalogue,gcat,/profiles/SoBigData.eu:%20Dataset%20Metadata DataCatalogue,science-catalogue,/users/andrearossi DataCatalogue,science-catalogue,/users/luca_frosini \ No newline at end of file diff --git a/src/test/resources/rules/gcat/gcat-collection-instance.json b/src/test/resources/rules/gcat/gcat-collection-instance.json index 8037842..edf1391 100644 --- a/src/test/resources/rules/gcat/gcat-collection-instance.json +++ b/src/test/resources/rules/gcat/gcat-collection-instance.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "(DataCatalogue)|(DataPublishing)", "serviceNameRegex": "(science-catalogue)|(gcat)|(gCat)", - "calledMethodRegex": "(\/){0,1}(rest\/(api\/){0,1}){0,1}(?group|item|license|namespace|organization|profile|user)s\/(?!list)[%0-9a-zA-Z\\-_]*$" + "calledMethodRegex": "^(\/){0,1}(rest\/(api\/){0,1}){0,1}(?group|item|license|namespace|organization|profile|user)s\/(?!list|create)[%0-9a-zA-Z\\-_.+:]*$" }, "replace": { "serviceClass": "DataPublishing", diff --git a/src/test/resources/rules/gcat/gcat-resource-instance.json b/src/test/resources/rules/gcat/gcat-resource-instance.json index 3b09704..e13ba3e 100644 --- a/src/test/resources/rules/gcat/gcat-resource-instance.json +++ b/src/test/resources/rules/gcat/gcat-resource-instance.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "(DataCatalogue)|(DataPublishing)", "serviceNameRegex": "(science-catalogue)|(gcat)|(gCat)", - "calledMethodRegex": "(\/){0,1}(rest\/(api\/){0,1}){0,1}items\/[%0-9a-zA-Z\\-_]*\/resources\/[%0-9a-zA-Z\\-_]*$" + "calledMethodRegex": "^(\/){0,1}(rest\/(api\/){0,1}){0,1}items\/[%0-9a-zA-Z\\-_]*\/resources\/[%0-9a-zA-Z\\-_.+:]*$" }, "replace": { "serviceClass": "DataPublishing", diff --git a/src/test/resources/rules/gcat/gcat-resources.json b/src/test/resources/rules/gcat/gcat-resources.json index 97ac78d..884d715 100644 --- a/src/test/resources/rules/gcat/gcat-resources.json +++ b/src/test/resources/rules/gcat/gcat-resources.json @@ -2,7 +2,7 @@ "match": { "serviceClassRegex": "(DataCatalogue)|(DataPublishing)", "serviceNameRegex": "(science-catalogue)|(gcat)|(gCat)", - "calledMethodRegex": "(\/){0,1}(rest\/(api\/){0,1}){0,1}items\/[%0-9a-zA-Z\\-_]*\/resources$" + "calledMethodRegex": "^(\/){0,1}(rest\/(api\/){0,1}){0,1}items\/[%0-9a-zA-Z\\-_.+:]*\/resources$" }, "replace": { "serviceClass": "DataPublishing",