Skip to content

Commit

Permalink
Update test_expected_errors.py
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro authored Oct 10, 2023
1 parent b593547 commit 2a18efc
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions orcid/test_expected_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,26 @@ def test_update_record2_from_other_source(self):
delete_response = self.delete_activity("/v2.0/", putcode, "work")
self.assertTrue("HTTP/1.1 204" in delete_response, "Delete Action Response: " + delete_response + " using putcode [%s]" % str(putcode))

def test_member_http_read_20(self):
# This test is outdated, going forward we expect a 301 when doing a HTTP to HTTPS redirect because AWS+Cloudflare include the headers in the redirect
#def test_member_http_read_20(self):
#Test making a call with 2.0 API using http not https returns the expected '521 Origin Down' error
curl_params = ['-H', "Accept: application/xml", '-H', 'Authorization: Bearer ' + self.static_access, '-L', '-i', '-k', '-X', 'GET']
response = self.orcid_curl("http://pub." + properties.test_server + "/v2.0/" + self.static_orcid_id + "/record", curl_params)
codeStart = response.find("HTTP/1.1 ")
codeEnd = codeStart + 12
self.assertTrue(response[codeStart:codeEnd].strip() in ["HTTP/1.1 522", "HTTP/1.1 521", "HTTP/1.1 400"], "Expected error code '521' or '400', instead: " + response)
#curl_params = ['-H', "Accept: application/xml", '-H', 'Authorization: Bearer ' + self.static_access, '-L', '-i', '-k', '-X', 'GET']
#response = self.orcid_curl("http://pub." + properties.test_server + "/v2.0/" + self.static_orcid_id + "/record", curl_params)
#codeStart = response.find("HTTP/1.1 ")
#codeEnd = codeStart + 12
#self.assertTrue(response[codeStart:codeEnd].strip() in ["HTTP/1.1 522", "HTTP/1.1 521", "HTTP/1.1 400"], "Expected error code '521' or '400', instead: " + response)

def test_member_http_read_21(self):
# This test is outdated, going forward we expect a 301 when doing a HTTP to HTTPS redirect because AWS+Cloudflare include the headers in the redirect
#def test_member_http_read_21(self):
#Test making a call with 2.1 API using http not https returns the expected '521 Origin Down' error
curl_params = ['-H', "Accept: application/xml", '-H', 'Authorization: Bearer ' + self.static_access, '-L', '-i', '-k', '-X', 'GET']
response = self.orcid_curl("http://pub." + properties.test_server + "/v2.1/" + self.static_orcid_id + "/record", curl_params)
codeStart = response.find("HTTP/1.1 ")
codeEnd = codeStart + 12
self.assertTrue(response[codeStart:codeEnd].strip() in ["HTTP/1.1 522", "HTTP/1.1 521", "HTTP/1.1 400"], "Expected error code '521' or '400', instead: " + response)
#curl_params = ['-H', "Accept: application/xml", '-H', 'Authorization: Bearer ' + self.static_access, '-L', '-i', '-k', '-X', 'GET']
#response = self.orcid_curl("http://pub." + properties.test_server + "/v2.1/" + self.static_orcid_id + "/record", curl_params)
#codeStart = response.find("HTTP/1.1 ")
#codeEnd = codeStart + 12
#self.assertTrue(response[codeStart:codeEnd].strip() in ["HTTP/1.1 522", "HTTP/1.1 521", "HTTP/1.1 400"], "Expected error code '521' or '400', instead: " + response)

def test_nonexisting_record(self):
#Confirm that the response type is 404 when fetching a non-existing record
curl_params = ['-H', 'Content-Type: application/orcid+xml', '-H', 'Accept: application/xml','-L', '-i', '-k', '-X', 'GET']
response = self.orcid_curl("https://%s/%s" % (self.test_server, self.invalid_id), curl_params)
self.assertTrue("HTTP/1.1 404" in response, "Non 404 returned: " + response)
self.assertTrue("HTTP/1.1 404" in response, "Non 404 returned: " + response)

0 comments on commit 2a18efc

Please sign in to comment.