1
0
mirror of https://github.com/quay/quay.git synced 2026-01-27 18:42:52 +03:00
Files
quay/endpoints/api/test/test_secscan.py
2022-03-22 11:12:39 -04:00

45 lines
1.5 KiB
Python

import base64
import pytest
from mock import patch
from data.registry_model import registry_model
from endpoints.test.shared import gen_basic_auth
from endpoints.api.test.shared import conduct_api_call
from endpoints.api.secscan import RepositoryManifestSecurity
from test.fixtures import *
@pytest.mark.parametrize(
"endpoint, anonymous_allowed, auth_headers, expected_code",
[
pytest.param(RepositoryManifestSecurity, True, gen_basic_auth("devtable", "password"), 200),
pytest.param(
RepositoryManifestSecurity, False, gen_basic_auth("devtable", "password"), 200
),
pytest.param(RepositoryManifestSecurity, True, None, 401),
pytest.param(RepositoryManifestSecurity, False, None, 401),
],
)
def test_get_security_info_with_pull_secret(
endpoint, anonymous_allowed, auth_headers, expected_code, client
):
with patch("features.ANONYMOUS_ACCESS", anonymous_allowed):
repository_ref = registry_model.lookup_repository("devtable", "simple")
tag = registry_model.get_repo_tag(repository_ref, "latest")
manifest = registry_model.get_manifest_for_tag(tag)
params = {
"repository": "devtable/simple",
"manifestref": manifest.digest,
}
headers = {}
if auth_headers is not None:
headers["Authorization"] = auth_headers
conduct_api_call(
client, endpoint, "GET", params, None, headers=headers, expected_code=expected_code
)