text: # -*- coding:utf-8 -*-
  from mako import runtime, filters, cache
  UNDEFINED = runtime.UNDEFINED
  STOP_RENDERING = runtime.STOP_RENDERING
  __M_dict_builtin = dict
  __M_locals_builtin = locals
  _magic_number = 10
  _modified_time = 1509981050.400404
  _enable_loop = True
  _template_filename = 'htdocs/test.mako'
  _template_uri = 'test.mako'
  _source_encoding = 'utf-8'
  _exports = []
  
  
  
  def createTests(ec_seq, ec_info):
    """
        Creates the graphic output for all tests.
        :param ec_seq: Entity category sequence as a list." \
        :param ec_info: Entity category dictionary with.
        :return: A graphic element for each category.
        """
    element = ""
    for ec in ec_seq:
      name = ec
      desc = ""
      if ec in ec_info:
          name = ec_info[ec]["Name"]
          desc = ec_info[ec]["Description"]
  
      if ec == "":
          ec = "base"
      element += '<div id="' + ec + '" name="' + name + '" status="4" class="row extrarow" ' \
                     'onmouseover="showHoverColor(\'' + ec + '\');" onmouseout="showOriginalColor(\'' + ec + '\');">'
      element += '    <div class="col-md-7" onclick="toggleDisplay(\'' + ec + '_extra\');' \
          '                   toggleArrow(\'' + ec + '_arrow\',\'static/arrowRight.png\',\'static/arrowDown.png\');">' \
                              '<img id="' + ec + '_arrow" src="static/arrowRight.png" />' \
                              '&nbsp;' + name + '</div>'
      element += '    <div id="' + ec + '_status" class="col-md-3">Not run</div><div class="col-md-2">'
      element += '        <div class="btn btn-sm btn-primary" onclick="runTest(\'' + ec + '\')">Run test</div>'
      element += '    </div>'
      element += '    <div id="' + ec + '_extra" class="extra"><div class="inner_extra">'
      element += '        <div id="' + ec + '_result" class="result"><div class="textleft"><b>Test result</b><br />No result exists.</div></div>'
      element += '        <div id="' + ec + '_info" class="information"><div class="textright">' + desc +'</div></div>'
      element += '    </div></div>'
      element += '</div>'
  
    return element
  
  
  def render_body(context,**pageargs):
      __M_caller = context.caller_stack._push_frame()
      try:
          __M_locals = __M_dict_builtin(pageargs=pageargs)
          ec_info = context.get('ec_info', UNDEFINED)
          ec_seq = context.get('ec_seq', UNDEFINED)
          __M_writer = context.writer()
          __M_writer('<!DOCTYPE html>\n\n\n')
          __M_writer('\n\n<html>\n<head>\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\n    <link rel="stylesheet" type="text/css" href="static/style.css" media="all"/>\n    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">\n    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n    <script src="static/jquery.min.1.9.1.js"></script>\n    <script src="static/jquery.tinysort.charorder.min.js"></script>\n    <script src="static/jquery.tinysort.min.js"></script>\n\n\n    <title></title>\n    <script language="JavaScript">\n        var $j = jQuery.noConflict();\n\n        var sortByNameValue = 1;\n        var sortByStatusValue = 2;\n\n        var testRunning = -1;\n        var tests = new Array();\n        var testIsRunning = false;\n\n        var ec_seq = ')
          __M_writer(str(ec_seq))
          __M_writer(';\n        var sortOrder=sortByNameValue;\n        var isLoggedIn = false;\n\n        function toggleArrow(id,pic1,pic2) {\n            if ($j(\'#\'+id).attr(\'src\') === pic1) {\n                $j(\'#\'+id).attr(\'src\',pic2);\n            } else {\n                $j(\'#\'+id).attr(\'src\',pic1);\n            }\n        }\n\n\n        function toggleDisplay(id) {\n            if ($j(\'#\'+id).css(\'display\') === \'none\') {\n                $j(\'#\'+id).css(\'display\',\'block\')\n            } else {\n                $j(\'#\'+id).css(\'display\',\'none\')\n            }\n        }\n\n\n        function showHoverColor(row) {\n            $j(\'#\'+row).attr(\'color\',$j(\'#\'+row).css(\'background-color\'));\n            $j(\'#\'+row).css(\'background-color\', \'#cdebf2\');\n        }\n\n        function showOriginalColor(row) {\n            $j(\'#\'+row).css(\'background-color\', $j(\'#\'+row).attr(\'color\'));\n        }\n\n        function setupRow(row, color, result, status, statusOrder) {\n            $j(\'#\'+row).css(\'background-color\',color);\n            $j(\'#\'+row).attr(\'color\', color);\n            $j(\'#\'+row+"_result").html(\'<b>Test result</b><br />\'+result);\n            $j(\'#\'+row+"_status").html(status);\n            $j(\'#\'+row).attr(\'status\',statusOrder);\n            sortList();\n        }\n\n        function resetRow(row) {\n            setupRow(row, \'#ffffff\', \'No result exists.\', \'Not run\', 4);\n        }\n\n\n        function verifyData(cmp) {\n            if (tests[testRunning].length > 0) {\n                testname = tests[testRunning]\n            } else {\n                testname = \'base\';\n            }\n            cmp = jQuery.parseJSON(cmp);\n            if (cmp.data.more.length === 0 && cmp.data.less.length === 0) {\n                setupRow(testname, \'#b0e399\', \'Perfect match.\', \'OK\', 3);\n            } else if ((cmp.data.more.length > 0) && (cmp.data.less.length > 0)) {\n                setupRow(testname, \'#ff7f7f\', getRepsonseAsText(cmp.data), \'Too few & too many\', 1);\n            } else if (cmp.data.more.length > 0) {\n                setupRow(testname, \'#ff9900\', getRepsonseAsText(cmp.data), \'Too many\', 2);\n            } else {\n                setupRow(testname, \'#fdff7f\', getRepsonseAsText(cmp.data), \'Too few\', 2);\n            }\n            isLoggedIn = true;\n            hideLogin();\n            setTimeout("runNext()", 2000);\n        }\n\n        function getRepsonseAsText(data) {\n            text = "";\n            if (data.more.length>0) {\n                text = "The following parameters should NOT be returned: \\n<ul>\\n";\n                for(i=0;i<data.more.length;i++){\n                    text += "<li>" + data.more[i] + "</li>\\n";\n                }\n                text += "</ul>\\n"\n            }\n\n            if (data.less.length>0) {\n                text += "The following parameters should be returned: \\n<ul>\\n";\n                for(i=0;i<data.less.length;i++){\n                    text += "<li>" + data.less[i] + "</li>\\n";\n                }\n                text += "</ul>\\n"\n            }\n            return text;\n        }\n\n        function hideLogin() {\n            $j("#background").hide();\n            $j("#iframe").hide();\n            $j("#iframeDescription").hide();\n            $j(\'#execute\').remove();\n            $j(".container").show();\n        }\n\n\n        function showLogin() {\n            if ($j(\'#execute\').length > 0) {\n                $j(".container").hide();\n                $j("#background").show();\n                $j("#iframe").show();\n                $j("#iframeDescription").show();\n                $j("#execute").show();\n            }\n        }\n\n        function callIframe(id, url) {\n            $j(\'#iframe\').html(\'<IFRAME id="\'+id+\'" >\');\n\n            if (!isLoggedIn)\n                showLogin();\n\n            $j(\'iframe#\'+id).attr(\'src\', url);\n        }\n\n        function performTest(type) {\n            callIframe(\'execute\', "/ecat?c="+type);\n        }\n\n        function runNext() {\n            if ((tests.length > 0) && (testRunning<(tests.length-1))){\n                testRunning += 1;\n                performTest(tests[testRunning]);\n            } else {\n                testRunning = -1;\n                setNoTestIsRunning();\n            }\n        }\n\n        function runTest(testname) {\n            if (testIsRunning===false) {\n                setTestIsRunning();\n                testRunning = -1;\n                tests = new Array();\n                if (testname === "") {\n                    resetRow("base");\n                } else {\n                    resetRow(testname);\n                }\n                tests.push(testname);\n                runNext();\n            }\n        }\n\n        function setNoTestIsRunning() {\n            isLoggedIn = false;\n            testIsRunning = false;\n            $j(\'.btn\').removeAttr(\'style\');\n            $j(\'#running_test\').hide();\n            if (sortOrder===sortByStatusValue) {\n                sortByStatus();\n            }\n            sortList();\n        }\n\n        function setTestIsRunning() {\n            testIsRunning = true;\n            $j(\'.btn\').attr(\'style\',\'background-color:#c9c9c9;\');\n            $j(\'#running_test\').show();\n        }\n\n        function runAll() {\n            if (testIsRunning===false) {\n                setTestIsRunning();\n                testRunning = -1;\n                tests = new Array();\n                for(i=0;i<ec_seq.length;i++){\n                    ec = ec_seq[i];\n                    if (ec === "") {\n                        resetRow("base");\n                    } else {\n                        resetRow(ec);\n                    }\n                    tests.push(ec);\n                }\n                runNext();\n            }\n        }\n\n        function setupec_seq() {\n            ec_seq = new Array();\n            count = 0;\n            $j(\'#rowContainer\').children().each( function() {\n                ec_seq[count] = $j(this).attr(\'id\');\n                count++;\n            } );\n        }\n\n        function sortList() {\n            $j(\'ul>li\').tinysort();\n        }\n\n\n        function sortByName() {\n            sortOrder=sortByNameValue;\n            $j(\'#descHeader\').css(\'text-decoration\',\'underline\');\n            $j(\'#statusHeader\').css(\'text-decoration\',\'none\');\n            $j(\'div#rowContainer>div\').tinysort(\'\',{attr:\'name\'});\n             setupec_seq();\n        }\n\n        function sortByStatus() {\n            sortOrder=sortByStatusValue;\n            $j(\'#descHeader\').css(\'text-decoration\',\'none\');\n            $j(\'#statusHeader\').css(\'text-decoration\',\'underline\');\n            $j(\'div#rowContainer>div\').tinysort(\'\',{attr:\'status\'});\n            setupec_seq();\n        }\n\n        $j(document).ready(function() {\n            $j(\'#iframe\').width($j(\'html\').width()-40);\n            $j(\'#iframe\').height($j(\'html\').height()-140);\n            $j(\'#iframeDescription\').width($j(\'html\').width()-40);\n            $j(\'#iframeDescription\').height(100);\n            $j(\'#iframeDescription\').css(\'margin-top\',$j(\'html\').height()-140+\'px\');\n            sortByName();\n            sortList();\n        });\n\n    </script>\n</head>\n    <body>\n        <div id="background"></div>\n        <div id="iframe"></div>\n        <div id="iframeDescription">\n            <h2><i>To continue the tests you first have to authenticate your self.</i></h2>\n            <input type="button" value="Abort" onclick="hideLogin();setNoTestIsRunning();" >\n        </div>\n\n        <div class="container">\n            <div class="navbar navbar-default">\n                <div class="navbar-header">\n                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">\n                    <span class="icon-bar"></span>\n                    <span class="icon-bar"></span>\n                    <span class="icon-bar"></span>\n                  </button>\n                  <a class="navbar-brand" href="#"><img src="static/SWAMID.png" width="40" height="40" />\n                      <span class="h1">Test utility for verifying your IdPs category compliance</span></a>\n                </div>\n            </div>\n            <div id="formContainer" class="jumbotron" >\n                <div id="running_test"><img src="static/loader.gif" />&nbsp;&nbsp;Wait while testing.</div>\n                <span>This utility can test all IdP\'s contained in the metadata configured\n                    for its service provider.</span><br />\n                <span>An overview of test results from previously tested IdP\'s is available <a href="/overview">here</a></span><br>\n\n                <span>NOTE:</span><br />\n                <span>To run this utility your IdP must be allowed to be viewed in IFrames!</span><br />\n                <span>Do not use X-Frame-Options in the HTTP response header or add ALLOW-FROM for samltest.swamid.se\n                    in the X-Frame-Options.</span><br />\n                <span id="helpLinkShow" class="link" onclick="toggleDisplay(\'help_instructions\');\n                                                      toggleDisplay(\'helpLinkShow\');\n                                                      toggleDisplay(\'helpLinkHide\')">\n                    <img src="static/arrowRight.png" /> Show instructions\n                </span>\n                <span id="helpLinkHide" style="display:none;" class="link" onclick="toggleDisplay(\'help_instructions\');\n                                                      toggleDisplay(\'helpLinkShow\');\n                                                      toggleDisplay(\'helpLinkHide\')">\n                    <img src="static/arrowDown.png" /> Hide instructions\n                </span>\n                <div id="help_instructions">\n                    <span class="h2">Instructions</span><br />\n                    <div class="row">\n                        <div class="col-md-6">\n                            To start a test click on the run test button on the row of the test you would like to run.\n                            If you want to start all tests click on the Run all test button above the test list.\n                            You will be prompted to choose the correct IdP and perform validation before the test begins.\n                            If you want more information about a test or the response generated by a test click anywhere\n                            on the row of the test.\n                        </div>\n                        <div class="col-md-6">\n                            <div>\n                                <span class="h3">Possible test status</span>\n                                <table>\n                                    <tr>\n                                        <td><div id="notrun" class="status_help">Not run</div></td>\n                                        <td>Test has not been run</td>\n                                    </tr>\n                                    <tr>\n                                        <td><div id="ok" class="status_help">OK</div></td>\n                                        <td>Test finished without errors</td>\n                                    </tr>\n                                    <tr>\n                                        <td><div id="toofew" class="status_help">Too few</div></td>\n                                        <td>Test returned too few values</td>\n                                    </tr>\n                                    <tr>\n                                        <td><div id="toomany" class="status_help">Too many</div></td>\n                                        <td>Test returned too many values</td>\n                                    </tr>\n                                    <tr>\n                                        <td><div id="toomanyfew" class="status_help">Too few & too many</div></td>\n                                        <td>Test returned too few and too many values</td>\n                                    </tr>\n                                </table>\n                            </div>\n                        </div>\n                    </div>\n                </div>\n                <div class="row" style="background-color:transparent">\n                    <div class="col-md-10"><span class="h2">Available tests</span></div>\n                    <div class="col-md-2"><div class="btn btn-lg btn-primary mainbtn" onclick="runAll();" >Run all tests</div></div>\n                </div>\n                <div>\n                    <div class="row" style="background-color: #c9c9c9">\n                        <div id="descHeader" class="col-md-7">Description&nbsp;<img src="static/arrowDown.png" class="sort" onclick="sortByName()"/></div>\n                        <div id="statusHeader" class="col-md-3">Status&nbsp;<img src="static/arrowDown.png" class="sort" onclick="sortByStatus()"/></div>\n                        <div class="col-md-2">Test</div>\n                    </div>\n                    <div id="rowContainer">\n                    ')
          __M_writer(str(createTests(ec_seq, ec_info)))
          __M_writer('\n                    </div>\n                    <div class="row"></div>\n                </div>\n            </div>\n        </div>\n    </body>\n</html>\n')
          return ''
      finally:
          context.caller_stack._pop_frame()
  
  
  """
  __M_BEGIN_METADATA
  {"source_encoding": "utf-8", "line_map": {"16": 4, "64": 372, "52": 0, "70": 64, "59": 1, "60": 38, "61": 62, "62": 62, "63": 372}, "uri": "test.mako", "filename": "htdocs/test.mako"}
  __M_END_METADATA
  """
  