diff --git a/spec/fixtures/vcr_cassettes/Person/find_by_id/account_locked.yml b/spec/fixtures/vcr_cassettes/Person/find_by_id/account_locked.yml new file mode 100644 index 000000000..0cdf2d8d2 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Person/find_by_id/account_locked.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: get + uri: https://pub.orcid.org/v3.0/0000-0003-1315-5960/person + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.2; mailto:info@datacite.org) + Accept: + - application/json;charset=UTF-8 + response: + status: + code: 409 + message: Conflict + headers: + Server: + - nginx/1.16.1 + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json;charset=UTF-8 + Date: + - Thu, 27 Aug 2020 16:28:00 GMT + Expires: + - '0' + Pragma: + - no-cache + X-Xss-Protection: + - 1; mode=block + Access-Control-Allow-Origin: + - "*" + X-Content-Type-Options: + - nosniff + Connection: + - keep-alive + Set-Cookie: + - X-Mapping-fjhppofk=26484D0F5DA32D2D6AF64AA1C9DBBA16; path=/ + X-Frame-Options: + - DENY + body: + encoding: ASCII-8BIT + string: '{"response-code":409,"developer-message":"409 Conflict: The ORCID record + is locked and cannot be edited. ORCID https://orcid.org/0000-0003-1315-5960","user-message":"The + ORCID record is locked.","error-code":9018,"more-info":"https://members.orcid.org/api/resources/troubleshooting"}' + http_version: null + recorded_at: Thu, 27 Aug 2020 16:28:00 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/Person/find_by_id/found_with_error.yml b/spec/fixtures/vcr_cassettes/Person/find_by_id/found_with_error.yml new file mode 100644 index 000000000..97c034536 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Person/find_by_id/found_with_error.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: get + uri: https://pub.orcid.org/v3.0/0000-0003-1315-5960/person + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.2; mailto:info@datacite.org) + Accept: + - application/json;charset=UTF-8 + response: + status: + code: 409 + message: Conflict + headers: + Server: + - nginx/1.16.1 + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json;charset=UTF-8 + Date: + - Thu, 27 Aug 2020 16:24:46 GMT + Expires: + - '0' + Pragma: + - no-cache + X-Xss-Protection: + - 1; mode=block + Access-Control-Allow-Origin: + - "*" + X-Content-Type-Options: + - nosniff + Connection: + - keep-alive + Set-Cookie: + - X-Mapping-fjhppofk=1F5FD8D0B8B1A8DD0F8680D854A2C10B; path=/ + X-Frame-Options: + - DENY + body: + encoding: ASCII-8BIT + string: '{"response-code":409,"developer-message":"409 Conflict: The ORCID record + is locked and cannot be edited. ORCID https://orcid.org/0000-0003-1315-5960","user-message":"The + ORCID record is locked.","error-code":9018,"more-info":"https://members.orcid.org/api/resources/troubleshooting"}' + http_version: null + recorded_at: Thu, 27 Aug 2020 16:24:47 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/PersonType/find_person_account_locked/returns_error.yml b/spec/fixtures/vcr_cassettes/PersonType/find_person_account_locked/returns_error.yml new file mode 100644 index 000000000..612db6778 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/PersonType/find_person_account_locked/returns_error.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: get + uri: https://pub.orcid.org/v3.0/0000-0003-1315-5960/person + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.2; mailto:info@datacite.org) + Accept: + - application/json;charset=UTF-8 + response: + status: + code: 409 + message: Conflict + headers: + Server: + - nginx/1.16.1 + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json;charset=UTF-8 + Date: + - Thu, 27 Aug 2020 16:30:40 GMT + Expires: + - '0' + Pragma: + - no-cache + X-Xss-Protection: + - 1; mode=block + Access-Control-Allow-Origin: + - "*" + X-Content-Type-Options: + - nosniff + Connection: + - keep-alive + Set-Cookie: + - X-Mapping-fjhppofk=EDEB8B375DA428655747278237992826; path=/ + X-Frame-Options: + - DENY + body: + encoding: ASCII-8BIT + string: '{"response-code":409,"developer-message":"409 Conflict: The ORCID record + is locked and cannot be edited. ORCID https://orcid.org/0000-0003-1315-5960","user-message":"The + ORCID record is locked.","error-code":9018,"more-info":"https://members.orcid.org/api/resources/troubleshooting"}' + http_version: null + recorded_at: Thu, 27 Aug 2020 16:30:40 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/graphql/types/person_type_spec.rb b/spec/graphql/types/person_type_spec.rb index f21721923..fea0f38be 100644 --- a/spec/graphql/types/person_type_spec.rb +++ b/spec/graphql/types/person_type_spec.rb @@ -177,6 +177,64 @@ end end + describe "find person account locked", elasticsearch: true, vcr: true do + let(:query) do + %(query { + person(id: "https://orcid.org/0000-0003-1315-5960") { + id + name + givenName + familyName + alternateName + description + links { + name + url + } + identifiers { + identifier + identifierType + identifierUrl + } + country { + id + name + } + citationCount + viewCount + downloadCount + works { + totalCount + published { + id + title + count + } + resourceTypes { + id + title + count + } + nodes { + id + titles { + title + } + citationCount + } + } + } + }) + end + + it "returns error" do + response = LupoSchema.execute(query).as_json + puts response + expect(response.dig("data")).to be_nil + expect(response.dig("errors")).to eq([{"locations"=>[{"column"=>9, "line"=>2}], "message"=>"409 Conflict: The ORCID record is locked and cannot be edited. ORCID https://orcid.org/0000-0003-1315-5960", "path"=>["person"]}]) + end + end + describe "query people", elasticsearch: true, vcr: true do let(:query) do %(query { diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 71b28db4d..4f4908f87 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -79,6 +79,11 @@ expect(person.country).to be_nil end + it "account locked" do + id = "https://orcid.org/0000-0003-1315-5960" + expect { Person.find_by_id(id) }.to raise_error(Faraday::ClientError, /ORCID record is locked/) + end + it "not found" do id = "https://orcid.org/xxxxx" people = Person.find_by_id(id)