Beispiel #1
0
    def dump_log(self, session, test_id):
        try:
            _conv = session["conv"]
        except KeyError:
            pass
        else:
            _pi = get_profile_info(session, test_id)
            if _pi:
                sline = 60*"="
                output = ["%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile",
                                                           "Test ID"]]
                output.append("Timestamp: %s" % in_a_while())
                output.extend(["", sline, ""])
                output.extend(trace_output(_conv.trace))
                output.extend(["", sline, ""])
                output.extend(condition(_conv.events))
                output.extend(["", sline, ""])
                # and lastly the result
                info = {
                    "events": _conv.events,
                    "trace": _conv.trace
                }
                output.append("RESULT: %s" % represent_result(info, session))
                output.append("")

                txt = "\n".join(output)

                print(txt)
Beispiel #2
0
    def dump_log(self, session, test_id):
        try:
            _conv = session["conv"]
        except KeyError:
            pass
        else:
            _pi = get_profile_info(session, test_id)
            if _pi:
                sline = 60 * "="
                output = [
                    "%s: %s" % (k, _pi[k])
                    for k in ["Issuer", "Profile", "Test ID"]
                ]
                output.append("Timestamp: %s" % in_a_while())
                output.extend(["", sline, ""])
                output.extend(trace_output(_conv.trace))
                output.extend(["", sline, ""])
                output.extend(condition(_conv.events))
                output.extend(["", sline, ""])
                # and lastly the result
                info = {"events": _conv.events, "trace": _conv.trace}
                output.append("RESULT: %s" % represent_result(info, session))
                output.append("")

                txt = "\n".join(output)

                print(txt)
Beispiel #3
0
def acs():
    tester, app_args = setup_tester()
    for ev in tester.conv.events:
        print(ev)

    tester.handle_response(flask.request.form, {})

    if 'assert' in tester.conv.flow:
        _ver = Verify(app_args['check_factory'], tester.conv)
        _ver.test_sequence(tester.conv.flow["assert"])

    sline = 60 * "="
    print("Timestamp: {}".format(in_a_while()))
    print("\n", sline, "\n")
    for l in trace_output(tester.conv.trace):
        print(l)
    print("\n", sline, "\n")
    for l in condition(tester.conv.events):
        print(l)
    print("\n", sline, "\n")

    try:
        test_results = flask.session['test_results']
    except KeyError:
        test_results = {}

    entcat_tests = dict(
        [(t, entcat_test(v)) for t, v in app.config['TESTS'].items()])

    test_results[tester.conv.events.get_data('test_id')[0]] = eval_state(
        tester.conv.events)

    check_result = ['{}: {}'.format(s.test_id, STATUSCODE[s.status]) for s in
                    tester.conv.events.get_data('condition')]

    flask.session['test_results'] = test_results
    return render_template("test_main.html",
                           base=tester.conv.base_url,
                           tests=app.config["TESTS"],
                           test_results=test_results,
                           check_result=check_result,
                           ec_tests=entcat_tests)
Beispiel #4
0
    def dump_log(self, session, test_id=None):
        try:
            _conv = session["conv"]
        except KeyError:
            pass
        else:
            _pi = get_profile_info(session, test_id)
            if _pi:
                _tid = _pi["Test ID"]
                path = log_path(session, _tid)
                if not path:
                    return

                sline = 60 * "="
                output = [
                    "%s: %s" % (k, _pi[k])
                    for k in ["Issuer", "Profile", "Test ID"]
                ]
                output.append("Timestamp: %s" % in_a_while())
                output.extend(["", sline, ""])
                output.extend(trace_output(_conv.trace))
                output.extend(["", sline, ""])
                output.extend(condition(_conv.events))
                output.extend(["", sline, ""])
                # and lastly the result
                self.store_test_info(session, _pi)
                _info = session["test_info"][_tid]
                output.append("RESULT: %s" % represent_result(_info, session))
                output.append("")

                f = open(path, "w")
                txt = "\n".join(output)

                try:
                    f.write(txt)
                except UnicodeEncodeError:
                    f.write(txt.encode("utf8"))

                f.close()
                pp = path.split("/")
                create_tar_archive(pp[1], pp[2])
                return path
Beispiel #5
0
    def dump_log(self, session, test_id=None):
        try:
            _conv = session["conv"]
        except KeyError:
            pass
        else:
            _pi = get_profile_info(session, test_id)
            if _pi:
                _tid = _pi["Test ID"]
                path = log_path(session, _tid)
                if not path:
                    return

                sline = 60*"="
                output = ["%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile",
                                                           "Test ID"]]
                output.append("Timestamp: %s" % in_a_while())
                output.extend(["", sline, ""])
                output.extend(trace_output(_conv.trace))
                output.extend(["", sline, ""])
                output.extend(condition(_conv.events))
                output.extend(["", sline, ""])
                # and lastly the result
                self.store_test_info(session, _pi)
                _info = session["test_info"][_tid]
                output.append("RESULT: %s" % represent_result(_info, session))
                output.append("")

                f = open(path, "w")
                txt = "\n".join(output)

                try:
                    f.write(txt)
                except UnicodeEncodeError:
                    f.write(txt.encode("utf8"))

                f.close()
                pp = path.split("/")
                create_tar_archive(pp[1], pp[2])
                return path
Beispiel #6
0
    def dump_log(self, session, test_id):
        try:
            _conv = session["conv"]
        except KeyError:
            pass
        else:
            try:
                _pi = self.profile_handler(session).get_profile_info(test_id)
            except TypeError:
                _pi = None
            except Exception as err:
                raise

            sline = 60 * "="
            if _pi:
                output = ["%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile",
                                                           "Test ID"]]
            else:
                output = ['Test ID: {}'.format(_conv.test_id)]

            output.append("Timestamp: {}".format(in_a_while()))
            output.extend(["", sline, ""])
            output.extend(trace_output(_conv.trace))
            output.extend(["", sline, ""])
            output.extend(condition(_conv.events))
            output.extend(["", sline, ""])
            # and lastly the result
            info = {
                "events": _conv.events,
                "trace": _conv.trace
            }
            output.append(
                "RESULT: {}".format(self.represent_result(
                    info, eval_state(_conv.events))))
            output.append("")

            txt = "\n".join(output)

            print(txt)
    def print_info(self, test_id, filename=''):
        if 'conv' not in self.session:
            return
        else:
            _conv = self.session["conv"]

        sline = 60 * "="

        _pi = self._profile_info(test_id)

        if _pi:
            _keys = list(_pi.keys())
            _keys.sort()
            output = ["%s: %s" % (k, _pi[k]) for k in _keys]
        else:
            output = ['Test ID: {}'.format(_conv.test_id),
                      "Timestamp: {}".format(in_a_while())]

        output.extend(["", sline, ""])
        output.extend(trace_output(_conv.trace))
        output.extend(["", sline, ""])
        output.extend(condition(_conv.events))
        output.extend(["", sline, ""])
        output.extend(['Events', '{}'.format(_conv.events)])
        output.extend(["", sline, ""])
        # and lastly the result
        output.append(
            "RESULT: {}".format(self.print_result(_conv.events)))
        output.append("")

        txt = "\n".join(output)

        if filename:
            f = open(filename, 'w')
            f.write(txt)
            f.close()
        else:
            print(txt)