Ejemplo n.º 1
0
def test_make_user_session(mock_dcos_client):
    # make user session from no auth
    cluster_none = mock_dcos_client
    user_1 = dcos_api.DcosUser({'foo': 'bar'})
    user_2 = dcos_api.DcosUser({'baz': 'qux'})
    cluster_1 = cluster_none.get_user_session(user_1)
    assert cluster_1.session.auth.auth_token == 'bar'
    # Add a cookie to this session to make sure it gets cleared
    cluster_1.session.cookies.update({'dcos-acs-auth-cookie': 'foo'})
    # make user session from user
    cluster_2 = cluster_1.get_user_session(user_2)
    assert cluster_2.session.auth.auth_token == 'bar'
    # check cleared cookie
    assert cluster_2.session.cookies.get('dcos-acs-auth-cookie') is None
    # make no auth session from use session
    cluster_none = cluster_2.get_user_session(None)
    assert cluster_none.session.auth is None
    assert len(cluster_none.session.cookies.items()) == 0
    def _oss_session(self):
        api = dcos_api.DcosApiSession(
            dcos_url='http://{}'.format(self._any_master.public_ip_address),
            masters=[str(n.public_ip_address) for n in self.masters],
            slaves=[str(n.public_ip_address) for n in self.agents],
            public_slaves=[
                str(n.public_ip_address) for n in self.public_agents
            ],
            auth_user=dcos_api.DcosUser(credentials=self.credentials),
        )

        api.login_default_user()
        return api
Ejemplo n.º 3
0
def make_session_fixture():
    args = dcos_api.DcosApiSession.get_args_from_env()

    exhibitor_admin_password = None
    if expanded_config['exhibitor_admin_password_enabled'] == 'true':
        exhibitor_admin_password = expanded_config['exhibitor_admin_password']

    dcos_api_session = dcos_api.DcosApiSession(
        auth_user=dcos_api.DcosUser(helpers.CI_CREDENTIALS),
        exhibitor_admin_password=exhibitor_admin_password,
        **args)
    dcos_api_session.wait_for_dcos()
    return dcos_api_session
    def _enterprise_session(self):
        cmd = ('cat', '/opt/mesosphere/etc/bootstrap-config.json')
        config_result = self._any_master_run(cmd)
        config = json.loads(config_result.stdout.decode())
        ssl_enabled = config['ssl_enabled']

        scheme = 'https://' if ssl_enabled else 'http://'
        dcos_url = scheme + str(self._any_master.public_ip_address)
        api = dcos_ee_api.EnterpriseApiSession(
            dcos_url=dcos_url,
            masters=[str(n.public_ip_address) for n in self.masters],
            slaves=[str(n.public_ip_address) for n in self.agents],
            public_slaves=[
                str(n.public_ip_address) for n in self.public_agents
            ],
            auth_user=dcos_api.DcosUser(credentials=self.credentials),
        )

        if api.ssl_enabled:
            api.set_ca_cert()
        api.login_default_user()
        api.set_initial_resource_ids()

        return api