Skip to content
Snippets Groups Projects
Commit 4a869664 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

tests/artifactcache/config.py: Added test for invalid push remote configuration

Test that we get the expected error when configuring a client-cert
without client-key, or the inverse.
parent 0c426cb4
No related branches found
No related tags found
Loading
Pipeline #30477671 failed
...@@ -9,8 +9,12 @@ from buildstream._context import Context ...@@ -9,8 +9,12 @@ from buildstream._context import Context
from buildstream._project import Project from buildstream._project import Project
from buildstream.utils import _deduplicate from buildstream.utils import _deduplicate
from buildstream import _yaml from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from tests.testutils.runcli import cli
DATA_DIR = os.path.dirname(os.path.realpath(__file__))
cache1 = ArtifactCacheSpec(url='https://example.com/cache1', push=True) cache1 = ArtifactCacheSpec(url='https://example.com/cache1', push=True)
cache2 = ArtifactCacheSpec(url='https://example.com/cache2', push=False) cache2 = ArtifactCacheSpec(url='https://example.com/cache2', push=False)
cache3 = ArtifactCacheSpec(url='https://example.com/cache3', push=False) cache3 = ArtifactCacheSpec(url='https://example.com/cache3', push=False)
...@@ -106,3 +110,33 @@ def test_artifact_cache_precedence(tmpdir, override_caches, project_caches, user ...@@ -106,3 +110,33 @@ def test_artifact_cache_precedence(tmpdir, override_caches, project_caches, user
# Verify that it was correctly read. # Verify that it was correctly read.
expected_cache_specs = list(_deduplicate(itertools.chain(override_caches, project_caches, user_caches))) expected_cache_specs = list(_deduplicate(itertools.chain(override_caches, project_caches, user_caches)))
assert parsed_cache_specs == expected_cache_specs assert parsed_cache_specs == expected_cache_specs
# Assert that if either the client key or client cert is specified
# without specifying it's counterpart, we get a comprehensive LoadError
# instead of an unhandled exception.
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize('config_key, config_value', [
('client-cert', 'client.crt'),
('client-key', 'client.key')
])
def test_missing_certs(cli, datafiles, config_key, config_value):
project = os.path.join(datafiles.dirname, datafiles.basename, 'missing-certs')
project_conf = {
'name': 'test',
'artifacts': {
'url': 'https://cache.example.com:12345',
'push': 'true',
config_key: config_value
}
}
project_conf_file = os.path.join (project, 'project.conf')
_yaml.dump(project_conf, project_conf_file)
# Use `pull` here to ensure we try to initialize the remotes, triggering the error
#
# This does not happen for a simple `bst show`.
result = cli.run(project=project, args=['pull', 'element.bst'])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
kind: autotools
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment