Ejemplo n.º 1
0
    def handle_client_ssl(self, e):
        exit_code = ExceptionHandler.handle_client_ssl(self, e)
        desc = _('Use the login command to authenticate with the server and '
                 'download a new session certificate.')
        self.prompt.render_paragraph(desc)

        return exit_code
Ejemplo n.º 2
0
    def setUp(self):
        super(PulpClientTests, self).setUp()

        self.config = SafeConfigParser()
        config_filename = os.path.join(DATA_DIR, 'test-override-client.conf')
        self.config = Config(config_filename)

        self.server_mock = mock.Mock()
        self.pulp_connection = PulpConnection('',
                                              server_wrapper=self.server_mock)
        self.bindings = Bindings(self.pulp_connection)

        # Disabling color makes it easier to grep results since the character codes aren't there
        self.recorder = okaara.prompt.Recorder()
        self.prompt = PulpPrompt(enable_color=False,
                                 output=self.recorder,
                                 record_tags=True)

        self.logger = logging.getLogger('pulp')
        self.exception_handler = ExceptionHandler(self.prompt, self.config)

        self.context = ClientContext(self.bindings, self.config, self.logger,
                                     self.prompt, self.exception_handler)

        self.cli = PulpCli(self.context)
        self.context.cli = self.cli
Ejemplo n.º 3
0
    def handle_not_found(self, e):
        """
        Handles a not found (HTTP 404) error from the server.

        :param e: An exception to handle
        :type  e: pulp.bindings.exceptions.NotFoundException

        :return: The appropriate exit code (in this case os.EX_DATAERR)
        :rtype:  int
        """
        if 'resources' in e.extra_data and 'bind_id' in e.extra_data['resources']:
            # The binding doesn't exist, but the way the server reports this is not
            # rendered in a user-friendly way by the default handler.
            self._log_server_exception(e)
            msg = _('The binding could not be found.')
            self.prompt.render_failure_message(msg)
        else:
            ExceptionHandler.handle_not_found(self, e)

        return CODE_NOT_FOUND
Ejemplo n.º 4
0
    def handle_not_found(self, e):
        """
        Handles a not found (HTTP 404) error from the server.

        :param e: An exception to handle
        :type  e: pulp.bindings.exceptions.NotFoundException

        :return: The appropriate exit code (in this case os.EX_DATAERR)
        :rtype:  int
        """
        if 'resources' in e.extra_data and 'bind_id' in e.extra_data[
                'resources']:
            # The binding doesn't exist, but the way the server reports this is not
            # rendered in a user-friendly way by the default handler.
            self._log_server_exception(e)
            msg = _('The binding could not be found.')
            self.prompt.render_failure_message(msg)
        else:
            ExceptionHandler.handle_not_found(self, e)

        return CODE_NOT_FOUND
Ejemplo n.º 5
0
    def handle_expired_client_cert(self, e):
        """
        Handles the exception raised when the client certificate has expired.

        :param e: The Exception that was raised
        :type  e: pulp.bindings.exceptions.ClientCertificateExpiredException
        :return:  The exit code to be used.
        :rtype:   int
        """
        exit_code = ExceptionHandler.handle_expired_client_cert(self, e)

        desc = _('Use the login command to authenticate with the server and '
                 'download a new session certificate.')
        self.prompt.render_paragraph(desc)

        return exit_code
Ejemplo n.º 6
0
    def handle_expired_client_cert(self, e):
        """
        Handles the exception raised when the client certificate has expired.

        :param e: The Exception that was raised
        :type  e: pulp.bindings.exceptions.ClientCertificateExpiredException
        :return:  The exit code to be used.
        :rtype:   int
        """
        exit_code = ExceptionHandler.handle_expired_client_cert(self, e)

        desc = _('Use the login command to authenticate with the server and '
                 'download a new session certificate.')
        self.prompt.render_paragraph(desc)

        return exit_code
Ejemplo n.º 7
0
 def setUp(self):
     TestCase.setUp(self)
     self.config = SafeConfigParser()
     path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data',
                         'client.conf')
     self.config = Config(path)
     self.server_mock = mock.Mock()
     self.pulp_connection = \
         PulpConnection('', server_wrapper=self.server_mock)
     self.bindings = Bindings(self.pulp_connection)
     self.recorder = okaara.prompt.Recorder()
     self.prompt = PulpPrompt(enable_color=False,
                              output=self.recorder,
                              record_tags=True)
     self.logger = logging.getLogger('pulp')
     self.exception_handler = ExceptionHandler(self.prompt, self.config)
     self.context = ClientContext(self.bindings, self.config, self.logger,
                                  self.prompt, self.exception_handler)
     self.cli = PulpCli(self.context)
     self.context.cli = self.cli