Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.191.176.82
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/ansible_test/_internal/commands/integration/cloud/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python3/dist-packages/ansible_test/_internal/commands/integration/cloud/httptester.py
"""HTTP Tester plugin for integration tests."""
from __future__ import annotations

import os

from ....util import (
    display,
    generate_password,
)

from ....config import (
    IntegrationConfig,
)

from ....containers import (
    CleanupMode,
    run_support_container,
)

from . import (
    CloudEnvironment,
    CloudEnvironmentConfig,
    CloudProvider,
)

KRB5_PASSWORD_ENV = 'KRB5_PASSWORD'


class HttptesterProvider(CloudProvider):
    """HTTP Tester provider plugin. Sets up resources before delegation."""

    def __init__(self, args: IntegrationConfig) -> None:
        super().__init__(args)

        self.image = os.environ.get('ANSIBLE_HTTP_TEST_CONTAINER', 'quay.io/ansible/http-test-container:2.1.0')

        self.uses_docker = True

    def setup(self) -> None:
        """Setup resources before delegation."""
        super().setup()

        ports = [
            80,
            88,
            443,
            444,
            749,
        ]

        aliases = [
            'ansible.http.tests',
            'sni1.ansible.http.tests',
            'fail.ansible.http.tests',
            'self-signed.ansible.http.tests',
        ]

        descriptor = run_support_container(
            self.args,
            self.platform,
            self.image,
            'http-test-container',
            ports,
            aliases=aliases,
            allow_existing=True,
            cleanup=CleanupMode.YES,
            env={
                KRB5_PASSWORD_ENV: generate_password(),
            },
        )

        if not descriptor:
            return

        # Read the password from the container environment.
        # This allows the tests to work when re-using an existing container.
        # The password is marked as sensitive, since it may differ from the one we generated.
        krb5_password = descriptor.details.container.env_dict()[KRB5_PASSWORD_ENV]
        display.sensitive.add(krb5_password)

        self._set_cloud_config(KRB5_PASSWORD_ENV, krb5_password)


class HttptesterEnvironment(CloudEnvironment):
    """HTTP Tester environment plugin. Updates integration test environment after delegation."""

    def get_environment_config(self) -> CloudEnvironmentConfig:
        """Return environment configuration for use in the test environment after delegation."""
        return CloudEnvironmentConfig(
            env_vars=dict(
                HTTPTESTER='1',  # backwards compatibility for tests intended to work with or without HTTP Tester
                KRB5_PASSWORD=str(self._get_cloud_config(KRB5_PASSWORD_ENV)),
            )
        )

Anon7 - 2022
AnonSec Team