def test_privileged(self):
        """Test being privileged (never get locked)."""
        self.mock.has_access.return_value = True
        access.check_access_and_get_testcase(self.testcase.key.id())

        with self.assertRaises(helpers.EarlyExitException) as cm:
            access.check_access_and_get_testcase(self.testcase.key.id() + 1)
        self.assertEqual(404, cm.exception.status)
Beispiel #2
0
    def wrapper(self):
        """Wrapper."""
        testcase_id = helpers.cast(self.request.get('testcaseId'), int,
                                   "The param 'testcaseId' is not a number.")

        testcase = access.check_access_and_get_testcase(testcase_id)
        return func(self, testcase)
    def post(self):
        """Serve the testcase JSON."""
        testcase_id = request.get('testcaseId')
        testcase = access.check_access_and_get_testcase(testcase_id)

        testcase_dict = _prepare_testcase_dict(testcase)
        return self.render_json(testcase_dict)
Beispiel #4
0
    def post(self):
        """Serve the testcase detail HTML page."""
        testcase_id = self.request.get('testcaseId')
        testcase = access.check_access_and_get_testcase(testcase_id)

        testcase_dict = _prepare_testcase_dict(testcase)
        self.render_json(testcase_dict)
Beispiel #5
0
def get(self):
    """Get testcase file and write it to the handler."""
    testcase_id = request.get('id')
    testcase = access.check_access_and_get_testcase(testcase_id)

    blob_info, _ = get_testcase_blob_info(testcase)

    save_as_filename = 'testcase-%s-%s' % (
        testcase.key.id(), blob_info.filename[-PREVIEW_BLOB_FILENAME_LENTGH:])

    content_disposition = str('attachment; filename=%s' % save_as_filename)
    return self.serve_gcs_object(blob_info.bucket, blob_info.object_path,
                                 content_disposition)
 def test_not_logged_in(self):
     """Test not logged in."""
     self.mock.get_user_email.return_value = ''
     with self.assertRaises(helpers.UnauthorizedException):
         access.check_access_and_get_testcase(self.testcase.key.id())
Beispiel #7
0
def get_testcase_detail_by_id(testcase_id):
  """Get testcase detail for rendering the testcase detail page."""
  testcase = access.check_access_and_get_testcase(testcase_id)
  return get_testcase_detail(testcase)