Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 18, 2021
2 parents d46e3bb + 736e8f0 commit b2b9426
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 4 deletions.
65 changes: 64 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions app/serializers/datacite_doi_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions spec/requests/datacite_dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"nameType" => "Personal",
"name" => "John Doe",
"affiliation" => [],
"nameIdentifiers" => [],
})
end

Expand All @@ -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
Expand Down Expand Up @@ -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" => {
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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" => {
Expand Down

0 comments on commit b2b9426

Please sign in to comment.