Firefox-Marionette

 view release on metacpan or  search on metacpan

t/test_daemons.pm  view on Meta::CPAN

daemon off;
pid $pid_path;
error_log logs/error.log;

events {
    worker_connections 1024;
}

http {
    client_body_temp_path   $temp_directories{client_body_temp};
    proxy_temp_path         $temp_directories{proxy_temp};
    fastcgi_temp_path       $temp_directories{fastcgi_temp};
    uwsgi_temp_path         $temp_directories{uwsgi_temp};
    scgi_temp_path          $temp_directories{scgi_temp};
    access_log              logs/access.log;
    sendfile                on;
    tcp_nopush              on;
    tcp_nodelay             on;
    keepalive_timeout       65;
    types_hash_max_size     4096;

    types {
        text/html           html;
        text/javascript     js;
        text/css            css;
        application/json    json;
    }
    default_type            text/plain;

    server  {
_NGINX_CONF_
    if ( $key_size && $ca ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        listen                     $listen:$port ssl;
_NGINX_CONF_
    }
    else {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        listen                     $listen:$port;
_NGINX_CONF_
    }
    print {$config_handle}
      <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        server_name                default;
_NGINX_CONF_
    if ( $username || $password ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        auth_basic                 "$realm";
        auth_basic_user_file       $passwd_path;
_NGINX_CONF_
    }
    if ( $key_size && $ca ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        ssl_certificate            $certificate_path;
        ssl_certificate_key        $key_path;
        ssl_protocols              TLSv1.2;
        ssl_ciphers                ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:!AES128-SHA:!DES-CBC3-SHA:!MD5:!aNULL:!CAMELLIA:!PSK:!SRP;
        ssl_prefer_server_ciphers  on;
        ssl_session_cache          shared:SSL:10m;
        ssl_session_timeout        10m;
        ssl_stapling               off;
        ssl_stapling_verify        off;
        ssl_ecdh_curve             secp384r1;
_NGINX_CONF_
    }
    print {$config_handle}
      <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        server_tokens              off;
        root                       $root_name;
        index                      $index_name;
    }
}
_NGINX_CONF_
    close $config_handle
      or Carp::croak("Failed to close $config_path:$EXTENDED_OS_ERROR");
    my $nginx = $class->SUPER::new(
        debug          => $parameters{debug},
        binary         => $nginx_binary,
        pid_handle     => $pid_handle,
        listen         => $listen,
        port           => $port,
        base_directory => $base_directory,
        content        => $random_string,
        arguments      => [ qw(-c), $config_path, qw(-p), $base_directory ]
    );
    return $nginx;
}

sub content {
    my ($self) = @_;
    return $self->{content};
}

package Test::Daemon::Squid;

use strict;
use warnings;
use Carp();
use English qw( -no_match_vars );

@Test::Daemon::Squid::ISA = qw(Test::Daemon Test::Binary::Available);

my $squid_binary = __PACKAGE__->find_binary('squid');

sub available {
    my ($class) = @_;
    return $class->SUPER::available( $squid_binary, '--version' );
}

sub find_basic_ncsa_auth {
    my $basic_ncsa_auth_path;
    foreach my $possible_path (
        '/usr/lib64/squid/basic_ncsa_auth',    # Redhat, Fedora
        '/usr/lib/squid/basic_ncsa_auth',      # Alpine Linux, Debian
        '/usr/local/libexec/squid/basic_ncsa_auth'
        ,                                      # FreeBSD, DragonflyBSD, OpenBSD
        '/usr/pkg/libexec/basic_ncsa_auth',    # NetBSD



( run in 0.328 second using v1.01-cache-2.11-cpan-e1769b4cff6 )