diff --git a/.env.example b/.env.example index f799524e9..544836cb4 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,71 @@ + +# Passenger +PASSENGER_MAX_POOL_SIZE=5 + +# DB +MYSQL_DATABASE=datacite +MYSQL_USER=root +MYSQL_PASSWORD= +MYSQL_HOST=mysql +MYSQL_PORT=3306 +MYSQL_ALLOW_EMPTY_PASSWORD=true + +# Logging +LOG_LEVEL=info +ADMIN_USERNAME=root +ADMIN_PASSWORD= + # Authentication +SESSION_ENCRYPTED_COOKIE_SALT= +SECRET_KEY_BASE= JWT_PUBLIC_KEY= +JWT_TOKEN= +JWT_TOKEN_EXPIRED= JWT_PRIVATE_KEY= -# AWS SQS queue +# AWS AWS_REGION= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= + +SITE_TITLE=DataCite API +PASSENGER_MAX_POOL_SIZE=5 +APP_URL=app.stage.datacite.org +ES_HOST=elasticsearch:9200 + +# Mailgun +MAILGUN_API_KEY= +MG_DOMAIN=mg.datacite.org + +# Needed for tests +MDS_USERNAME= +MDS_PASSWORD= + +CONCURRENCY=25 +INTEGRATION=1 # Set this environment variable to run the integration tests +REFRESH=true + +STAFF_ADMIN_PASSWORD= +ORGANIZATION_ADMIN_PASSWORD= +CONSORTIUM_ADMIN_PASSWORD= +CLIENT_ADMIN_PASSWORD= + +# Handle server config +HANDLE_URL=https://handle.test.datacite.org +HANDLE_USERNAME= +HANDLE_PASSWORD= + +# Set to the URL for the test handle server +HS_REST_URL=https://localhost:8000/api/handles/ +# Set to a homed prefix for the test handle server (including the trailing '/') +HS_PREFIX=9999/ + +# Set to appropriate credentials for a user that can create handles in the +# given prefix. Currently, the API only supports password ('secret key') +# authentication. +HS_USER=1234.TEST/ADMIN +HS_SECKEY=password + +# Set to 0 if the test handle server has a self-signed or otherwise invalid SSL +# certificate +HS_SSL_VERIFY=0 \ No newline at end of file diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index ef1fd8a8c..4805cd505 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -12,6 +12,12 @@ module Indexable IndexJob.perform_later(self) else __elasticsearch__.index_document + # This is due to the order of indexing, we want to always ensure + # the prefix index is up to date with relations + # So we force it here to reindex prefix if we touch them. + if ["ProviderPrefix", "ClientPrefix"].include?(self.class.name) + self.prefix.__elasticsearch__.index_document + end end if ( diff --git a/app/serializers/datacite_doi_serializer.rb b/app/serializers/datacite_doi_serializer.rb index 98897079d..d3414694a 100644 --- a/app/serializers/datacite_doi_serializer.rb +++ b/app/serializers/datacite_doi_serializer.rb @@ -126,6 +126,7 @@ class DataciteDoiSerializer Array.wrap(c["affiliation"]).map do |a| params[:affiliation] ? a : a["name"] end.compact + c["nameIdentifiers"] = Array.wrap(c["nameIdentifiers"]) c end.compact end diff --git a/spec/requests/datacite_dois_spec.rb b/spec/requests/datacite_dois_spec.rb index 60e3281c8..dc5309bb5 100644 --- a/spec/requests/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois_spec.rb @@ -350,6 +350,7 @@ "nameType" => "Personal", "name" => "John Doe", "affiliation" => [], + "nameIdentifiers" => [], }) end @@ -360,6 +361,28 @@ expect(json.dig("data", "attributes", "creators")).to eq([doi.creators]) end end + + context "nameIdentifiers started as an object not array" do + let(:doi) do + create(:doi, client: client, creators: + [{ + "nameType" => "Personal", + "name" => "John Doe", + "affiliation" => [], + "nameIdentifiers": { + "nameIdentifier": "http://viaf.org/viaf/4934600", + "nameIdentifierScheme": "VIAF" + }, + }]) + end + + it "returns the nameIdentifiers as list" do + get "/dois/#{doi.doi}", nil, headers + + expect(last_response.status).to eq(200) + expect(json.dig("data", "attributes", "creators", 0, "nameIdentifiers")).to eq([{ "nameIdentifier" => "http://viaf.org/viaf/4934600", "nameIdentifierScheme" => "VIAF"}]) + end + end end describe "GET /dois for dissertations", elasticsearch: true, vcr: true do @@ -1357,7 +1380,7 @@ context "when the creators change" do let(:xml) { Base64.strict_encode64(file_fixture("datacite.xml").read) } - let(:creators) { [{ "affiliation" => [], "name" => "Ollomi, Benjamin" }, { "affiliation" => [], "name" => "Duran, Patrick" }] } + let(:creators) { [{ "affiliation" => [], "nameIdentifiers" => [], "name" => "Ollomi, Benjamin" }, { "affiliation" => [], "nameIdentifiers" => [], "name" => "Duran, Patrick" }] } let(:valid_attributes) do { "data" => { @@ -2472,7 +2495,7 @@ end context "when the creators change" do - let(:creators) { [{ "affiliation" => [], "name" => "Ollomi, Benjamin" }, { "affiliation" => [], "name" => "Duran, Patrick" }] } + let(:creators) { [{ "affiliation" => [], "nameIdentifiers" => [], "name" => "Ollomi, Benjamin" }, { "affiliation" => [], "nameIdentifiers" => [], "name" => "Duran, Patrick" }] } let(:xml) { Base64.strict_encode64(file_fixture("datacite.xml").read) } let(:valid_attributes) do { @@ -3188,7 +3211,7 @@ end context "update multiple affiliations" do - let(:creators) { [{ "name" => "Ollomi, Benjamin", "affiliation" => [{ "name" => "Cambridge University" }, { "name" => "EMBL-EBI" }] }] } + let(:creators) { [{ "name" => "Ollomi, Benjamin", "affiliation" => [{ "name" => "Cambridge University" }, { "name" => "EMBL-EBI" }], "nameIdentifiers" => [] }] } let(:update_attributes) do { "data" => {