def _run():
        leap_session = yield initialize_leap_single_user(
            args.leap_provider_cert,
            args.leap_provider_cert_fingerprint,
            args.credentials_file,
            leap_home=args.leap_home)

        execute_command(args, leap_session)
    def _run():
        leap_session = yield initialize_leap_single_user(
            args.leap_provider_cert,
            args.leap_provider_cert_fingerprint,
            args.credentials_file,
            leap_home=args.leap_home)

        execute_command(args, leap_session)
    def _run():
        leap_session = yield initialize_leap_single_user(
            args.leap_provider_cert,
            args.leap_provider_cert_fingerprint,
            args.credentials_file,
            organization_mode=False,
            leap_home=args.leap_home,
            initial_sync=_do_initial_sync(args))

        execute_command(args, leap_session)
Exemple #4
0
    def _run():
        leap_session = yield initialize_leap_single_user(
            args.leap_provider_cert,
            args.leap_provider_cert_fingerprint,
            args.credentials_file,
            organization_mode=False,
            leap_home=args.leap_home,
            initial_sync=_do_initial_sync(args))

        execute_command(args, leap_session)
Exemple #5
0
def _start_in_single_user_mode(args, resource, services_factory):
    start_site(args, resource)
    deferred = initialize_leap_single_user(args.leap_provider_cert,
                                           args.leap_provider_cert_fingerprint,
                                           args.credentials_file,
                                           args.organization_mode,
                                           args.leap_home)
    deferred.addCallback(
        lambda leap_session: start_user_agent_in_single_user_mode(
            resource, services_factory, args.leap_home, leap_session))
    return deferred
def _start_in_single_user_mode(args, resource, services_factory):
    start_site(args, resource)
    deferred = initialize_leap_single_user(args.leap_provider_cert,
                                           args.leap_provider_cert_fingerprint,
                                           args.credentials_file,
                                           args.organization_mode,
                                           args.leap_home)
    deferred.addCallback(
        lambda leap_session: start_user_agent_in_single_user_mode(
            resource,
            services_factory,
            args.leap_home,
            leap_session))
    return deferred
def _start_in_single_user_mode(args, resource, services_factory):
    start_site(args, resource)
    deferred = initialize_leap_single_user(args.leap_provider_cert,
                                           args.leap_provider_cert_fingerprint,
                                           args.credentials_file,
                                           args.leap_home)

    def _handle_error(exception):
        if (exception.type is InvalidAuthTokenError):
            log.critical(
                'Got an invalid soledad token, the user agent can\'t synchronize data, exiting'
            )
            os._exit(1)
        else:
            exception.raiseException()

    deferred.addCallbacks(
        lambda leap_session: start_user_agent_in_single_user_mode(
            resource, services_factory, args.leap_home, leap_session),
        _handle_error)
    return deferred
    def test_init_single_user_does_bonafide_auth_and_gives_a_leap_session(self, mock_event_server, mock_credentials, mock_init_leap_provider):
        provider_mock = MagicMock()
        mock_init_leap_provider.return_value = provider_mock
        mock_credentials.read.return_value = ('provider_url', 'username', 'password')
        mock_authenticator = MagicMock()

        with patch('pixelated.config.leap.Authenticator', return_value=mock_authenticator) as mock_instantiate_authenticator:
            auth_mock = MagicMock()
            mock_authenticator.authenticate.return_value = defer.succeed(auth_mock)
            leap_session = MagicMock()
            deferred_leap_session = defer.succeed(leap_session)
            with patch.object(LeapSessionFactory, 'create', return_value=deferred_leap_session) as mock_create_leap_session:
                returned_session = yield initialize_leap_single_user('leap_provider_cert', 'leap_provider_cert_fingerprint', 'credentials_file', 'leap_home')

        mock_event_server.ensure_server.assert_called_once()
        mock_credentials.read.assert_called_once_with('credentials_file')
        mock_init_leap_provider.asser_called_once_with('provider_url', 'leap_provider_cert', 'leap_provider_cert_fingerprint', 'leap_home')
        mock_instantiate_authenticator.assert_called_once_with(provider_mock)
        mock_authenticator.authenticate.assert_called_once_with('username', 'password')
        mock_create_leap_session.assert_called_once_with('username', 'password', auth_mock)
        self.assertEqual(leap_session, returned_session)
def _start_in_single_user_mode(args, resource, services_factory):
    start_site(args, resource)
    deferred = initialize_leap_single_user(args.leap_provider_cert,
                                           args.leap_provider_cert_fingerprint,
                                           args.credentials_file,
                                           args.leap_home)

    def _handle_error(exception):
        if(exception.type is InvalidAuthTokenError):
            log.critical('Got an invalid soledad token, the user agent can\'t synchronize data, exiting')
            os._exit(1)
        else:
            exception.raiseException()

    deferred.addCallbacks(
        lambda leap_session: start_user_agent_in_single_user_mode(
            resource,
            services_factory,
            args.leap_home,
            leap_session), _handle_error)
    return deferred