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

Fix API token URL generation #547

Merged
merged 2 commits into from
Feb 6, 2023
Merged

Conversation

dataclouder
Copy link
Contributor

@dataclouder dataclouder commented Feb 3, 2023

The API token URL was created by removing "/api" from the client URL. This method fails when the URL host name starts with "api". (Issue #994)

The new method uses a more robust approach, by combining the existing elements of the client URL.

To test that the API token works, set an API token in your VCD, and then:

export TEST_VCD_ORG=System 
export TEST_VCD_API_TOKEN=$YOUR_API_TOKEN 
go test -tags api -check.f TestVCDClient_GetBearerTokenFromApiToken -check.vv -timeout 0

unset TEST_VCD_ORG
unset TEST_VCD_API_TOKEN

The API token URL was created by removing "/api" from the client URL.
This method fails when the URL host part starts with "api".

The new methid uses a more robust approach.

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
@dataclouder dataclouder marked this pull request as ready for review February 3, 2023 05:52
@dataclouder dataclouder requested a review from adezxc February 3, 2023 05:52
@dataclouder dataclouder self-assigned this Feb 3, 2023
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Test worked.

Copy link
Collaborator

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, thanks!

@dataclouder dataclouder merged commit 384b6a5 into vmware:main Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants