-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/datacite/lupo
- Loading branch information
Showing
2 changed files
with
105 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"data": { | ||
"id": "10.23725/at5e-0s42", | ||
"attributes": { | ||
"identifier": "https://handle.test.datacite.org/10.23725/at5e-0s42", | ||
"doi": "10.23725/at5e-0s42", | ||
"confirm-doi": null, | ||
"prefix": "10.23725", | ||
"suffix": "at5e-0s42", | ||
"url": "http://example.com", | ||
"author": [{ | ||
"type": "Person", | ||
"id": "https://orcid.org/0000-0003-1419-2405", | ||
"name": "Fenner, Martin", | ||
"givenName": "Martin", | ||
"familyName": "Fenner" | ||
}], | ||
"title": "Eating your own Dog Food", | ||
"publisher": "DataCite", | ||
"published": "2016", | ||
"description": "Eating your own dog food is a slang term to describe that an organization should itself use the products and services it provides. For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...", | ||
"license": null, | ||
"xml": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG5zMDpyZXNvdXJjZSB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczpuczA9Imh0dHA6Ly9kYXRhY2l0ZS5vcmcvc2NoZW1hL2tlcm5lbC00IiB4c2k6c2NoZW1hTG9jYXRpb249Imh0dHA6Ly9kYXRhY2l0ZS5vcmcvc2NoZW1hL2tlcm5lbC00IGh0dHA6Ly9zY2hlbWEuZGF0YWNpdGUub3JnL21ldGEva2VybmVsLTQvbWV0YWRhdGEueHNkIj4KICA8bnMwOmlkZW50aWZpZXIgaWRlb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6dmVyc2lvbj4KICA8bnMwOmRlc2NyaXB0aW9ucz4KICAgIDxuczA6ZGVzY3JpcHRpb24gZGVzY3JpcHRpb25UeXBlPSJBYnN0cmFjdCI+RWF0aW5nIHlvdXIgb3duIGRvZyBmb29kIGlzIGEgc2xhbmcgdGVybSB0byBkZXNjcmliZSB0aGF0IGFuIG9yZ2FuaXphdGlvbiBzaG91bGQgaXRzZWxmIHVzZSB0aGUgcHJvZHVjdHMgYW5kIHNlcnZpY2VzIGl0IHByb3ZpZGVzLiBGb3IgRGF0YUNpdGUgdGhpcyBtZWFucyB0aGF0IHdlIHNob3VsZCB1c2UgRE9JcyB3aXRoIGFwcHJvcHJpYXRlIG1ldGFkYXRhIGFuZCBzdHJhdGVnaWVzIGZvciBsb25nLXRlcm0gcHJlc2VydmF0aW9uIGZvci4uLjwvbnMwOmRlc2NyaXB0aW9uPgogIDwvbnMwOmRlc2NyaXB0aW9ucz4KPC9uczA6cmVzb3VyY2U+", | ||
"resource-type-subtype": "BlogPosting", | ||
"version": "1.0", | ||
"metadata-version": "1", | ||
"schema-version": "http://datacite.org/schema/kernel-4", | ||
"is-active": true, | ||
"source": "mds", | ||
"state": "findable", | ||
"event": null, | ||
"created": "2018-08-29T13:45:34.000Z", | ||
"registered": "2018-08-29T14:07:53.000Z", | ||
"updated": "2018-08-29T14:07:53.000Z", | ||
"mode": "transfer" | ||
}, | ||
"relationships": { | ||
"client": { | ||
"data": { | ||
"type": "clients", | ||
"id": "datacite.magic" | ||
} | ||
}, | ||
"resource-type": { | ||
"data": { | ||
"type": "resource-types", | ||
"id": "text" | ||
} | ||
} | ||
}, | ||
"type": "dois" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,56 +375,63 @@ | |
end | ||
end | ||
|
||
# context 'when we transfer a DOI as provider' do | ||
# let(:provider_bearer) { User.generate_token(role_id: "provider_admin", uid: provider.symbol.downcase, password: provider.password) } | ||
# let(:provider_headers) { {'ACCEPT'=>'application/vnd.api+json', 'CONTENT_TYPE'=>'application/vnd.api+json', 'Authorization' => 'Bearer ' + provider_bearer}} | ||
context 'fail when we transfer a DOI as provider' do | ||
|
||
# let(:doi) { create(:doi, client: client) } | ||
# let(:new_client) { create(:client, symbol: "#{provider.symbol}.magic", provider: provider, password: ENV['MDS_PASSWORD']) } | ||
# let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) } | ||
# let(:valid_attributes) do | ||
# { | ||
# "data" => { | ||
# "type" => "dois", | ||
# "attributes" => { | ||
# "url" => "http://www.bl.uk/pdf/pat.pdf", | ||
# "xml" => xml | ||
# }, | ||
# "relationships"=> { | ||
# "client"=> { | ||
# "data"=> { | ||
# "type"=> "clients", | ||
# "id"=> new_client.symbol.downcase | ||
# } | ||
# }, | ||
# "provider"=> { | ||
# "data"=> { | ||
# "type"=> "providers", | ||
# "id"=> provider.symbol.downcase | ||
# } | ||
# } | ||
# } | ||
# } | ||
# } | ||
# end | ||
let(:provider_bearer) { User.generate_token(uid: "datacite", role_id: "provider_admin", name: "DataCite", email:"[email protected]", provider_id: "datacite") } | ||
let(:provider_headers) { {'ACCEPT'=>'application/vnd.api+json', 'CONTENT_TYPE'=>'application/vnd.api+json', 'Authorization' => 'Bearer ' + provider_bearer}} | ||
|
||
# before { put "/dois/#{doi.doi}", params: valid_attributes.to_json, headers: provider_headers } | ||
let(:doi) { create(:doi, client: client) } | ||
let(:new_client) { create(:client, symbol: "#{provider.symbol}.magic", provider: provider, password: ENV['MDS_PASSWORD']) } | ||
## Attributes MUST be empty | ||
let(:valid_attributes) {file_fixture('transfer.json').read } | ||
|
||
# it 'returns no errors' do | ||
# # puts provider_bearer | ||
# puts Client.where(symbol: new_client.symbol.downcase).inspect | ||
# puts Client.where(symbol: client.symbol.downcase).inspect | ||
# puts Provider.where(symbol: provider.symbol.downcase).inspect | ||
# expect(response).to have_http_status(200) | ||
# expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi) | ||
# end | ||
before { put "/dois/#{doi.doi}", params: valid_attributes, headers: provider_headers } | ||
|
||
# it 'updates the client id' do | ||
# expect(json.dig('data', 'relationships', 'client','data','id')).to eq(new_client.symbol.downcase) | ||
# end | ||
# end | ||
it 'returns no errors' do | ||
expect(response).to have_http_status(403) | ||
end | ||
end | ||
|
||
context 'passeswhen we transfer a DOI as provider' do | ||
|
||
let(:provider_bearer) { User.generate_token(uid: "datacite", role_id: "provider_admin", name: "DataCite", email:"[email protected]", provider_id: "datacite") } | ||
let(:provider_headers) { {'ACCEPT'=>'application/vnd.api+json', 'CONTENT_TYPE'=>'application/vnd.api+json', 'Authorization' => 'Bearer ' + provider_bearer}} | ||
|
||
let(:doi) { create(:doi, client: client) } | ||
let(:new_client) { create(:client, symbol: "#{provider.symbol}.magic", provider: provider, password: ENV['MDS_PASSWORD']) } | ||
## Attributes MUST be empty | ||
let(:valid_attributes) do | ||
{ | ||
"data" => { | ||
"type" => "dois", | ||
"attributes" => { | ||
}, | ||
"relationships"=> { | ||
"client"=> { | ||
"data"=> { | ||
"type"=> "clients", | ||
"id"=> new_client.symbol.downcase | ||
} | ||
} | ||
} | ||
} | ||
} | ||
end | ||
|
||
before { put "/dois/#{doi.doi}", params: valid_attributes.to_json, headers: provider_headers } | ||
|
||
it 'returns no errors' do | ||
expect(response).to have_http_status(200) | ||
expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi.downcase) | ||
end | ||
|
||
it 'updates the client id' do | ||
expect(json.dig('data', 'relationships', 'client','data','id')).to eq(new_client.symbol.downcase) | ||
expect(json.dig('data', 'attributes', 'title')).to eq(doi.title) | ||
end | ||
end | ||
|
||
context 'when we transfer a DOI as staff' do | ||
context 'when we transfer a DOI as staff' do | ||
let(:doi) { create(:doi, doi: "10.24425/119495", client: client, state: "registered") } | ||
let(:new_client) { create(:client, symbol: "#{provider.symbol}.magic", provider: provider, password: ENV['MDS_PASSWORD']) } | ||
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) } | ||
|