Пример #1
0
    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
Пример #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()