zuul/tests/unit
James E. Blair be50a6ca42 Freeze job variables at start of build
Freze Zuul job variables when starting a build so that jinja
templates can not be used to expose secrets.  The values will be
frozen by running a playbook with set_fact, and that playbook
will run without access to secrets.  After the playbook
completes, the frozen variables are read from and then removed
from the fact cache.  They are then supplied as normal inventory
variables for any trusted playbooks or playbooks with secrets.

The regular un-frozen variables are used for all other untrusted
playbooks.

Extra-vars are now only used to establish precedence among all
Zuul job variables.  They are no longer passed to Ansible with
the "-e" command line option, as that level of precedence could
also be used to obtain secrets.

Much of this work is accomplished by "squashing" all of the Zuul
job, host, group, and extra variables into a flat structure for
each host in the inventory.  This means that much of the variable
precedence is now handled by Zuul, which then gives Ansible
variables as host vars.  The actual inventory files will be much
more verbose now, since each host will have a copy of every "all"
value.  But this allows the freezing process to be much simpler.

When writing the inventory for the setup playbook, we now use the
!unsafe YAML tag which is understood by Ansible to indicate that
it should not perform jinja templating on variables.  This may
help to avoid any mischief with templated variables since they
have not yet been frozen.

Also, be more strict about what characters are allowed in ansible
variable names.  We already checked job variables, but we didn't
verify that secret names/aliases met the ansible variable
requirements.  A check is added for that (and a unit test that
relied on the erroneous behavior is updated).

Story: 2008664
Story: 2008682
Change-Id: I04d8b822fda6628e87a4a57dc368f20d84ae5ea9
2021-06-24 06:24:23 -07:00
..
__init__.py Move tests into test/unit 2017-01-24 10:18:38 -08:00
test_auth.py Bump pyjwt to 2.0.0 2021-01-14 12:35:18 +00:00
test_bubblewrap.py Make most test cases work on MacOS 2020-02-20 12:59:38 +01:00
test_change_matcher.py Make files matcher match changes with no files 2019-08-23 18:59:29 +02:00
test_circular_dependencies.py Merge "Check cycle items are mergeable before reporting" 2021-03-08 14:12:57 +00:00
test_client.py zuul tenant-conf-check: disable scheduler creation 2021-06-11 16:00:39 +00:00
test_cmd.py Revert "Revert "Add the process environment to zuul.conf parser"" 2019-11-02 09:10:18 +09:00
test_component_registry.py Calculate statsd metrics via ComponentRegistry 2021-05-17 16:47:15 -07:00
test_configloader.py Cache unparsed config files in Zookeeper 2021-05-24 09:31:15 -07:00
test_connection.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_cross_crd.py Separate connection registries in tests 2020-10-13 07:00:09 +02:00
test_daemon.py Remove unecessary shebang and exec bit 2018-07-26 07:12:24 +00:00
test_default_config.py Add type check for zuul conf 2018-12-10 19:24:50 +08:00
test_disk_accountant.py Optionally disable disk_limit_per_job 2019-02-22 08:10:59 +01:00
test_encryption.py Use nested tempfile fixture for cleanups 2018-02-06 15:18:45 -08:00
test_event_queues.py Add a logical timestamp to management events 2021-05-19 17:05:05 -07:00
test_executor.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_gerrit.py Cleanup Zuul's stdout/stderr output 2021-06-04 11:42:02 -07:00
test_gerrit_crd.py Separate connection registries in tests 2020-10-13 07:00:09 +02:00
test_gerrit_legacy_crd.py Separate connection registries in tests 2020-10-13 07:00:09 +02:00
test_git_driver.py Use scheduler manager consistently in tests 2020-04-03 14:49:59 +02:00
test_github_crd.py Use scheduler manager consistently in tests 2020-04-03 14:49:59 +02:00
test_github_driver.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_github_requirements.py Fix multiple prs found when commit is not head 2020-09-04 13:47:54 +02:00
test_gitlab_driver.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_inventory.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_keystorage.py Store secrets keys and SSH keys in Zookeeper 2021-04-14 08:22:07 +02:00
test_lib_ansible.py Validate ansible extra packages 2020-05-08 09:03:10 +02:00
test_merger_repo.py Support overlapping repos and a flat workspace scheme 2021-04-29 17:56:24 -07:00
test_model.py Remove layout attribute from queue items 2021-06-01 18:19:39 +02:00
test_multi_driver.py Make test setup_config more pure 2020-02-28 11:50:22 +01:00
test_nodepool.py Provide statsd client to Nodepool and make scheduler optional 2021-04-30 12:12:28 +02:00
test_openstack.py Support overlapping repos and a flat workspace scheme 2021-04-29 17:56:24 -07:00
test_pagure_driver.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_prometheus.py prometheus: add options to start the server and process collector 2021-04-26 14:47:36 +00:00
test_push_reqs.py Make test setup_config more pure 2020-02-28 11:50:22 +01:00
test_reporting.py Report dequeued changes via Github checks API 2020-05-14 07:42:24 +02:00
test_requirements.py Fix reject clauses in the absence of approvals 2018-08-13 12:37:32 +02:00
test_scheduler.py Fix unknown job detection 2021-06-09 11:51:05 -07:00
test_serial.py Make fake test Gerrit merger more realistic 2020-04-29 15:00:05 -07:00
test_ssh_agent.py Add SSH Agent Primitives and usage 2017-05-26 09:52:22 -07:00
test_stack_dump.py Several executor threading fixes 2017-10-17 09:49:29 -07:00
test_streaming.py Initialize ZooKeeper connection in server rather than in cmd classes 2021-03-08 07:15:32 -08:00
test_strings.py Pseudo-shard unique project names in keystore 2021-04-20 09:53:29 -07:00
test_supercedent.py Check branches in supercedent pipelines 2019-04-05 13:59:05 -07:00
test_v3.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_web.py Add secret_data to zuul_return 2021-06-24 06:24:23 -07:00
test_web_urls.py Initialize ZooKeeper connection in server rather than in cmd classes 2021-03-08 07:15:32 -08:00
test_yamlutil.py Freeze job variables at start of build 2021-06-24 06:24:23 -07:00
test_zk.py Implement API for caching raw config files in ZK 2021-05-19 17:05:06 -07:00
test_zuultrigger.py Switch to Zookeeper backed trigger event queues 2021-03-18 09:24:09 +01:00