예제 #1
0
파일: main.py 프로젝트: dizz/doyouspeakocci
    def get(self):
        """
        TODO: not yet commented.
        """
        client = uuid.uuid4().__str__()
        token = channel.create_channel(client)

        if Suite.all().count() > 0:
            running_since = Suite.all().order('date').get().date
        else:
            running_since = datetime.now()

        number_of_runs = Suite.all().count()

        ctfs = {}
        # run the test suite
        for elem in dir(tests):
            if elem.find('ctf_') != -1:
                func = getattr(tests, elem)
                ctfs[func.__name__] = func.__doc__.strip()

        template_values = {
            'client': client,
            'token': token,
            'number_of_runs': number_of_runs,
            'running_since': running_since,
            'tests': ctfs,
            }

        path = os.path.join(os.path.dirname(__file__), '../templates/index.html')
        self.response.out.write(template.render(path, template_values))
예제 #2
0
    def post(self):
        """
        TODO: not yet commented.
        """
        suite = Suite()
        suite.service_uri = self.request.get('service_uri')

        compliance_tests = []
        is_compliant = True

        # run the test suite
        for elem in dir(tests):
            if elem.find('ctf_') != -1:
                func = getattr(tests, elem)
                desc = func.__doc__.strip()

                # run the individual test
                test = Test(suite)
                test.name = func.__name__
                test.description = desc
                try:
                    func(suite.service_uri)
                    test.result = True
                except ComplianceError, e:
                    test.details = e.__str__()
                    is_compliant = False
                compliance_tests.append(test)

                # store test to database and add to result set
                test.put()
예제 #3
0
파일: main.py 프로젝트: dizz/doyouspeakocci
    def post(self):
        """
        TODO: not yet commented.
        """
        suite = Suite(key_name=uuid.uuid4().__str__())
        suite.put()

        # run the test suite
        is_compliant = True
        suite.service_uri = self.request.get('url')

        for elem in dir(tests):
            if elem.find('ctf_') != -1:
                func = getattr(tests, elem)

                # initialize a new test object
                test = Test(suite=suite)
                test.put()

                test.name = func.__name__
                test.description = func.__doc__.strip()

                # run the individual test
                auth = self.request.get('auth')
                if auth:
                    token = base64.b64encode(self.request.get('user') + ':' + self.request.get('pass'))
                    test.result = func(test, suite.service_uri, token)
                else:
                    test.result = func(test, suite.service_uri)

                is_compliant &= test.result

                # store test to database and add to result set
                test.put()
                channel.send_message(self.request.get('client'), simplejson.dumps(test.to_dict()))

        suite.is_compliant = is_compliant
        suite.put()
        #channel.send_message(self.request.get('client'), simplejson.dumps(suite.to_dict()))

        self.response.set_status(202)
        self.response.headers['Content-type'] = 'application/json'
        self.response.headers.add_header('Location', self.request.url + '/archive/' + suite.key().name())
        self.response.out.write(simplejson.dumps(suite.to_dict()))


# eof