Support AWX_TASK_ENV injection in task and notification invocations.

This change _only_ injects `AWS_TASK_ENV` into `os.environ`; it's up to
underlying libraries to be good citizens and actually respect things
like `HTTPS_PROXY`.

see: #3508
This commit is contained in:
Ryan Petrello
2017-07-06 10:22:59 -04:00
parent 92bc5fd3f0
commit 12d41e2deb
7 changed files with 136 additions and 3 deletions

View File

@@ -2,7 +2,9 @@
# Copyright (c) 2017 Ansible, Inc.
# All Rights Reserved.
import os
import pytest
from uuid import uuid4
from awx.main.utils import common
@@ -15,3 +17,13 @@ from awx.main.utils import common
])
def test_parse_yaml_or_json(input_, output):
assert common.parse_yaml_or_json(input_) == output
def test_set_environ():
key = str(uuid4())
old_environ = os.environ.copy()
with common.set_environ(**{key: 'bar'}):
assert os.environ[key] == 'bar'
assert set(os.environ.keys()) - set(old_environ.keys()) == set([key])
assert os.environ == old_environ
assert key not in os.environ