Merge pull request #65786 from dmurphy18/fix_63063

[3006.x] Fix credentials encoding for Artifactory
This commit is contained in:
Shane Lee 2024-01-04 14:38:02 -07:00 committed by GitHub
commit d1a3b3ef6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

1
changelog/63063.fixed.md Normal file
View file

@ -0,0 +1 @@
Corrected encoding of credentials for use with Artifactory

View file

@ -79,7 +79,7 @@ def get_latest_snapshot(
headers = {}
if username and password:
headers["Authorization"] = "Basic {}".format(
salt.utils.hashutils.base64_encodestring(
salt.utils.hashutils.base64_b64encode(
"{}:{}".format(username.replace("\n", ""), password.replace("\n", ""))
)
)
@ -165,7 +165,7 @@ def get_snapshot(
headers = {}
if username and password:
headers["Authorization"] = "Basic {}".format(
salt.utils.hashutils.base64_encodestring(
salt.utils.hashutils.base64_b64encode(
"{}:{}".format(username.replace("\n", ""), password.replace("\n", ""))
)
)
@ -238,7 +238,7 @@ def get_latest_release(
headers = {}
if username and password:
headers["Authorization"] = "Basic {}".format(
salt.utils.hashutils.base64_encodestring(
salt.utils.hashutils.base64_b64encode(
"{}:{}".format(username.replace("\n", ""), password.replace("\n", ""))
)
)
@ -320,8 +320,9 @@ def get_release(
headers = {}
if username and password:
headers["Authorization"] = "Basic {}".format(
salt.utils.hashutils.base64_encodestring(
salt.utils.hashutils.base64_b64encode(
"{}:{}".format(username.replace("\n", ""), password.replace("\n", ""))
## f"{username.replace("\n", "")}:{password.replace("\n", "")}")
)
)
release_url, file_name = _get_release_url(

View file

@ -278,7 +278,7 @@ def test_get_latest_snapshot_username_password():
save_artifact_mock.assert_called_with(
"http://artifactory.example.com/artifactory/snapshot",
"/path/to/file",
{"Authorization": "Basic dXNlcjpwYXNzd29yZA==\n"},
{"Authorization": "Basic dXNlcjpwYXNzd29yZA=="},
)
@ -305,7 +305,7 @@ def test_get_snapshot_username_password():
save_artifact_mock.assert_called_with(
"http://artifactory.example.com/artifactory/snapshot",
"/path/to/file",
{"Authorization": "Basic dXNlcjpwYXNzd29yZA==\n"},
{"Authorization": "Basic dXNlcjpwYXNzd29yZA=="},
)
@ -334,7 +334,7 @@ def test_get_latest_release_username_password():
save_artifact_mock.assert_called_with(
"http://artifactory.example.com/artifactory/release",
"/path/to/file",
{"Authorization": "Basic dXNlcjpwYXNzd29yZA==\n"},
{"Authorization": "Basic dXNlcjpwYXNzd29yZA=="},
)
@ -361,7 +361,7 @@ def test_get_release_username_password():
save_artifact_mock.assert_called_with(
"http://artifactory.example.com/artifactory/release",
"/path/to/file",
{"Authorization": "Basic dXNlcjpwYXNzd29yZA==\n"},
{"Authorization": "Basic dXNlcjpwYXNzd29yZA=="},
)