We are introducing a new subcommand for managing your clusters. Configuring your CLI to talk to your cluster is a single command now `dcos cluster setup`. Moreover, the CLI can now be aware of multiple clusters with cluster specific configuration managed by the CLI. Subcommands will be installed for the current "attached" cluster only. To install a subcommand for all your configured clusters, use `--global`. Note that `DCOS_CONFIG` environment variable will not take effect in "cluster" mode since we are now managing different clusters in the CLI.
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
import os
|
|
|
|
import pytest
|
|
|
|
from dcos import constants
|
|
|
|
from .helpers.common import assert_command, exec_command, update_config
|
|
|
|
|
|
@pytest.fixture
|
|
def env():
|
|
r = os.environ.copy()
|
|
r.update({constants.PATH_ENV: os.environ[constants.PATH_ENV]})
|
|
|
|
return r
|
|
|
|
|
|
def test_info():
|
|
stdout = b'Authenticate to DC/OS cluster\n'
|
|
assert_command(['dcos', 'auth', '--info'],
|
|
stdout=stdout)
|
|
|
|
|
|
def test_version():
|
|
stdout = b'dcos-auth version SNAPSHOT\n'
|
|
assert_command(['dcos', 'auth', '--version'],
|
|
stdout=stdout)
|
|
|
|
|
|
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"
|
|
|
|
|
|
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)
|