Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Action fails upon authentication with SWORD API #213

Closed
JR-1991 opened this issue Aug 26, 2024 · 6 comments · Fixed by #214
Closed

GitHub Action fails upon authentication with SWORD API #213

JR-1991 opened this issue Aug 26, 2024 · 6 comments · Fixed by #214
Assignees
Labels
status:incoming Newly created issue to be forwarded type:bug Something isn't working
Milestone

Comments

@JR-1991
Copy link
Member

JR-1991 commented Aug 26, 2024

After merging the recent pull request #201 by @shoeffner, one test fails even though all checks have passed in the pull request CI, which is quite unexpected. I am opening this issue to keep track of this.

Failed run

=========================== short test summary info ============================
FAILED tests/api/test_api.py::TestApiToken::test_sword_api_can_authenticate - assert 400 == 200
 +  where 400 = <Response [400 Bad Request]>.status_code
================== 1 failed, 79 passed, 65 warnings in 21.12s ==================
@JR-1991 JR-1991 added type:bug Something isn't working status:incoming Newly created issue to be forwarded labels Aug 26, 2024
@JR-1991 JR-1991 added this to the 0.3.4 milestone Aug 26, 2024
@JR-1991 JR-1991 self-assigned this Aug 26, 2024
@JR-1991
Copy link
Member Author

JR-1991 commented Aug 26, 2024

I dont know why, but it seems like there are some bots spamming sketchy Mediafire links to PRs (see microsoft/vscode#226578 for sth similar). I have hidden the comments and advise to NOT click the links supplied.

@shoeffner
Copy link
Collaborator

shoeffner commented Aug 26, 2024 via email

@shoeffner
Copy link
Collaborator

I checked out the main branch but cannot reproduce the test failure locally with the docker-compose setup. Maybe the CI runs against a different Dataverse version? I'll try against the dataverse demo instance later...

@JR-1991
Copy link
Member Author

JR-1991 commented Aug 28, 2024

I can confirm that I wasn't able to reproduce the error using a local instance. To investigate further, I created a fork and hard-coded DV_VERSION: 6.3 into the workflow to see if the action might be using version 6.4 instead, since some tests explicitly check the DV version. Interestingly, all tests, except the one failing in this issue, ran successfully.

I also tested against https://demo.dataverse.org, and the test failed there as well. I looked into it further and, out of curiosity, I wrote a script to perform the test "manually".

auth = httpx.BasicAuth("<TOKEN>", "")
response = httpx.get(
     "https://demo.dataverse.org/dvn/api/data-deposit/v1.1/swordv2/service-document",
     auth=auth,
)

This is where I discovered that the SSL certificate for demo.dataverse had expired, causing the request to fail since httpx typically verifies if a certificate is valid. @pdurbin you may already be aware of this, but I am tagging you here. While this resolved the issue for demo.dataverse, I am not comfortable with setting verify=False, as it defeats the purpose of SSL. At least this confirms that the code itself is functioning correctly, but I’m still puzzled as to why it only fails within the GitHub Workflow.

I didn't stop there and applied the "manual" test from earlier into a fork of mine, and voilà, everything worked. Here is the test I overwrote in my fork:

def test_sword_api_can_authenticate(self):
BASE_URL = os.getenv("BASE_URL")
API_TOKEN = os.getenv("API_TOKEN")
# api = SwordApi(BASE_URL, api_token=API_TOKEN)
# response = api.get_service_document()
assert API_TOKEN is not None, "API_TOKEN is not set"
assert len(API_TOKEN) > 0, "API_TOKEN is not set"
auth = httpx.BasicAuth(API_TOKEN, "")
response = httpx.get(
"http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/service-document",
auth=auth,
)
assert response.status_code == 200

For the grand finale, I restored everything and printed the actual URL being used, and believe it or not, the whole error stemmed from a wrong URL where there was // instead of / in http://localhost:8080//dvn/api/data-deposit/v1.1/swordv2/service-document. I'm relieved it was something so simple 😁

@pdurbin
Copy link
Member

pdurbin commented Aug 28, 2024

the SSL certificate for demo.dataverse had expired

Yes, sorry, our wildcard cert expired. We are rolling out the new one now. The guides server has been fixed. demo soon, I suspect.

@pdurbin
Copy link
Member

pdurbin commented Aug 28, 2024

Weird about the double slash. Thanks for fixing it! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:incoming Newly created issue to be forwarded type:bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

5 participants
@pdurbin @shoeffner @JR-1991 and others