sources: simplify test_curl_source_amend_* tests a little bit
The `amend_secrets()` does not work with real files so there is no need to mock cachedirs or create fake input files. This commit just removes those. It also changes the checksum to `"1"*64` to make it very clear that the checksum has no significance in this test.
This commit is contained in:
parent
fe05b3084b
commit
fb701d6db5
1 changed files with 8 additions and 14 deletions
|
|
@ -16,7 +16,7 @@ def test_curl_source_not_exists(sources_service):
|
|||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
}
|
||||
checksum = "sha256:1234567890123456789012345678901234567890909b14ffb032aa20fa23d9ad6"
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
assert not sources_service.exists(checksum, desc)
|
||||
|
||||
|
||||
|
|
@ -26,14 +26,12 @@ def test_curl_source_exists(sources_service):
|
|||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
}
|
||||
checksum = "sha256:1234567890123456789012345678901234567890909b14ffb032aa20fa23d9ad6"
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
pathlib.Path(os.path.join(tmpdir.name, checksum)).touch()
|
||||
assert sources_service.exists(checksum, desc)
|
||||
|
||||
|
||||
def test_curl_source_amend_secrets(sources_service):
|
||||
tmpdir = tempfile.TemporaryDirectory()
|
||||
sources_service.cache = tmpdir.name
|
||||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
"secrets": {
|
||||
|
|
@ -49,25 +47,21 @@ def test_curl_source_amend_secrets(sources_service):
|
|||
del os.environ["OSBUILD_SOURCES_CURL_SSL_CLIENT_KEY"]
|
||||
del os.environ["OSBUILD_SOURCES_CURL_SSL_CLIENT_CERT"]
|
||||
cm.callback(cb)
|
||||
checksum = "sha256:1234567890123456789012345678901234567890909b14ffb032aa20fa23d9ad6"
|
||||
pathlib.Path(os.path.join(tmpdir.name, checksum)).touch()
|
||||
new_desc = sources_service.amend_secrets(checksum, desc)
|
||||
assert new_desc[1]["secrets"]["ssl_client_key"] == "key"
|
||||
assert new_desc[1]["secrets"]["ssl_client_cert"] == "cert"
|
||||
assert new_desc[1]["secrets"]["ssl_ca_cert"] is None
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
_, new_desc = sources_service.amend_secrets(checksum, desc)
|
||||
assert new_desc["secrets"]["ssl_client_key"] == "key"
|
||||
assert new_desc["secrets"]["ssl_client_cert"] == "cert"
|
||||
assert new_desc["secrets"]["ssl_ca_cert"] is None
|
||||
|
||||
|
||||
def test_curl_source_amend_secrets_fail(sources_service):
|
||||
tmpdir = tempfile.TemporaryDirectory()
|
||||
sources_service.cache = tmpdir.name
|
||||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
"secrets": {
|
||||
"name": "org.osbuild.mtls",
|
||||
},
|
||||
}
|
||||
checksum = "sha256:1234567890123456789012345678901234567890909b14ffb032aa20fa23d9ad6"
|
||||
pathlib.Path(os.path.join(tmpdir.name, checksum)).touch()
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
with pytest.raises(RuntimeError) as exc:
|
||||
sources_service.amend_secrets(checksum, desc)
|
||||
assert "mtls secrets required" in str(exc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue