def test_timeout(env): with update_config('marathon.url', 'http://1.2.3.4', env): with update_config('core.timeout', '1', env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'app', 'list'], env=env) assert returncode == 1 assert stdout == b'' assert "(connect timeout=1)".encode('utf-8') in stderr
def test_job_list_unauthorized(): with update_config('core.dcos_acs_token', None): assert_command(['dcos', 'job', 'list'], stdout=b"", stderr=(b'Error: authentication failed, ' b'please run `dcos auth login`\n'), returncode=1)
def test_url_validation(env): key = 'package.cosmos_url' with update_config(key, None, env): config_set(key, 'http://localhost', env) config_set(key, 'https://localhost', env) config_set(key, 'http://dcos-1234', env) config_set(key, 'http://dcos-1234.mydomain.com', env) config_set(key, 'http://*****:*****@localhost:8080', env) config_set(key, 'http://u-ser@localhost:8080', env) config_set(key, 'http://user123_@localhost:8080', env) config_set(key, 'http://*****:*****@localhost:8080', env) config_set(key, 'http://*****:*****@localhost:8080', env) config_set(key, 'http://us%r1$3:pa#sw*rd321@localhost:8080', env)
def test_bad_configuration(env): with update_config('marathon.url', 'http://localhost:88888', env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'about'], env=env) assert returncode == 1 assert stdout == b'' assert stderr.startswith( b"URL [http://localhost:88888/v2/info] is unreachable")
def test_verify_ssl_without_cert_env_var(env): env['DCOS_SSL_VERIFY'] = 'true' with update_config('core.ssl_verify', None, env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'app', 'list'], env) assert returncode == 1 assert stderr.decode('utf-8') == _ssl_error_msg() env.pop('DCOS_SSL_VERIFY')
def test_logout_with_token(env): with update_config("core.dcos_acs_token", "foobar", env): stderr = b"[core.dcos_acs_token]: changed\n" assert_command( ['dcos', 'config', 'set', 'core.dcos_acs_token', 'faketoken'], stderr=stderr, env=env) assert_command(['dcos', 'auth', 'logout'], env=env)
def test_repo_list(): repo_list = bytes(("Universe: {0}\n" "helloworld-universe: {helloworld-universe}\n").format( UNIVERSE_REPO, **UNIVERSE_TEST_REPOS), 'utf-8') assert_command(['dcos', 'package', 'repo', 'list'], stdout=repo_list) # test again, but override the dcos_url with a cosmos_url config dcos_url = config.get_config_val("core.dcos_url") with update_config('package.cosmos_url', dcos_url): assert_command(['dcos', 'package', 'repo', 'list'], stdout=repo_list)
def test_list_cli_only(env): helloworld_path = 'tests/data/package/json/test_list_helloworld_cli.json' helloworld_json = file_json(helloworld_path) with _helloworld_cli(), \ update_config('package.cosmos_url', 'http://nohost', env): assert_command( cmd=['dcos', 'package', 'list', '--json', '--cli'], stdout=helloworld_json) assert_command( cmd=['dcos', 'package', 'list', '--json', '--cli', '--app-id=/helloworld'], stdout=b'[]\n') assert_command( cmd=['dcos', 'package', 'list', '--json', '--cli', 'helloworld'], stdout=helloworld_json)
def test_unset_property(env): with update_config("core.reporting", None, env): _get_missing_value('core.reporting', env)
def test_get_existing_number_property(env): with update_config("core.timeout", "5", env): _get_value('core.timeout', 5, env)
def test_get_existing_boolean_property(env): with update_config("core.reporting", "false", env): _get_value('core.reporting', False, env)
def test_set_missing_property(env): with update_config("package.cosmos_url", None, env=env): config_set('package.cosmos_url', 'http://localhost:8080', env) _get_value('package.cosmos_url', 'http://localhost:8080', env)
def test_bad_configuration(env): with update_config('marathon.url', 'http://localhost:88888', env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'about'], env=env) assert returncode == 1
def test_verify_ssl_with_bad_cert_config(env): with update_config('core.ssl_verify', 'tests/data/ssl/fake.pem', env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'app', 'list'], env) assert returncode == 1 assert stderr.decode('utf-8') == _ssl_error_msg()
def test_dont_verify_ssl_with_config(env): with update_config('core.ssl_verify', 'false', env): returncode, stdout, stderr = exec_command( ['dcos', 'marathon', 'app', 'list'], env) assert returncode == 0 assert stderr == b''
def test_logout_no_token(env): with update_config("core.dcos_acs_token", None, env): returncode, _, stderr = exec_command( ['dcos', 'config', 'show', 'core.dcos_acs_token'], env=env) assert returncode == 1 assert stderr == b"Property 'core.dcos_acs_token' doesn't exist\n"