From 16fedb92165a444ee7a40043e4fe113c3e47a85f Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Fri, 23 Aug 2024 13:01:12 +0200 Subject: [PATCH 01/10] Feature: Add unmapped, range and domain attributes for properties endpoints (#89) * implement in ontology property endpoint the display all attributes * add a new unit test for the ontology property display all option --- Gemfile.lock | 20 +++---- controllers/properties_controller.rb | 4 +- .../controllers/test_properties_controller.rb | 57 ++++++++++++------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 311e26ee..b2273ce2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ncbo_cron.git - revision: fabd04ef4fa37989d526fc6a7aa1e98830008dae + revision: bed0ff08408ad1241db3513992ad025a253eeef0 branch: master specs: ncbo_cron (0.0.1) @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 552fbe5faed5bb195396251066ef0e7b930939a0 + revision: 9605eb44c4271c60bedda0520e85d8c3fa2513ac branch: development specs: ontologies_linked_data (0.0.1) @@ -129,7 +129,7 @@ GEM capistrano (~> 3.1) sshkit (~> 1.3) coderay (1.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crack (1.0.0) bigdecimal @@ -175,7 +175,7 @@ GEM grpc (~> 1.59) get_process_mem (0.2.7) ffi (~> 1.0) - google-analytics-data (0.6.0) + google-analytics-data (0.6.1) google-analytics-data-v1beta (>= 0.11, < 2.a) google-cloud-core (~> 1.6) google-analytics-data-v1beta (0.13.0) @@ -220,7 +220,7 @@ GEM hashdiff (1.1.1) htmlentities (4.3.4) http-accept (1.7.0) - http-cookie (1.0.6) + http-cookie (1.0.7) domain_name (~> 0.5) httpclient (2.8.3) i18n (0.9.5) @@ -247,7 +247,7 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0702) + mime-types-data (3.2024.0820) mini_mime (1.1.5) minitest (4.7.5) minitest-stub_any_instance (1.0.3) @@ -278,7 +278,7 @@ GEM omni_logger (0.1.4) logger os (1.1.4) - parallel (1.25.1) + parallel (1.26.3) parseconfig (1.1.2) pony (1.13.1) mail (>= 2.0) @@ -320,14 +320,14 @@ GEM rdf (~> 3.2) rexml (~> 3.2) redcarpet (3.6.0) - redis (5.2.0) + redis (5.3.0) redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool redis-rack-cache (2.2.1) rack-cache (>= 1.10, < 2) redis-store (>= 1.6, < 2) - redis-store (1.10.0) + redis-store (1.11.0) redis (>= 4, < 6) representable (3.2.0) declarative (< 0.1.0) @@ -341,7 +341,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) - rexml (3.3.4) + rexml (3.3.6) strscan rsolr (2.6.0) builder (>= 2.1.2) diff --git a/controllers/properties_controller.rb b/controllers/properties_controller.rb index d32180d5..c20bc532 100644 --- a/controllers/properties_controller.rb +++ b/controllers/properties_controller.rb @@ -24,7 +24,9 @@ class PropertiesController < ApplicationController get '/:property' do prop = params[:property] ont, submission = get_ontology_and_submission - p = ont.property(prop, submission, display_all_attributes: false) + bring_unmapped = bring_unmapped?(includes_param) + + p = ont.property(prop, submission, display_all_attributes: bring_unmapped) error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil? reply 200, p end diff --git a/test/controllers/test_properties_controller.rb b/test/controllers/test_properties_controller.rb index 96879083..bbc64ba5 100644 --- a/test/controllers/test_properties_controller.rb +++ b/test/controllers/test_properties_controller.rb @@ -4,24 +4,24 @@ class TestPropertiesController < TestCase def self.before_suite count, acronyms, bro = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({ - process_submission: true, - process_options:{process_rdf: true, extract_metadata: false}, - acronym: "BROSEARCHTEST", - name: "BRO Search Test", - file_path: "./test/data/ontology_files/BRO_v3.2.owl", - ont_count: 1, - submission_count: 1, - ontology_type: "VALUE_SET_COLLECTION" + process_submission: true, + process_options: { process_rdf: true, extract_metadata: false }, + acronym: "BROSEARCHTEST", + name: "BRO Search Test", + file_path: "./test/data/ontology_files/BRO_v3.2.owl", + ont_count: 1, + submission_count: 1, + ontology_type: "VALUE_SET_COLLECTION" }) count, acronyms, mccl = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({ - process_submission: true, - process_options:{process_rdf: true, extract_metadata: true}, - acronym: "MCCLSEARCHTEST", - name: "MCCL Search Test", - file_path: "./test/data/ontology_files/CellLine_OWL_BioPortal_v1.0.owl", - ont_count: 1, - submission_count: 1 + process_submission: true, + process_options: { process_rdf: true, extract_metadata: true }, + acronym: "MCCLSEARCHTEST", + name: "MCCL Search Test", + file_path: "./test/data/ontology_files/CellLine_OWL_BioPortal_v1.0.owl", + ont_count: 1, + submission_count: 1 }) @@ontologies = bro.concat(mccl) @@acronyms = @@ontologies.map { |ont| ont.bring_remaining; ont.acronym } @@ -47,14 +47,33 @@ def test_single_property get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23Originator" assert last_response.ok? results = MultiJson.load(last_response.body) + assert results.is_a?(Hash) assert_equal ["Originator"], results["label"] assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Originator", results["@id"] + assert results.key?('range') + assert results.key?('domain') get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23DummyProp" assert_equal 404, last_response.status end + def test_single_property_all_attributes + get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23Originator?display=all" + assert last_response.ok? + results = MultiJson.load(last_response.body) + assert_equal ["Originator"], results["label"] + assert results.key?('range') + assert results.key?('domain') + + assert_equal results["properties"]["http://www.w3.org/2000/01/rdf-schema#comment"], ["Originator of a class"] + assert_equal results["properties"]["http://www.w3.org/2004/02/skos/core#prefLabel"], ["Originator"] + assert_equal results["properties"]["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"], ["http://www.w3.org/2002/07/owl#DatatypeProperty"] + assert_equal results["properties"]["http://www.w3.org/2000/01/rdf-schema#domain"], ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Algorithm"] + assert_equal results["properties"]["http://www.w3.org/2000/01/rdf-schema#label"], ["Originator"] + + end + def test_property_roots get "/ontologies/#{@@acronyms.first}/properties/roots" assert last_response.ok? @@ -66,10 +85,10 @@ def test_property_roots assert_includes [18, 13], opr.length # count datatype properties dpr = pr.select { |p| p["@type"] == "http://www.w3.org/2002/07/owl#DatatypeProperty" } - assert_includes [32,31], dpr.length + assert_includes [32, 31], dpr.length # count annotation properties apr = pr.select { |p| p["@type"] == "http://www.w3.org/2002/07/owl#AnnotationProperty" } - assert_includes [12,8], apr.length + assert_includes [12, 8], apr.length # check for non-root properties assert_empty pr.select { |p| ["http://www.w3.org/2004/02/skos/core#broaderTransitive", @@ -174,7 +193,7 @@ def test_property_descendants dn = MultiJson.load(last_response.body) assert_equal 2, dn.length assert_equal ["http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#overExpress", - "http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#underExpress"].sort, dn.map { |d| d["@id"] }.sort + "http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#underExpress"].sort, dn.map { |d| d["@id"] }.sort end def test_property_parents @@ -207,7 +226,7 @@ def test_property_children assert_empty ch get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23semanticRelation" - return unless last_response.ok? #depending if owlapi import SKOS + return unless last_response.ok? # depending if owlapi import SKOS get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23semanticRelation/children" assert last_response.ok? From fc6635f8938b89bc9884800ee82a4a73766f1ff3 Mon Sep 17 00:00:00 2001 From: Syphax Date: Fri, 30 Aug 2024 10:45:00 +0200 Subject: [PATCH 02/10] update home endpoint to add portal config information --- Gemfile | 4 ++-- Gemfile.lock | 20 +++++++++--------- config/environments/config.rb.sample | 31 ++++++++++++++++++++++++++++ controllers/home_controller.rb | 18 +++++++++++----- docker-compose.yml | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index adaeb43a..2410452a 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'json-ld' # Rack middleware -gem 'ffi' +gem 'ffi', '~> 1.16.3' gem 'rack-accept', '~> 0.4' gem 'rack-attack', '~> 6.6.1', require: 'rack/attack' gem 'rack-cache', '~> 1.13.0' @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/add-portal-config-model' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index b2273ce2..23175a03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 9605eb44c4271c60bedda0520e85d8c3fa2513ac - branch: development + revision: d893c08a2c2f11c743fad520873b7f98b0805240 + branch: feature/add-portal-config-model specs: ontologies_linked_data (0.0.1) activesupport @@ -108,7 +108,7 @@ GEM multi_json (~> 1.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - airbrussh (1.5.2) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) backports (3.25.0) base64 (0.2.0) @@ -164,7 +164,7 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.17.0) + ffi (1.16.3) gapic-common (0.21.1) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) @@ -178,7 +178,7 @@ GEM google-analytics-data (0.6.1) google-analytics-data-v1beta (>= 0.11, < 2.a) google-cloud-core (~> 1.6) - google-analytics-data-v1beta (0.13.0) + google-analytics-data-v1beta (0.13.1) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) google-apis-analytics_v3 (0.16.0) @@ -236,7 +236,7 @@ GEM kgio (2.11.4) libxml-ruby (5.0.3) link_header (0.0.8) - logger (1.6.0) + logger (1.6.1) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -247,7 +247,7 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0820) + mime-types-data (3.2024.0903) mini_mime (1.1.5) minitest (4.7.5) minitest-stub_any_instance (1.0.3) @@ -258,7 +258,7 @@ GEM mutex_m (0.2.0) net-http-persistent (4.0.2) connection_pool (~> 2.2) - net-imap (0.4.14) + net-imap (0.4.15) date net-protocol net-pop (0.1.2) @@ -273,7 +273,7 @@ GEM net-protocol net-ssh (7.2.3) netrc (0.11.0) - newrelic_rpm (9.12.0) + newrelic_rpm (9.13.0) oj (3.16.1) omni_logger (0.1.4) logger @@ -419,7 +419,7 @@ DEPENDENCIES cube-ruby ed25519 (>= 1.2, < 2.0) faraday (~> 1.9) - ffi + ffi (~> 1.16.3) goo! haml (~> 5.2.2) json-ld diff --git a/config/environments/config.rb.sample b/config/environments/config.rb.sample index f143b8f9..4e7900b7 100644 --- a/config/environments/config.rb.sample +++ b/config/environments/config.rb.sample @@ -87,6 +87,37 @@ LinkedData.config do |config| link: 'https://www.googleapis.com/oauth2/v3/userinfo' } } + config.ui_name = 'Bioportal' + config.title = 'NCBO BioPortal' + config.description = "The world's most comprehensive repository of biomedical ontologies " + config.color = '#234979' + config.logo = '' + config.fundedBy = [ + { + img_src: 'https://identity.stanford.edu/wp-content/uploads/sites/3/2020/07/block-s-right.png', + url: 'https://www.stanford.edu', + + }, + { + img_src: 'https://ontoportal.org/images/logo.png', + url: 'https://ontoportal.org/', + } + ] + config.federated_portals = { + 'agroportal' => { + api: 'http://data.agroportal.lirmm.fr', + ui: 'http://agroportal.lirmm.fr', + apikey: '1cfae05f-9e67-486f-820b-b393dec5764b', + color: '#1e2251' + }, + 'bioportal' => { + api: 'http://data.bioontology.org', + ui: 'http://bioportal.bioontology.org', + apikey: '4a5011ea-75fa-4be6-8e89-f45c8c84844e', + color: '#234979' + }, + + } end Annotator.config do |config| diff --git a/controllers/home_controller.rb b/controllers/home_controller.rb index a44fd22e..140d4522 100644 --- a/controllers/home_controller.rb +++ b/controllers/home_controller.rb @@ -4,7 +4,7 @@ class HomeController < ApplicationController CLASS_MAP = { - Property: "LinkedData::Models::ObjectProperty" + Property: "LinkedData::Models::ObjectProperty" } namespace "/" do @@ -28,14 +28,22 @@ class HomeController < ApplicationController next if route.length < 3 || route.split("/").length > 2 route_no_slash = route.gsub("/", "") context[route_no_slash] = route_to_class_map[route].type_uri.to_s if route_to_class_map[route] && route_to_class_map[route].respond_to?(:type_uri) - routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix+route_no_slash + routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix + route_no_slash end - routes_hash["@context"] = context - reply ({links: routes_hash}) + + config = LinkedData::Models::PortalConfig.current_portal_config + + federated_portals = config.federated_portals + federated_portals. transform_values! { |v| v.delete(:apikey) ; v } + config.init_federated_portals_settings(federated_portals) + + config.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) } + + reply config end get "documentation" do - @metadata_all = metadata_all.sort {|a,b| a[0].name <=> b[0].name} + @metadata_all = metadata_all.sort { |a, b| a[0].name <=> b[0].name } haml "documentation/documentation".to_sym, :layout => "documentation/layout".to_sym end diff --git a/docker-compose.yml b/docker-compose.yml index 564fc8d2..07b0cda1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: - "9393:9393" volumes: # bundle volume for hosting gems installed by bundle; it speeds up gem install in local development - - app_api:/srv/ontoportal/ontologies_api + - .:/srv/ontoportal/ontologies_api - repository:/srv/ontoportal/data/repository ncbo_cron: From dd3be1f4bc5a1fe15a7bcc84087ae683381363dd Mon Sep 17 00:00:00 2001 From: Syphax Date: Wed, 4 Sep 2024 14:21:16 +0200 Subject: [PATCH 03/10] set the portal config id as the the api endpoint host --- controllers/home_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/home_controller.rb b/controllers/home_controller.rb index 140d4522..29aa851c 100644 --- a/controllers/home_controller.rb +++ b/controllers/home_controller.rb @@ -36,7 +36,7 @@ class HomeController < ApplicationController federated_portals = config.federated_portals federated_portals. transform_values! { |v| v.delete(:apikey) ; v } config.init_federated_portals_settings(federated_portals) - + config.id = RDF::URI.new(LinkedData.settings.id_url_prefix) config.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) } reply config From 5d56ebba6a885a420362d67d49a82ba7b9b2b4c2 Mon Sep 17 00:00:00 2001 From: Syphax Date: Mon, 16 Sep 2024 06:33:56 +0200 Subject: [PATCH 04/10] add submission diff endpoint --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- .../ontology_submissions_controller.rb | 19 +++++++++++++++++++ .../test_ontology_submissions_controller.rb | 10 ++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index bf492d6e..4ab99783 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parse-diff-files' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 0dab4ec7..f8e14446 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 651d2f4226004c2311120e900a936101ee509865 - branch: development + revision: d69ede0a0b3e3c5dee64fa75cb09cc6e16e0f4b5 + branch: feature/parse-diff-files specs: ontologies_linked_data (0.0.1) activesupport @@ -202,7 +202,7 @@ GEM google-protobuf (>= 3.18, < 5.a) googleapis-common-protos-types (~> 1.7) grpc (~> 1.41) - googleapis-common-protos-types (1.15.0) + googleapis-common-protos-types (1.16.0) google-protobuf (>= 3.18, < 5.a) googleauth (1.11.0) faraday (>= 1.0, < 3.a) @@ -231,7 +231,7 @@ GEM rdf (>= 2.2.8, < 4.0) json-schema (2.8.1) addressable (>= 2.4) - jwt (2.8.2) + jwt (2.9.0) base64 kgio (2.11.4) libxml-ruby (5.0.3) diff --git a/controllers/ontology_submissions_controller.rb b/controllers/ontology_submissions_controller.rb index 0068a5f1..6b5818b5 100644 --- a/controllers/ontology_submissions_controller.rb +++ b/controllers/ontology_submissions_controller.rb @@ -140,6 +140,25 @@ class OntologySubmissionsController < ApplicationController end end + get '/:ontology_submission_id/diff' do + acronym = params["acronym"] + submission_attributes = [:submissionId, :submissionStatus, :diffFilePath] + ont = Ontology.find(acronym).include(:submissions => submission_attributes).first + error 422, "You must provide an existing `acronym` to download" if ont.nil? + ont.bring(:viewingRestriction) + check_access(ont) + ont_restrict_downloads = LinkedData::OntologiesAPI.settings.restrict_download + error 403, "License restrictions on download for #{acronym}" if ont_restrict_downloads.include? acronym + submission = ont.submission(params['ontology_submission_id'].to_i) + error 404, "There is no such submission for download" if submission.nil? + file_path = submission.diffFilePath + if File.readable? file_path + reply submission.parse_diff_report + else + error 500, "Cannot read submission diff file: #{file_path}" + end + end + ## # Download a submission diff file get '/:ontology_submission_id/download_diff' do diff --git a/test/controllers/test_ontology_submissions_controller.rb b/test/controllers/test_ontology_submissions_controller.rb index 095d0339..1e5014f6 100644 --- a/test/controllers/test_ontology_submissions_controller.rb +++ b/test/controllers/test_ontology_submissions_controller.rb @@ -474,6 +474,16 @@ def test_submissions_param_include test_submissions_custom_includes end + def test_submission_diff + num_onts_created, created_ont_acronyms, onts = create_ontologies_and_submissions(ont_count: 1, submission_count: 2, + process_submission: true, + process_options: { process_rdf: true, extract_metadata: false, diff: true} ) + + ont = onts.first + sub = ont.latest_submission(status: :any) + + get "/ontologies/#{ont.acronym}/submissions/#{sub.submissionId}/diff" + end private def submission_keys(sub) sub.to_hash.keys - %w[@id @type id] From 1c27d64a169f7c353289b27ae8cadce88bfa99a5 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:01:14 +0200 Subject: [PATCH 05/10] add a test for parent category --- Gemfile | 2 +- Gemfile.lock | 6 ++++- .../controllers/test_categories_controller.rb | 25 ++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index f1b00e71..de4be286 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/add-portal-config-model' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 57397362..774dde55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 651d2f4226004c2311120e900a936101ee509865 + revision: f7ee9f13db6b89a303ebe86887b932ab035181d7 branch: development specs: ontologies_linked_data (0.0.1) @@ -211,6 +211,9 @@ GEM multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) + grpc (1.65.2) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) grpc (1.65.2-x86_64-linux) google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) @@ -406,6 +409,7 @@ GEM hashdiff (>= 0.4.0, < 2.0.0) PLATFORMS + ruby x86_64-linux DEPENDENCIES diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index d7e07cd2..bfbe6fdd 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -117,4 +117,27 @@ def test_delete_category get "/categories/#{acronym}" assert last_response.status == 404 end -end \ No newline at end of file + + def test_parent_category + parent_category1 = LinkedData::Models::Category.new( + acronym: "PARENT1", + name: "Parent Category 1", + description: "Description for Parent Category 1." + ) + + parent_category2 = LinkedData::Models::Category.new( + acronym: "PARENT2", + name: "Parent Category 2", + description: "Description for Parent Category 2." + ) + + category_instance = LinkedData::Models::Category.new( + acronym: "CAT123", + name: "Sample Category", + description: "This is a sample category.", + parentCategories: [parent_category1, parent_category2] + ) + assert_equal category_instance.parentCategories.first , parent_category1 + assert_equal category_instance.parentCategories.last , parent_category2 + end +end From 129294f63d477d35b195e9135c0de6e23beaf765 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:07:36 +0200 Subject: [PATCH 06/10] use parent category branch in the gemfile --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index de4be286..6abed255 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parent-category-list' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 774dde55..17c45568 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: f7ee9f13db6b89a303ebe86887b932ab035181d7 - branch: development + revision: 4d7d433b5f62a284eef6a37fb20c420fd0f41f70 + branch: feature/parent-category-list specs: ontologies_linked_data (0.0.1) activesupport From 3afae264d9ff2882a9b73bd19c94e07eaf75b652 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:55:12 +0200 Subject: [PATCH 07/10] update test parent category to use parentCategory instead of parentCategories --- Gemfile.lock | 2 +- test/controllers/test_categories_controller.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 17c45568..9fdfcfde 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 4d7d433b5f62a284eef6a37fb20c420fd0f41f70 + revision: ce7463428dbee569a0ca4ca20fe84861e4a2ce82 branch: feature/parent-category-list specs: ontologies_linked_data (0.0.1) diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index bfbe6fdd..3c0377e7 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -135,9 +135,9 @@ def test_parent_category acronym: "CAT123", name: "Sample Category", description: "This is a sample category.", - parentCategories: [parent_category1, parent_category2] + parentCategory: [parent_category1, parent_category2] ) - assert_equal category_instance.parentCategories.first , parent_category1 - assert_equal category_instance.parentCategories.last , parent_category2 + assert_equal category_instance.parentCategory.first , parent_category1 + assert_equal category_instance.parentCategory.last , parent_category2 end end From 40c5444d5cf0355f7aedcfd84ae002f5a8de0d59 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Thu, 10 Oct 2024 14:00:28 +0200 Subject: [PATCH 08/10] save category and fetch it in test parent category --- Gemfile | 2 +- Gemfile.lock | 4 ++-- test/controllers/test_categories_controller.rb | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 6abed255..de4be286 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parent-category-list' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 9fdfcfde..9c861a4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: ce7463428dbee569a0ca4ca20fe84861e4a2ce82 - branch: feature/parent-category-list + revision: 25819bc9bff2313a9ac4fc717241d37051bcdf4f + branch: development specs: ontologies_linked_data (0.0.1) activesupport diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index 3c0377e7..4cfa7a0b 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -124,12 +124,14 @@ def test_parent_category name: "Parent Category 1", description: "Description for Parent Category 1." ) + parent_category1.save parent_category2 = LinkedData::Models::Category.new( acronym: "PARENT2", name: "Parent Category 2", description: "Description for Parent Category 2." ) + parent_category2.save category_instance = LinkedData::Models::Category.new( acronym: "CAT123", @@ -137,7 +139,12 @@ def test_parent_category description: "This is a sample category.", parentCategory: [parent_category1, parent_category2] ) - assert_equal category_instance.parentCategory.first , parent_category1 - assert_equal category_instance.parentCategory.last , parent_category2 + category_instance.save + + get '/categories/CAT123' + fetched_category = MultiJson.load(last_response.body) + + assert_equal fetched_category["parentCategory"].first , parent_category1.id.to_s + assert_equal fetched_category["parentCategory"].last , parent_category2.id.to_s end end From 4b62667ad6fb5bb9000c5d33d65bd7ebc789ea0f Mon Sep 17 00:00:00 2001 From: MUH <58882014+muhammedBkf@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:04:48 +0100 Subject: [PATCH 09/10] Fix: Broken password reset after merging (ontologies_linked_data PR#159) + Add User sensitive data unit test (#98) * add a unit test for user sensitive data * explicitly load sensitive data in password reset * update Gemfile.lock --------- Co-authored-by: Syphax --- helpers/users_helper.rb | 4 +++- test/controllers/test_users_controller.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/helpers/users_helper.rb b/helpers/users_helper.rb index a9a14d30..082ebd94 100644 --- a/helpers/users_helper.rb +++ b/helpers/users_helper.rb @@ -40,7 +40,9 @@ def reset_password(email, username, token) user = LinkedData::Models::User.where(email: email, username: username).include(User.goo_attrs_to_load(includes_param)).first error 404, "User not found" unless user - + + user.bring(:resetToken) + user.bring(:passwordHash) user.show_apikey = true [user, token.eql?(user.resetToken)] diff --git a/test/controllers/test_users_controller.rb b/test/controllers/test_users_controller.rb index a165a5d7..be875249 100644 --- a/test/controllers/test_users_controller.rb +++ b/test/controllers/test_users_controller.rb @@ -148,6 +148,18 @@ def test_oauth_authentication end end + def test_hide_sensitive_data + user = @@users[0] + reset_token = "reset_password_token" + user.resetToken = reset_token + user.save + username = user.username + get "/users/#{username}?display=resetToken,passwordHash" + assert last_response.ok? + refute_includes MultiJson.load(last_response.body), 'resetToken', "resetToken should NOT be included in the response" + refute_includes MultiJson.load(last_response.body), 'passwordHash', "passwordHash should NOT be included in the response" + end + private def _create_admin_user(apikey: nil) user = {email: "#{@@username}@example.org", password: "pass_the_word", role: ['ADMINISTRATOR']} From 3fb29ce300e72d14620e4916b48aa93ac10c55e4 Mon Sep 17 00:00:00 2001 From: MUH <58882014+muhammedBkf@users.noreply.github.com> Date: Tue, 22 Oct 2024 01:34:02 +0100 Subject: [PATCH 10/10] Fix: remove file parameters when no file is uploaded (#99) Co-authored-by: Syphax --- helpers/ontology_helper.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/ontology_helper.rb b/helpers/ontology_helper.rb index 47816d49..3d82939e 100644 --- a/helpers/ontology_helper.rb +++ b/helpers/ontology_helper.rb @@ -20,8 +20,13 @@ def create_submission(ont) ont_submission.submissionId = submission_id # Get file info - add_file_to_submission(ont, ont_submission) - + filename, tmpfile = add_file_to_submission(ont, ont_submission) + # if no actual file was uploaded, we remove the file parameters + if filename.nil? && tmpfile.nil? + params.delete("uploadFilePath") + params.delete("diffFilePath") + end + # Add new format if it doesn't exist if ont_submission.hasOntologyLanguage.nil? error 422, "You must specify the ontology format using the `hasOntologyLanguage` parameter" if params["hasOntologyLanguage"].nil? || params["hasOntologyLanguage"].empty?