예제 #1
0
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.operations:
            path, name = os.path.split(self.args.operations)
            self.operations = get_mod(name, [path])
        else:
            self.operations = __import__("idp_test.saml2base",
                                         fromlist=["idp_test"])

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        try:
            self.setup()
        except (AttributeError, ToOld), err:
            print >> sys.stdout, "Configuration Error: %s" % err
예제 #2
0
파일: __init__.py 프로젝트: Itxaka/pysaml2
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.operations:
            path, name = os.path.split(self.args.operations)
            self.operations = get_mod(name, [path])
        else:
            self.operations = __import__("idp_test.saml2base",
                                         fromlist=["idp_test"])

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        try:
            self.setup()
        except (AttributeError, ToOld), err:
            print >> sys.stdout, "Configuration Error: %s" % err
예제 #3
0
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        self.setup()

        try:
            oper = self.operations.OPERATIONS[self.args.oper]
        except KeyError:
            if self.tests:
                try:
                    oper = self.tests.OPERATIONS[self.args.oper]
                except ValueError:
                    print >> sys.stderr, "Undefined testcase"
                    return
            else:
                print >> sys.stderr, "Undefined testcase"
                return

        opers = oper["sequence"]

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        logger.info("Starting conversation")
        conv = Conversation(self.idp,
                            self.idp_config,
                            self.interactions,
                            self.json_config,
                            check_factory=self.check_factory,
                            entity_id=self.entity_id,
                            constraints=self.constraints)
        try:
            conv.do_sequence(opers, oper["tests"])
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError, err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
예제 #4
0
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        self.setup()

        try:
            oper = self.operations.OPERATIONS[self.args.oper]
        except KeyError:
            if self.tests:
                try:
                    oper = self.tests.OPERATIONS[self.args.oper]
                except ValueError:
                    print >> sys.stderr, "Undefined testcase"
                    return
            else:
                print >> sys.stderr, "Undefined testcase"
                return

        opers = oper["sequence"]

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        logger.info("Starting conversation")
        conv = Conversation(self.idp, self.idp_config,
                            self.interactions, self.json_config,
                            check_factory=self.check_factory,
                            entity_id=self.entity_id,
                            constraints=self.constraints)
        try:
            conv.do_sequence(opers, oper["tests"])
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError, err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
예제 #5
0
파일: config.py 프로젝트: bcopeland/pysaml2
    def setup_logger(self):
        if root_logger.level != logging.NOTSET:  # Someone got there before me
            return root_logger

        _logconf = self.logger
        if _logconf is None:
            return root_logger

        try:
            root_logger.setLevel(LOG_LEVEL[_logconf["loglevel"].lower()])
        except KeyError:  # reasonable default
            root_logger.setLevel(logging.INFO)

        root_logger.addHandler(self.log_handler())
        root_logger.info("Logging started")
        return root_logger
예제 #6
0
    def setup_logger(self):
        if root_logger.level != logging.NOTSET:  # Someone got there before me
            return root_logger

        _logconf = self.logger
        if _logconf is None:
            return root_logger

        try:
            root_logger.setLevel(LOG_LEVEL[_logconf["loglevel"].lower()])
        except KeyError:  # reasonable default
            root_logger.setLevel(logging.INFO)

        root_logger.addHandler(self.log_handler())
        root_logger.info("Logging started")
        return root_logger
예제 #7
0
파일: __init__.py 프로젝트: Goggin/pysaml2
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        self.setup()

        try:
            oper = self.operations.OPERATIONS[self.args.oper]
        except KeyError:
            if self.tests:
                try:
                    oper = self.tests.OPERATIONS[self.args.oper]
                except ValueError:
                    print("Undefined testcase " + self.args.oper,
                          file=sys.stderr)
                    return
            else:
                print("Undefined testcase " + self.args.oper, file=sys.stderr)
                return

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        logger.info("Starting conversation")
        conv = Conversation(self.idp, self.idp_config,
                            self.interactions, self.json_config,
                            check_factory=self.check_factory,
                            entity_id=self.entity_id,
                            constraints=self.constraints,
                            commandlineargs = self.args)
        try:
            conv.do_sequence_and_tests(oper["sequence"], oper["tests"])
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError as err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
        except FatalError as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
        except Exception as err:
            if conv:
                conv.test_output.append({"status": CRITICAL,
                         "name": "test driver error",
                         "id": "critial exception"})
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
            logger.error("Unexpected exception in test driver %s",
                         traceback.format_exception(*sys.exc_info()))


        if pp:
            pp.pprint(tsum)
        else:
            print(json.dumps(tsum), file=sys.stdout)

        if tsum["status"] > 1 or self.args.debug or err:
            self.output_log(memoryhandler, streamhandler)
예제 #8
0
파일: __init__.py 프로젝트: jchysk/pysaml2
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.operations:
            path, name = os.path.split(self.args.operations)
            self.operations = get_mod(name, [path])
        else:
            self.operations = __import__("idp_test.saml2base",
                                         fromlist=["idp_test"])

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        try:
            self.setup()
        except (AttributeError, ToOld) as err:
            print("Configuration Error: %s" % err, file=sys.stderr)

        self.client = Saml2Client(self.sp_config)
        conv = None

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        try:
            try:
                oper = self.operations.OPERATIONS[self.args.oper]
            except KeyError:
                if self.tests:
                    try:
                        oper = self.tests.OPERATIONS[self.args.oper]
                    except ValueError:
                        logger.error("Undefined testcase")
                        return
                else:
                    logger.error("Undefined testcase")
                    return

            logger.info("Starting conversation")
            conv = Conversation(self.client, self.sp_config, self.interactions,
                                check_factory=self.check_factory,
                                entity_id=self.entity_id,
                                constraints=self.constraints)
            conv.do_sequence(oper)
            #testres, trace = do_sequence(oper,
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError as err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
        except FatalError as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
        except Exception as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)

        if pp:
            pp.pprint(tsum)
        else:
            print(json.dumps(tsum), file=sys.stdout)

        if tsum["status"] > 1 or self.args.debug or err:
            self.output_log(memoryhandler, streamhandler)
예제 #9
0
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.operations:
            path, name = os.path.split(self.args.operations)
            self.operations = get_mod(name, [path])
        else:
            self.operations = __import__("idp_test.saml2base",
                                         fromlist=["idp_test"])

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        try:
            self.setup()
        except (AttributeError, ToOld) as err:
            print("Configuration Error: %s" % err, file=sys.stderr)

        self.client = Saml2Client(self.sp_config)
        conv = None

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        try:
            try:
                oper = self.operations.OPERATIONS[self.args.oper]
            except KeyError:
                if self.tests:
                    try:
                        oper = self.tests.OPERATIONS[self.args.oper]
                    except ValueError:
                        logger.error("Undefined testcase")
                        return
                else:
                    logger.error("Undefined testcase")
                    return

            logger.info("Starting conversation")
            conv = Conversation(self.client,
                                self.sp_config,
                                self.interactions,
                                check_factory=self.check_factory,
                                entity_id=self.entity_id,
                                constraints=self.constraints)
            conv.do_sequence(oper)
            #testres, trace = do_sequence(oper,
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError as err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
        except FatalError as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
        except Exception as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)

        if pp:
            pp.pprint(tsum)
        else:
            print(json.dumps(tsum), file=sys.stdout)

        if tsum["status"] > 1 or self.args.debug or err:
            self.output_log(memoryhandler, streamhandler)
예제 #10
0
    def run(self):
        self.args = self._parser.parse_args()

        if self.args.pysamllog:
            root_logger.addHandler(memoryhandler)
            root_logger.setLevel(logging.DEBUG)

        if self.args.metadata:
            return self.make_meta()
        elif self.args.list:
            return self.list_operations()
        elif self.args.oper == "check":
            return self.verify_metadata()
        else:
            if not self.args.oper:
                raise Exception("Missing test case specification")
            self.args.oper = self.args.oper.strip("'")
            self.args.oper = self.args.oper.strip('"')

        self.setup()

        try:
            oper = self.operations.OPERATIONS[self.args.oper]
        except KeyError:
            if self.tests:
                try:
                    oper = self.tests.OPERATIONS[self.args.oper]
                except ValueError:
                    print("Undefined testcase " + self.args.oper,
                          file=sys.stderr)
                    return
            else:
                print("Undefined testcase " + self.args.oper, file=sys.stderr)
                return

        if self.args.pretty:
            pp = pprint.PrettyPrinter(indent=4)
        else:
            pp = None

        logger.info("Starting conversation")
        conv = Conversation(self.idp,
                            self.idp_config,
                            self.interactions,
                            self.json_config,
                            check_factory=self.check_factory,
                            entity_id=self.entity_id,
                            constraints=self.constraints,
                            commandlineargs=self.args)
        try:
            conv.do_sequence_and_tests(oper["sequence"], oper["tests"])
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
            err = None
        except CheckError as err:
            self.test_log = conv.test_output
            tsum = self.test_summation(self.args.oper)
        except FatalError as err:
            if conv:
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
        except Exception as err:
            if conv:
                conv.test_output.append({
                    "status": CRITICAL,
                    "name": "test driver error",
                    "id": "critial exception"
                })
                self.test_log = conv.test_output
                self.test_log.append(exception_trace("RUN", err))
            else:
                self.test_log = exception_trace("RUN", err)
            tsum = self.test_summation(self.args.oper)
            logger.error("Unexpected exception in test driver %s",
                         traceback.format_exception(*sys.exc_info()))

        if pp:
            pp.pprint(tsum)
        else:
            print(json.dumps(tsum), file=sys.stdout)

        if tsum["status"] > 1 or self.args.debug or err:
            self.output_log(memoryhandler, streamhandler)