code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def do_create(tag, build_name, reproducible_artifact_path, commit, variant_arguments, all_completes):
"""Create a installer script for each variant in bootstrap_dict.
Writes a dcos_generate_config.<variant>.sh for each variant in
bootstrap_dict to the working directory, except for the default variant's
... | Create a installer script for each variant in bootstrap_dict.
Writes a dcos_generate_config.<variant>.sh for each variant in
bootstrap_dict to the working directory, except for the default variant's
script, which is written to dcos_generate_config.sh. Returns a dict mapping
variants to (genconf_version... | do_create | python | dcos/dcos | gen/build_deploy/bash.py | https://github.com/dcos/dcos/blob/master/gen/build_deploy/bash.py | Apache-2.0 |
def variant_name(variant):
"""Return a human-readable string representation of variant."""
if variant is None:
return '<default>'
return variant | Return a human-readable string representation of variant. | variant_name | python | dcos/dcos | gen/build_deploy/util.py | https://github.com/dcos/dcos/blob/master/gen/build_deploy/util.py | Apache-2.0 |
def test_master_default(self):
"""
Test that Master Admin Router config file has the correct default
`ssl_ciphers` and `ssl_protocols` values. Defaults are present in
`dcos-config.yaml` file and in `calc.py`.
"""
config_path = '/etc/adminrouter-tls-master.conf'
ar... |
Test that Master Admin Router config file has the correct default
`ssl_ciphers` and `ssl_protocols` values. Defaults are present in
`dcos-config.yaml` file and in `calc.py`.
| test_master_default | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_agent_default(self):
"""
Test that Agent Admin Router config file has the correct `ssl_ciphers`
and `ssl_protocols` values. It is not possible to override these with
any configuration parameters.
"""
config_path = '/etc/adminrouter-tls-agent.conf'
argumen... |
Test that Agent Admin Router config file has the correct `ssl_ciphers`
and `ssl_protocols` values. It is not possible to override these with
any configuration parameters.
| test_agent_default | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_agent_cannot_be_configured(self, tls_versions, ciphers):
"""
Agent Admin Router configuration is not affected by changing Master
Admin Router TLS version or TLS cipher suites configuration.
"""
config_path = '/etc/adminrouter-tls-agent.conf'
new_arguments = {'adm... |
Agent Admin Router configuration is not affected by changing Master
Admin Router TLS version or TLS cipher suites configuration.
| test_agent_cannot_be_configured | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def supported_ssl_ciphers(
self,
new_config_arguments: Dict[str, str],
config_path: str) -> List[str]:
"""
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256:EECDH+AES128:RSA+AES128:!MD5:!3DES;
and returns the list of ciphers.
... |
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256:EECDH+AES128:RSA+AES128:!MD5:!3DES;
and returns the list of ciphers.
Args:
new_config_arguments: Arguments which are added to the 'standard'
set of arguments before generating configuration f... | supported_ssl_ciphers | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def supported_ssl_ciphers_master(
self,
new_config_arguments: Dict[str, str]) -> List[str]:
"""
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256:EECDH+AES128:RSA+AES128:!MD5:!3DES;
and returns the list of ciphers.
Args:
new_c... |
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256:EECDH+AES128:RSA+AES128:!MD5:!3DES;
and returns the list of ciphers.
Args:
new_config_arguments: Arguments which are added to the 'standard'
set of arguments before generating configuration f... | supported_ssl_ciphers_master | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def supported_ssl_ciphers_agent(
self,
new_config_arguments: Dict[str, str]) -> List[str]:
"""
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256;
and returns the list of ciphers.
Args:
new_config_arguments: Arguments which are... |
Finds the line that looks like:
ssl_ciphers EECDH+AES256:RSA+AES256;
and returns the list of ciphers.
Args:
new_config_arguments: Arguments which are added to the 'standard'
set of arguments before generating configuration files.
| supported_ssl_ciphers_agent | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_cipher_agent_default(self):
"""
Admin Router Agent comes with the default ssl_ciphers configuration.
"""
ciphers = self.supported_ssl_ciphers_agent(
new_config_arguments={},
)
assert ciphers == ['EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:!MD5'] |
Admin Router Agent comes with the default ssl_ciphers configuration.
| test_cipher_agent_default | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_cipher_agent_cannot_override(self):
"""
The config variable `adminrouter_tls_cipher_suite` does not impact
internal traffic.
"""
new_arguments = {'adminrouter_tls_cipher_suite': 'EECDH+AES128:RSA+AES128'}
ciphers = self.supported_ssl_ciphers_agent(
ne... |
The config variable `adminrouter_tls_cipher_suite` does not impact
internal traffic.
| test_cipher_agent_cannot_override | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_cipher_master_default(self):
"""
If `adminrouter_tls_cipher_suite` is not overridden the Master Admin
Router is configured with default cipher suite.
"""
new_arguments = {'adminrouter_tls_cipher_suite': ''}
ciphers = self.supported_ssl_ciphers_master(
... |
If `adminrouter_tls_cipher_suite` is not overridden the Master Admin
Router is configured with default cipher suite.
| test_cipher_master_default | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_cipher_master_custom(self):
"""
Setting `adminrouter_tls_cipher_suite` overrides Master Admin Router
TLS configuration.
"""
new_arguments = {'adminrouter_tls_cipher_suite': 'EECDH+AES128:RSA+AES128'}
ciphers = self.supported_ssl_ciphers_master(
new_co... |
Setting `adminrouter_tls_cipher_suite` overrides Master Admin Router
TLS configuration.
| test_cipher_master_custom | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def supported_tls_protocols_ar_master(
self, new_config_arguments: Dict[str, str]) -> List[str]:
"""
This finds a line which looks like the following:
ssl_protocols TLSv1, TLSv1.1;
in the Admin Router TLS configuration.
It then returns the listed protocols.
... |
This finds a line which looks like the following:
ssl_protocols TLSv1, TLSv1.1;
in the Admin Router TLS configuration.
It then returns the listed protocols.
Args:
new_config_arguments: Arguments which are added to the 'standard'
set of arguments ... | supported_tls_protocols_ar_master | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_tls_version_flag_true_false(self, config_name):
"""
Provided configuration flag must be 'true' or 'false' value.
"""
validate_error(
new_arguments={config_name: 'foo'},
key=config_name,
message=true_false_msg,
) |
Provided configuration flag must be 'true' or 'false' value.
| test_tls_version_flag_true_false | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_default_master(self):
"""
By default TLS 1.0 is disabled, and therefore by default the config
variable is set to 'false'.
"""
default_protocols = self.supported_tls_protocols_ar_master(
new_config_arguments={},
)
disable_tls1_protocols = self.... |
By default TLS 1.0 is disabled, and therefore by default the config
variable is set to 'false'.
| test_default_master | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_no_tls_version_enabled(self):
"""
Not setting the `adminrouter_tls_version_override` or any of the
TLS version configuration options results in error.
"""
new_arguments = {'adminrouter_tls_1_0_enabled': 'false',
'adminrouter_tls_1_1_enabled': 'fa... |
Not setting the `adminrouter_tls_version_override` or any of the
TLS version configuration options results in error.
| test_no_tls_version_enabled | python | dcos/dcos | gen/tests/test_adminrouter_tls_conf.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_tls_conf.py | Apache-2.0 |
def test_adminrouter_ui_x_frame_options_default():
"""
Test that Master Admin Router config file has the correct default
`X-Frame-Options` value. Defaults are present in `calc.py`.
"""
config_path = '/etc_master/adminrouter-ui-security.conf'
arguments = make_arguments(new_arguments={})
gener... |
Test that Master Admin Router config file has the correct default
`X-Frame-Options` value. Defaults are present in `calc.py`.
| test_adminrouter_ui_x_frame_options_default | python | dcos/dcos | gen/tests/test_adminrouter_ui.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_ui.py | Apache-2.0 |
def test_adminrouter_ui_x_frame_options_custom(value):
"""
Test for all 3 allowed values
See: https://tools.ietf.org/html/rfc7034#section-2.1
"""
config_path = '/etc_master/adminrouter-ui-security.conf'
arguments = make_arguments(new_arguments={
'adminrouter_x_frame_options': value,
... |
Test for all 3 allowed values
See: https://tools.ietf.org/html/rfc7034#section-2.1
| test_adminrouter_ui_x_frame_options_custom | python | dcos/dcos | gen/tests/test_adminrouter_ui.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_adminrouter_ui.py | Apache-2.0 |
def assert_package_contents(config: dict, package_contents_dir: str) -> None:
"""Raise an AssertionError if config does not match package_contents_dir."""
# Assert all files in config are in package_contents_dir with the correct details.
for file_info in config['package']:
if file_info['path'].start... | Raise an AssertionError if config does not match package_contents_dir. | assert_package_contents | python | dcos/dcos | gen/tests/test_gen.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_gen.py | Apache-2.0 |
def assert_do_gen_package(config: dict) -> None:
"""Generate a package from config and raise an AssertionError if incorrect."""
with tempfile.TemporaryDirectory() as tmpdir:
package_filename = os.path.join(tmpdir, 'package.tar.xz')
package_extract_dir = os.path.join(tmpdir, 'package')
#... | Generate a package from config and raise an AssertionError if incorrect. | assert_do_gen_package | python | dcos/dcos | gen/tests/test_gen.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_gen.py | Apache-2.0 |
def generate_rsa_public_key():
"""
Generate an RSA keypair with a key size of 2048 bits and an
exponent of 65537. Serialize the public key in the the
X.509 SubjectPublicKeyInfo/OpenSSL PEM public key format
(RFC 5280).
Returns:
public key as unicode objects holding the serialized key.
... |
Generate an RSA keypair with a key size of 2048 bits and an
exponent of 65537. Serialize the public key in the the
X.509 SubjectPublicKeyInfo/OpenSSL PEM public key format
(RFC 5280).
Returns:
public key as unicode objects holding the serialized key.
| generate_rsa_public_key | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def test_uid_and_public_key_provided(self):
"""
No error is shown if valid ``superuser_service_account_uid`` and
``superuser_service_account_public_key`` are provided.
"""
validate_success(
new_arguments={
'superuser_service_account_uid': str(uuid.uuid... |
No error is shown if valid ``superuser_service_account_uid`` and
``superuser_service_account_public_key`` are provided.
| test_uid_and_public_key_provided | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def test_uid_not_provided(self):
"""
An error is shown when ``superuser_service_account_public_key`` is
provided but ``superuser_service_account_uid`` is not.
"""
validate_error_multikey(
new_arguments={
'superuser_service_account_public_key': generate... |
An error is shown when ``superuser_service_account_public_key`` is
provided but ``superuser_service_account_uid`` is not.
| test_uid_not_provided | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def test_public_key_not_provided(self):
"""
An error is shown when ``superuser_service_account_uid`` is
provided but ``superuser_service_account_public_key`` is not.
"""
validate_error_multikey(
new_arguments={'superuser_service_account_uid': str(uuid.uuid4())},
... |
An error is shown when ``superuser_service_account_uid`` is
provided but ``superuser_service_account_public_key`` is not.
| test_public_key_not_provided | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def test_provided_uid_empty(self):
"""
An error is shown when an empty ``superuser_service_account_uid``
is together with a valid ``superuser_service_account_public_key``.
"""
validate_error_multikey(
new_arguments={
'superuser_service_account_uid': ''... |
An error is shown when an empty ``superuser_service_account_uid``
is together with a valid ``superuser_service_account_public_key``.
| test_provided_uid_empty | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def test_provided_public_key_invalid(self):
"""
An error is shown when ``superuser_service_account_public_key`` is
given a value which is not an RSA public key encoded in the OpenSSL PEM
format.
"""
validate_error(
new_arguments={
'superuser_se... |
An error is shown when ``superuser_service_account_public_key`` is
given a value which is not an RSA public key encoded in the OpenSSL PEM
format.
| test_provided_public_key_invalid | python | dcos/dcos | gen/tests/test_service_account.py | https://github.com/dcos/dcos/blob/master/gen/tests/test_service_account.py | Apache-2.0 |
def make_arguments(new_arguments):
"""
Fields with default values should not be added in here so that the
default values are also tested.
"""
arguments = copy.deepcopy({
'ip_detect_filename': pkg_resources.resource_filename('gen', 'ip-detect/aws.sh'),
'ip6_detect_filename': pkg_resou... |
Fields with default values should not be added in here so that the
default values are also tested.
| make_arguments | python | dcos/dcos | gen/tests/utils.py | https://github.com/dcos/dcos/blob/master/gen/tests/utils.py | Apache-2.0 |
def __init__(self, occurrences, exact):
"""Initialize new SearchCriteria object
Attributes:
occurrences (int): number of occurrences of the particular regexp
in the buffer
exact (bool): should the `occurrences` attribute be treated as
`exact number of... | Initialize new SearchCriteria object
Attributes:
occurrences (int): number of occurrences of the particular regexp
in the buffer
exact (bool): should the `occurrences` attribute be treated as
`exact number of occurrences` (True), or `at least that many
... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def __init__(self, filter_regexpes, line_buffer, timeout=3):
"""Initialize new LineBufferFilter object
Create new LineBufferFilter object configured to search for string
`filter_regexp` in line buffer `filter_regexp` for as much as `timeout`
seconds.
Args:
line_buff... | Initialize new LineBufferFilter object
Create new LineBufferFilter object configured to search for string
`filter_regexp` in line buffer `filter_regexp` for as much as `timeout`
seconds.
Args:
line_buffer (list()): an array of log lines, as presented by `.*_line_buffer()`
... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def _match_line_against_filter_regexpes(self, line):
"""Helper method that abstracts matching of the line against multiple
regexpes.
Each match is registered, so that it's possible to determine if
search criteria were met.
Arguments:
line (str): a line to match
... | Helper method that abstracts matching of the line against multiple
regexpes.
Each match is registered, so that it's possible to determine if
search criteria were met.
Arguments:
line (str): a line to match
| _match_line_against_filter_regexpes | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def __exit__(self, *unused):
"""Context manager __exit__ method for filter string search
This is the heart of the LineBufferFilter - the whole matching happens
here.
"""
msg_fmt = "Beginning to scan for line `%s` in logline buffer"
log.debug(msg_fmt, list(self._filter_re... | Context manager __exit__ method for filter string search
This is the heart of the LineBufferFilter - the whole matching happens
here.
| __exit__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def extra_matches(self):
"""Detailed information about regexpes that has and/or has not been
matched.
This property can be useful if i.e. there were mixed search criterias -
some of the regexpes had to be strictly matched, some not.
Return:
It returns a dictionary w... | Detailed information about regexpes that has and/or has not been
matched.
This property can be useful if i.e. there were mixed search criterias -
some of the regexpes had to be strictly matched, some not.
Return:
It returns a dictionary with regexpes from `filter_regexpes` ... | extra_matches | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def configure_logger(tests_log_level):
""" Set up a logging basing on pytest cmd line args.
Configure log verbosity basing on the --log-level command line
argument (disabled by default). Additionally write all logs to a file
(inc. DEBUG loglevel information).
Arguments:
tests_log_level: lo... | Set up a logging basing on pytest cmd line args.
Configure log verbosity basing on the --log-level command line
argument (disabled by default). Additionally write all logs to a file
(inc. DEBUG loglevel information).
Arguments:
tests_log_level: log level to use for STDOUT output
| configure_logger | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def add_lo_ipaddr(nflink, ip_addr, prefix_len):
"""Add an ipv4 address to loopback interface.
Add an ipv4 address to loopback provided that it does not already exist.
Args:
nflink: a pyroute2.IPRoute() object/NFLINK connection
ip_addr (str): IP address
prefix_len (int): prefix leng... | Add an ipv4 address to loopback interface.
Add an ipv4 address to loopback provided that it does not already exist.
Args:
nflink: a pyroute2.IPRoute() object/NFLINK connection
ip_addr (str): IP address
prefix_len (int): prefix length
| add_lo_ipaddr | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def del_lo_ipaddr(nflink, ip_addr, prefix_len):
"""Remove ipv4 address from loopback interface
Remove existing ipv4 address, defined by ip_addr and prefix_len, from
loopback interface.
Args:
nflink: a pyroute2.IPRoute() object/NFLINK connection
ip_addr (str): IP address
prefix_... | Remove ipv4 address from loopback interface
Remove existing ipv4 address, defined by ip_addr and prefix_len, from
loopback interface.
Args:
nflink: a pyroute2.IPRoute() object/NFLINK connection
ip_addr (str): IP address
prefix_len (int): prefix length
Raises:
NetlinkEr... | del_lo_ipaddr | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def setup_thread_debugger():
"""Setup a thread debbuger for pytest session
This function, based on http://stackoverflow.com/a/133384, is meant to
add debugging facility to pytest that will allow to debug deadlock that
may sometimes occur.
"""
def debug(signal, frame):
"""Interrupt runni... | Setup a thread debbuger for pytest session
This function, based on http://stackoverflow.com/a/133384, is meant to
add debugging facility to pytest that will allow to debug deadlock that
may sometimes occur.
| setup_thread_debugger | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def debug(signal, frame):
"""Interrupt running process and provide a python prompt for
interactive debugging."""
d = {'_frame': frame} # Allow access to frame object.
d.update(frame.f_globals) # Unless shadowed by global
d.update(frame.f_locals)
i = code.InteractiveCon... | Interrupt running process and provide a python prompt for
interactive debugging. | debug | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def iam_denies_all_requests(mocker_instance):
"""Modifies IAM mock configuration to deny all policyquery requests"""
mocker_instance.send_command(
endpoint_id='http://127.0.0.1:8101',
func_name='deny_all_queries',
)
yield
mocker_instance.send_command(
endpoint_id='http:... | Modifies IAM mock configuration to deny all policyquery requests | iam_denies_all_requests | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def auth_type_str(repo_type):
"""Return valid authentication type string for given cluster type
Arguments:
repo_type (bool): True/False, depending on wheter it is an EE cluster
or not.
Returns:
String denoting valid authentication type string as used in
WWW-Authenticate... | Return valid authentication type string for given cluster type
Arguments:
repo_type (bool): True/False, depending on wheter it is an EE cluster
or not.
Returns:
String denoting valid authentication type string as used in
WWW-Authenticate header.
| auth_type_str | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def jwt_type_str(repo_type):
"""Return valid JWT type string for given cluster type
Arguments:
repo_type (bool): True/False, depending on wheter it is an EE cluster
or not.
Returns:
String denoting JWT type string.
"""
if repo_type:
return 'RS256'
else:
... | Return valid JWT type string for given cluster type
Arguments:
repo_type (bool): True/False, depending on wheter it is an EE cluster
or not.
Returns:
String denoting JWT type string.
| jwt_type_str | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/util.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/util.py | Apache-2.0 |
def ping_mesos_agent(ar,
auth_header,
endpoint_id='http://127.0.0.2:15001',
expect_status=200,
agent_id=AGENT1_ID,
timeout=60,
):
"""Test if agent is reachable or not
Helper function me... | Test if agent is reachable or not
Helper function meant to simplify checking mesos agent reachability/mesos
agent related testing.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
auth_header (dict): headers dict that contains DC/OS authentication
token... | ping_mesos_agent | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_no_slash_redirect_test(ar, path, code=301, headers=None):
"""Test if request for location without trailing slash is redirected
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of... | Test if request for location without trailing slash is redirected
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
path (str): path for which request should be ... | generic_no_slash_redirect_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_verify_response_test(
ar,
headers,
path,
assert_headers=None,
assert_headers_absent=None,
assert_status=200):
"""Test if response sent by AR is correct
Helper function meant to simplify writing multiple tests testing the
same thing for different e... | Test if response sent by AR is correct
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
headers (dict): dictionary containing the headers to send
to... | generic_verify_response_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_upstream_cookies_verify_test(
ar,
headers,
path,
cookies_to_send=None,
assert_cookies_present=None,
assert_cookies_absent=None):
"""Test if cookies that are passed to the upstream by AR are correct
Helper function meant to simplify writing multiple te... | Test if cookies that are passed to the upstream by AR are correct
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
headers (dict): headers dict that contains DC... | generic_upstream_cookies_verify_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_upstream_headers_verify_test(
ar, auth_header, path, assert_headers=None, assert_headers_absent=None):
"""Test if headers sent upstream are correct
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin ... | Test if headers sent upstream are correct
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
auth_header (dict): headers dict that contains DC/OS authentication
... | generic_upstream_headers_verify_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_correct_upstream_dest_test(ar, headers, path, endpoint_id):
"""Test if upstream request has been sent to correct upstream
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runn... | Test if upstream request has been sent to correct upstream
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
headers (dict): dictionary containing the headers to... | generic_correct_upstream_dest_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_correct_upstream_request_test(
ar, headers, given_path, expected_path, http_ver='HTTP/1.0'):
"""Test if path component of the request sent upstream is correct.
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
... | Test if path component of the request sent upstream is correct.
Helper function meant to simplify writing multiple tests testing the
same thing for different endpoints.
Arguments:
ar: Admin Router object, an instance of runner.(ee|open).Nginx
headers (dict): dictionary containing the heade... | generic_correct_upstream_request_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def generic_location_header_during_redirect_is_adjusted_test(
ar,
mocker,
headers,
endpoint_id,
basepath,
location_set,
location_expected,
):
"""Test if the `Location` header is rewritten by AR on redirect.
This generic test issues a request to AR... | Test if the `Location` header is rewritten by AR on redirect.
This generic test issues a request to AR for a given path and verifies that
redirect has occurred with the `Location` header contents equal to
`location_expected` argument.
Arguments:
mocker (Mocker): instance of the Mocker class, u... | generic_location_header_during_redirect_is_adjusted_test | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def header_is_absent(headers, header_name):
"""Test if given header is present in the request headers list
Arguments:
headers (list): list of tuples containing all the headers present in
the reflected request data
header_name (string): name of the header that should not be present/m... | Test if given header is present in the request headers list
Arguments:
headers (list): list of tuples containing all the headers present in
the reflected request data
header_name (string): name of the header that should not be present/must
not be set.
Raises:
As... | header_is_absent | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def verify_header(headers, header_name, header_value):
"""Asserts that particular header exists and has correct value.
Helper function for checking if header with given name has been defined
with correct value in given headers list. The headers list is in format
defined by requests module.
Presenc... | Asserts that particular header exists and has correct value.
Helper function for checking if header with given name has been defined
with correct value in given headers list. The headers list is in format
defined by requests module.
Presence of more than one header with given name or incorrect value r... | verify_header | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def assert_endpoint_response(
ar,
path,
code,
assert_error_log=None,
headers=None,
cookies=None,
assertions=None
):
"""Asserts response code and log messages in Admin Router stderr for
request against specified path.
Arguments:
ar (Ngi... | Asserts response code and log messages in Admin Router stderr for
request against specified path.
Arguments:
ar (Nginx): Running instance of the AR
code (int): Expected response code
assert_error_log (dict): LineBufferFilter compatible definition of messages
to assert
... | assert_endpoint_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def overridden_file_content(file_path, new_content=None):
"""Context manager meant to simplify static files testsing
While inside the context, file can be modified and/or modified content
may be injected by the context manager itself. Right after context is
exited, the original file contents are restor... | Context manager meant to simplify static files testsing
While inside the context, file can be modified and/or modified content
may be injected by the context manager itself. Right after context is
exited, the original file contents are restored.
Arguments:
file_path: path the the file that sho... | overridden_file_content | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def repo_is_ee():
"""Determine the flavour of the repository
Return:
True if repository is EE
"""
cur_dir = os.path.dirname(__file__)
ee_tests_dir = os.path.abspath(os.path.join(cur_dir, "..", "..", "tests", "ee"))
open_tests_dir = os.path.abspath(os.path.join(cur_dir, "..", "..", "test... | Determine the flavour of the repository
Return:
True if repository is EE
| repo_is_ee | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/common.py | Apache-2.0 |
def assert_iam_queried_for_uid(mocker, uid, expect_two_iam_calls=False):
"""Asserts that IAM mock has been queried for given UID
Arguments:
mocker (Mocker): Mocker instance with all server mocks
uid (str): User ID that should have been queried
expect_two_iam_calls (bool): specifies whet... | Asserts that IAM mock has been queried for given UID
Arguments:
mocker (Mocker): Mocker instance with all server mocks
uid (str): User ID that should have been queried
expect_two_iam_calls (bool): specifies whether the request is being made to IAM
or not. Requests being made to ... | assert_iam_queried_for_uid | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/generic_test_code/open.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/generic_test_code/open.py | Apache-2.0 |
def _register_endpoints(self, endpoints):
"""Register given endpoints list with the mock
This method registers all the endpoints that are going to be managed
by this Mocker instance.
Args:
endpoints (object: [EndpointA, EndpointB,...]): list of endpoints
tha... | Register given endpoints list with the mock
This method registers all the endpoints that are going to be managed
by this Mocker instance.
Args:
endpoints (object: [EndpointA, EndpointB,...]): list of endpoints
that should be registered
| _register_endpoints | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def _create_common_endpoints():
"""Helper function that takes care of creating/instantiating all the
endpoints that are common for both EE and Open repositories"""
res = []
# pkgpanda endpoint
res.append(ReflectingUnixSocketEndpoint('/run/dcos/pkgpanda-api.sock'))
# e... | Helper function that takes care of creating/instantiating all the
endpoints that are common for both EE and Open repositories | _create_common_endpoints | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def __init__(self, extra_endpoints=None):
"""Initialize new MockerBase instance
Args:
extra_endpoints (obj: [EndpointA, EndpointB,...]): list of endpoints
that are unique to the inheriting class/represent specific behaviour
of given flavour
"""
... | Initialize new MockerBase instance
Args:
extra_endpoints (obj: [EndpointA, EndpointB,...]): list of endpoints
that are unique to the inheriting class/represent specific behaviour
of given flavour
| __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def start(self):
"""Start all endpoints registered with this Mocker instance"""
with concurrent.futures.ThreadPoolExecutor() as executor:
for endpoint in self._endpoints.values():
executor.submit(endpoint.start) | Start all endpoints registered with this Mocker instance | start | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def stop(self):
"""Stop all endpoints registered with this Mocker instance.
Usually called right before object destruction
"""
with concurrent.futures.ThreadPoolExecutor() as executor:
for endpoint in self._endpoints.values():
executor.submit(endpoint.stop) | Stop all endpoints registered with this Mocker instance.
Usually called right before object destruction
| stop | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def send_command(self, endpoint_id, func_name, aux_data=None):
"""Reconfigure endpoint manager by Mocker
This method reconfigures endpoint previously started by Mocker. The
reconfiguration is basically calling method `func_name` belonging to
endpoint `endpoint_id` with data `aux_data`
... | Reconfigure endpoint manager by Mocker
This method reconfigures endpoint previously started by Mocker. The
reconfiguration is basically calling method `func_name` belonging to
endpoint `endpoint_id` with data `aux_data`
Args:
endpoint_id (str): id of the endpoint to reconfi... | send_command | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/common.py | Apache-2.0 |
def load_key(key_path):
"""Load a key from a file
`ascii` encoding is assumed as the key will be either RSA PEM, or base64
encoded shared secret. The contents are stripped.
Args:
key_path (str): path to the file that contains the key
Returns:
The contents of the file in `key_path`... | Load a key from a file
`ascii` encoding is assumed as the key will be either RSA PEM, or base64
encoded shared secret. The contents are stripped.
Args:
key_path (str): path to the file that contains the key
Returns:
The contents of the file in `key_path` path
Raises:
OSEr... | load_key | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | Apache-2.0 |
def decode_pem_key(key_pem):
"""Convert plaintext PEM key into the format usable for JWT generation
Args:
key_pam (str): key data in PEM format, presented as plain string
Returns:
Parsed PEM data
"""
private_key = serialization.load_pem_private_key(
data=key_pem.encode('asc... | Convert plaintext PEM key into the format usable for JWT generation
Args:
key_pam (str): key data in PEM format, presented as plain string
Returns:
Parsed PEM data
| decode_pem_key | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | Apache-2.0 |
def generate_rs256_jwt(
key_path, uid, exp=None, skip_uid_claim=False, skip_exp_claim=False):
"""Generate a RS256 JSON Web Token
Args:
key_path (str): path to the private key encoded in PEM format, which will be
used for token signing/encoding
uid (str): a value of `uid` JWT... | Generate a RS256 JSON Web Token
Args:
key_path (str): path to the private key encoded in PEM format, which will be
used for token signing/encoding
uid (str): a value of `uid` JWT claim that should be set in the token
exp (int): a value of `exp` JWT claim that should be set in th... | generate_rs256_jwt | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | Apache-2.0 |
def generate_hs256_jwt(
key_path, uid, exp=None, skip_uid_claim=False, skip_exp_claim=False):
"""Generate a HS256 JSON Web Token
Args:
key_path (str): path to shared secret, which will be used for token
signing/encoding
uid (str): a value of `uid` JWT claim that should be se... | Generate a HS256 JSON Web Token
Args:
key_path (str): path to shared secret, which will be used for token
signing/encoding
uid (str): a value of `uid` JWT claim that should be set in the token
exp (int): a value of `exp` JWT claim that should be set in the token,
by ... | generate_hs256_jwt | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/jwt.py | Apache-2.0 |
def _reflect_request(self, base_path, url_args, body_args=None):
"""Gather all the request data into single dict and prepare it for
sending it to the client for inspection.
Please refer to the description of the _calculate_response method
for details on the arguments and return value of... | Gather all the request data into single dict and prepare it for
sending it to the client for inspection.
Please refer to the description of the _calculate_response method
for details on the arguments and return value of this method.
| _reflect_request | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _parse_request_body(self):
"""Parse request body in order to extract arguments.
This method recognizes both `multipart/form-data` and
`application/x-www-form-urlencoded` encoded data. So the client can
check how the tested Nginx behaves with different kinds of params.
It's b... | Parse request body in order to extract arguments.
This method recognizes both `multipart/form-data` and
`application/x-www-form-urlencoded` encoded data. So the client can
check how the tested Nginx behaves with different kinds of params.
It's based on: http://stackoverflow.com/a/423345... | _parse_request_body | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _process_commands(self, content_type, blob):
"""Process all the endpoint configuration and execute things that
user requested.
Please check the Returns section to understand how chaining response
handling/overriding this method look like.
Arguments:
blob (byt... | Process all the endpoint configuration and execute things that
user requested.
Please check the Returns section to understand how chaining response
handling/overriding this method look like.
Arguments:
blob (bytes array): data that is meant to be sent to the client.
... | _process_commands | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def log_message(self, log_format, *args):
"""Just a patch to make Mockers Requests Handlers compatible with
Unix Sockets.
Method logs the request without source IP address/with hard-coded value
of `unix-socket-connection` if the socket is a Unix Socket.
Please check the http... | Just a patch to make Mockers Requests Handlers compatible with
Unix Sockets.
Method logs the request without source IP address/with hard-coded value
of `unix-socket-connection` if the socket is a Unix Socket.
Please check the http.server.BaseHTTPRequestHandler documentation
... | log_message | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _finalize_request(self, code, content_type, blob, extra_headers=None):
"""A helper function meant to abstract sending request to client
Arguments:
code (int): HTTP response code to send
content_type (string): HTTP content type value of the response
blob (b''): da... | A helper function meant to abstract sending request to client
Arguments:
code (int): HTTP response code to send
content_type (string): HTTP content type value of the response
blob (b''): data to send to the client in the body of the request
extra_headers (dict): ... | _finalize_request | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _convert_data_to_blob(data):
"""A helper function meant to simplify converting python objects to
bytes arrays.
Arguments:
data: data to convert to b''. Can be anything as long as it's JSON
serializable.
Returns:
A resulting byte sequence
... | A helper function meant to simplify converting python objects to
bytes arrays.
Arguments:
data: data to convert to b''. Can be anything as long as it's JSON
serializable.
Returns:
A resulting byte sequence
| _convert_data_to_blob | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _parse_request_path(self):
"""Parse query arguments in the request path to dict.
Returns:
A tuple that contains a request path stripped of query arguments
and a dict containing all the query arguments (if any).
"""
parsed_url = urlparse(self.path)
pat... | Parse query arguments in the request path to dict.
Returns:
A tuple that contains a request path stripped of query arguments
and a dict containing all the query arguments (if any).
| _parse_request_path | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def _unified_method_handler(self):
"""A unified entry point for all request types.
This method is meant to be top level entry point for all requests.
This class specifies only GET|POST for now, but other handlers can
add request types if necessary.
All query parameters are extr... | A unified entry point for all request types.
This method is meant to be top level entry point for all requests.
This class specifies only GET|POST for now, but other handlers can
add request types if necessary.
All query parameters are extracted (both from the uri and the body),
... | _unified_method_handler | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py | Apache-2.0 |
def __init__(self, initial_data=None):
"""Initialize EndpointContext object.
This data is often manipulated by methods nested across
inheritance chains, so we need to use RLock() instead of Lock().
The need for the lock itself stems from the fact that very often certain
keys of... | Initialize EndpointContext object.
This data is often manipulated by methods nested across
inheritance chains, so we need to use RLock() instead of Lock().
The need for the lock itself stems from the fact that very often certain
keys of the context need to be manipulated at the same ti... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __init__(self, endpoint_id):
"""Initialize new Endpoint object
Args:
endpoint_id (str): ID of the endpoint that it should identify itself
with
"""
initial_data = {"always_bork": False,
"endpoint_id": endpoint_id,
... | Initialize new Endpoint object
Args:
endpoint_id (str): ID of the endpoint that it should identify itself
with
| __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def reset(self, aux_data=None):
"""Reset endpoint to the default/good state
Args:
aux_data (dict): unused, present only to satisfy the endpoint's
method interface. See class description for details.
"""
del aux_data
log.debug("Resetting endpoint `%s`"... | Reset endpoint to the default/good state
Args:
aux_data (dict): unused, present only to satisfy the endpoint's
method interface. See class description for details.
| reset | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def always_stall(self, aux_data=None):
"""Make endpoint always wait given time before answering the request
Args:
aux_data (numeric): time in seconds, as acepted by time.sleep()
function
"""
with self._context.lock:
self._context.data["always_stal... | Make endpoint always wait given time before answering the request
Args:
aux_data (numeric): time in seconds, as acepted by time.sleep()
function
| always_stall | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def always_redirect(self, aux_data=None):
"""Make endpoint always respond with a redirect
Args:
aux_data (str): target location for the redirect
"""
with self._context.lock:
self._context.data["always_redirect"] = True
self._context.data["redirect_tar... | Make endpoint always respond with a redirect
Args:
aux_data (str): target location for the redirect
| always_redirect | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def stop(self):
"""Perform cleanup of the endpoint threads
This method should be used right before destroying the Endpoint object.
It takes care of stopping internal httpd server.
"""
log.debug("Stopping endpoint `%s`", self.id)
self._httpd.shutdown()
self._httpd... | Perform cleanup of the endpoint threads
This method should be used right before destroying the Endpoint object.
It takes care of stopping internal httpd server.
| stop | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __init__(self, handler_class, port, ip='', keyfile=None, certfile=None):
"""Initialize new TcpIpHttpEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
port (int): tcp port that h... | Initialize new TcpIpHttpEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
port (int): tcp port that httpd server will listen on
ip (str): ip address that httpd server will liste... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __setup_httpd_thread(self, ip, port):
"""Setup internal HTTPd server that this endpoints relies on to serve
requests.
"""
self._httpd = StatefullHTTPServer(self._context,
(ip, port),
self._handler_... | Setup internal HTTPd server that this endpoints relies on to serve
requests.
| __setup_httpd_thread | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def server_bind(self):
"""Override default server socket bind behaviour to adapt it to
serving on Unix socket.
Please check the documentation of http.server.HTTPServer class for more
details.
"""
socketserver.TCPServer.server_bind(self)
self.server_name = self... | Override default server socket bind behaviour to adapt it to
serving on Unix socket.
Please check the documentation of http.server.HTTPServer class for more
details.
| server_bind | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __init__(self, handler_class, path, keyfile=None, certfile=None):
"""Initialize new UnixSocketHTTPEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
path (str): Unix socket path,... | Initialize new UnixSocketHTTPEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
path (str): Unix socket path, that internal httpd server will listen
on
keyfile(st... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __setup_httpd_thread(self, socket_path):
"""Setup internal HTTPd server that this endpoints relies on to serve
requests.
Args:
path (str): Unix socket path, that internal httpd server will listen
on
"""
self._httpd = UnixSocketStatefulHTTPServe... | Setup internal HTTPd server that this endpoints relies on to serve
requests.
Args:
path (str): Unix socket path, that internal httpd server will listen
on
| __setup_httpd_thread | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/generic.py | Apache-2.0 |
def __init__(self, port, ip='', keyfile=None, certfile=None, cafile=None):
"""Initialize new GRPCEndpoint object
Args:
port (int): tcp port that grpc server will listen on
ip (str): ip address that grpc server will listen on, by default
listen on all addresses
... | Initialize new GRPCEndpoint object
Args:
port (int): tcp port that grpc server will listen on
ip (str): ip address that grpc server will listen on, by default
listen on all addresses
keyfile(str): path to the key of the certificate
certfile(str): ... | __init__ | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/grpc.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/grpc.py | Apache-2.0 |
def app_from_template(app_id, port, ip="127.0.0.1", scheme="http"):
"""Create a Marathon app entry basing on the supplied data and the template
Arguments:
app_id (string): app ID that the new app should have
port (string): TCP/IP port that the app should pretend to have
ip (string): IP ... | Create a Marathon app entry basing on the supplied data and the template
Arguments:
app_id (string): app ID that the new app should have
port (string): TCP/IP port that the app should pretend to have
ip (string): IP address that the new apps hould pretend to listen on
scheme (string... | app_from_template | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def _calculate_response(self, base_path, url_args, body_args=None):
"""Reply with empty list of apps for the '/v2/apps' request
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
Endpoint... | Reply with empty list of apps for the '/v2/apps' request
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
EndpointException: request URL path is unsupported
| _calculate_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def set_apps_response(self, apps):
"""Change the response content for apps endpoint
Arguments:
apps (dict): a dict of marathon app dicts describing mocked
apps
"""
with self._context.lock:
self._context.data["endpoint-content"] = apps | Change the response content for apps endpoint
Arguments:
apps (dict): a dict of marathon app dicts describing mocked
apps
| set_apps_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def remove_leader(self, *_):
"""Change the endpoint output so that it simulates absence of the Marathon
leader node.
"""
with self._context.lock:
self._context.data["leader-content"] = None | Change the endpoint output so that it simulates absence of the Marathon
leader node.
| remove_leader | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def change_leader(self, new_leader):
"""Change the endpoint output so that it responds with a non-default
Marathon leader node.
"""
with self._context.lock:
self._context.data["leader-content"] = {"leader": new_leader} | Change the endpoint output so that it responds with a non-default
Marathon leader node.
| change_leader | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def break_leader_reply(self, *_):
"""Change the endpoint output so that it responds with a broken
reply to a query for Marathon leader node.
NOTE: We cannot just use `always_bork` here as we need a more fine-grained
control on what we are breaking. E.G. cache tests need to have... | Change the endpoint output so that it responds with a broken
reply to a query for Marathon leader node.
NOTE: We cannot just use `always_bork` here as we need a more fine-grained
control on what we are breaking. E.G. cache tests need to have apps
endpoint up and running whil... | break_leader_reply | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def __context_init(self):
"""Helper function meant to initialize all the data relevant to this
particular type of endpoint"""
self._context.data["endpoint-content"] = copy.deepcopy({"apps": [
SCHEDULER_APP_ALWAYSTHERE,
SCHEDULER_APP_ALWAYSTHERE_NEST1,
SCHED... | Helper function meant to initialize all the data relevant to this
particular type of endpoint | __context_init | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/marathon.py | Apache-2.0 |
def framework_from_template(fid, name, webui_url):
"""Create a Mesos framework entry basing on the supplied data and the template
Arguments:
sid (string): framework ID that the new framework should have
port (string): TCP/IP port that the new framework should pretend to
listen on
... | Create a Mesos framework entry basing on the supplied data and the template
Arguments:
sid (string): framework ID that the new framework should have
port (string): TCP/IP port that the new framework should pretend to
listen on
ip (string): IP address that the new framework hould... | framework_from_template | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | Apache-2.0 |
def agent_from_template(sid, ip, port):
"""Create a Mesos agent entry basing on the supplied data and the template
Arguments:
sid (string): agent ID that the new agent should have
port (string): TCP/IP port that the new agent should pretend to listen on
ip (string): IP address that the ... | Create a Mesos agent entry basing on the supplied data and the template
Arguments:
sid (string): agent ID that the new agent should have
port (string): TCP/IP port that the new agent should pretend to listen on
ip (string): IP address that the new agent hould pretend to listen on
Retur... | agent_from_template | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | Apache-2.0 |
def _calculate_response(self, base_path, url_args, body_args=None):
"""Reply with a static Mesos state-summary response.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
EndpointExcepti... | Reply with a static Mesos state-summary response.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
EndpointException: request URL path is unsupported
| _calculate_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | Apache-2.0 |
def set_frameworks_response(self, frameworks):
"""Set response content for frameworks section of /state-summary response
Arguments:
frameworks (list): a list of framework dicts describing mocked
frameworks.
"""
with self._context.lock:
self._conte... | Set response content for frameworks section of /state-summary response
Arguments:
frameworks (list): a list of framework dicts describing mocked
frameworks.
| set_frameworks_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos.py | Apache-2.0 |
def _calculate_response(self, base_path, url_args, body_args=None):
"""Reply with the currently set mock-reply for given SRV record query.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
... | Reply with the currently set mock-reply for given SRV record query.
Please refer to the description of the BaseHTTPRequestHandler class
for details on the arguments and return value of this method.
Raises:
EndpointException: request URL path is unsupported
| _calculate_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | Apache-2.0 |
def __srv_permissions_request_handler(self, srvid):
"""Calculate reply for given service-ID
Arguments:
srvid (string): service ID to reply to
"""
ctx = self.server.context
if srvid not in ctx.data['services']:
raise EndpointException(
cod... | Calculate reply for given service-ID
Arguments:
srvid (string): service ID to reply to
| __srv_permissions_request_handler | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | Apache-2.0 |
def create_srv_entry(srv_name, ip, port):
"""Create a SRV entry based on the supplied data
Arguments:
srv_name (string): service ID that the new SRV-entry should represent
port (string): TCP/IP port that the new agent should pretend to listen on
ip (string): IP address that the new agen... | Create a SRV entry based on the supplied data
Arguments:
srv_name (string): service ID that the new SRV-entry should represent
port (string): TCP/IP port that the new agent should pretend to listen on
ip (string): IP address that the new agent hould pretend to listen on
Returns:
... | create_srv_entry | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | Apache-2.0 |
def set_srv_response(self, srvs):
"""Change the endpoint output so that it responds with a non-default
MesosDNS srv node.
"""
with self._context.lock:
self._context.data["services"] = srvs | Change the endpoint output so that it responds with a non-default
MesosDNS srv node.
| set_srv_response | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/mesos_dns.py | Apache-2.0 |
def _record_request(self):
"""Store all the relevant data of the request into the endpoint context."""
ctx = self.server.context
res = {}
res['method'] = self.command
res['path'] = self.path
res['headers'] = self.headers.items()
res['request_version'] = self.requ... | Store all the relevant data of the request into the endpoint context. | _record_request | python | dcos/dcos | packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | https://github.com/dcos/dcos/blob/master/packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/recording.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.