From 2a18efcb366ee0ad1351ec377e73d8aab48205a3 Mon Sep 17 00:00:00 2001 From: Angel Montenegro Date: Tue, 10 Oct 2023 08:21:22 -0600 Subject: [PATCH] Update test_expected_errors.py --- orcid/test_expected_errors.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/orcid/test_expected_errors.py b/orcid/test_expected_errors.py index aa4efbd..69fa153 100644 --- a/orcid/test_expected_errors.py +++ b/orcid/test_expected_errors.py @@ -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) \ No newline at end of file + self.assertTrue("HTTP/1.1 404" in response, "Non 404 returned: " + response)