mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02:30
Update tests to use ee fixture
This commit is contained in:
@@ -140,7 +140,7 @@ def test_delete_instance_group_jobs_running(delete, instance_group_jobs_running,
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_delete_rename_tower_instance_group_prevented(delete, options, tower_instance_group, instance_group, user, patch):
|
def test_delete_rename_tower_instance_group_prevented(delete, options, tower_instance_group, instance_group, user, patch, execution_environment):
|
||||||
url = reverse("api:instance_group_detail", kwargs={'pk': tower_instance_group.pk})
|
url = reverse("api:instance_group_detail", kwargs={'pk': tower_instance_group.pk})
|
||||||
super_user = user('bob', True)
|
super_user = user('bob', True)
|
||||||
|
|
||||||
|
|||||||
@@ -829,5 +829,5 @@ def slice_job_factory(slice_jt_factory):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def execution_environment(organization):
|
def execution_environment():
|
||||||
return ExecutionEnvironment.objects.create(name="test-ee", description="test-ee", organization=organization)
|
return ExecutionEnvironment.objects.create(name="test-ee", description="test-ee", managed_by_tower=True)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import base64
|
import base64
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
from unittest import mock # noqa
|
from unittest import mock # noqa
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from awx.main.scheduler.kubernetes import PodManager
|
from awx.main.tasks import AWXReceptorJob
|
||||||
from awx.main.utils import (
|
from awx.main.utils import (
|
||||||
create_temporary_fifo,
|
create_temporary_fifo,
|
||||||
)
|
)
|
||||||
@@ -34,7 +35,7 @@ def test_containerized_job(containerized_job):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_kubectl_ssl_verification(containerized_job):
|
def test_kubectl_ssl_verification(containerized_job, execution_environment):
|
||||||
cred = containerized_job.instance_group.credential
|
cred = containerized_job.instance_group.credential
|
||||||
cred.inputs['verify_ssl'] = True
|
cred.inputs['verify_ssl'] = True
|
||||||
key_material = subprocess.run('openssl genrsa 2> /dev/null', shell=True, check=True, stdout=subprocess.PIPE)
|
key_material = subprocess.run('openssl genrsa 2> /dev/null', shell=True, check=True, stdout=subprocess.PIPE)
|
||||||
@@ -46,6 +47,8 @@ def test_kubectl_ssl_verification(containerized_job):
|
|||||||
cert = subprocess.run(cmd.strip(), shell=True, check=True, stdout=subprocess.PIPE)
|
cert = subprocess.run(cmd.strip(), shell=True, check=True, stdout=subprocess.PIPE)
|
||||||
cred.inputs['ssl_ca_cert'] = cert.stdout
|
cred.inputs['ssl_ca_cert'] = cert.stdout
|
||||||
cred.save()
|
cred.save()
|
||||||
pm = PodManager(containerized_job)
|
RunJob = namedtuple('RunJob', ['instance', 'build_execution_environment_params'])
|
||||||
ca_data = pm.kube_config['clusters'][0]['cluster']['certificate-authority-data']
|
rj = RunJob(instance=containerized_job, build_execution_environment_params=lambda x: {})
|
||||||
|
receptor_job = AWXReceptorJob(rj, runner_params={'settings': {}})
|
||||||
|
ca_data = receptor_job.kube_config['clusters'][0]['cluster']['certificate-authority-data']
|
||||||
assert cert.stdout == base64.b64decode(ca_data.encode())
|
assert cert.stdout == base64.b64decode(ca_data.encode())
|
||||||
|
|||||||
Reference in New Issue
Block a user