コード例 #1
0
 def test_load_isolated_os_only_bad(self):
   data = {
     u'os': 'HP/UX',
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   with self.assertRaises(isolated_format.IsolatedError):
     isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #2
0
 def test_load_isolated_os_only_bad(self):
   data = {
     u'os': 'HP/UX',
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   with self.assertRaises(isolated_format.IsolatedError):
     isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #3
0
 def _expect_results(
     self, args, read_only, extra_vars, empty_file, root_dir=None):
   self._expected_isolated(args, read_only, empty_file)
   self._expected_saved_state(
       args, read_only, empty_file, extra_vars, root_dir)
   # Also verifies run_isolated.py will be able to read it.
   with open(self.isolated, 'rb') as f:
     isolated_format.load_isolated(f.read(), ALGO)
コード例 #4
0
 def test_load_isolated_bad_abs(self):
   for i in ('/a', 'a/..', 'a/', '\\\\a'):
     data = {
       u'files': {i: {u'l': u'somewhere'}},
       u'version': isolated_format.ISOLATED_FILE_VERSION,
     }
     with self.assertRaises(isolated_format.IsolatedError):
       isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #5
0
 def test_load_isolated_bad_abs(self):
   for i in ('/a', 'a/..', 'a/', '\\\\a'):
     data = {
       u'files': {i: {u'l': u'somewhere'}},
       u'version': isolated_format.ISOLATED_FILE_VERSION,
     }
     with self.assertRaises(isolated_format.IsolatedError):
       isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #6
0
 def _expect_results(
     self, args, read_only, extra_vars, empty_file, root_dir=None):
   self._expected_isolated(args, read_only, empty_file)
   self._expected_saved_state(
       args, read_only, empty_file, extra_vars, root_dir)
   # Also verifies run_isolated.py will be able to read it.
   with open(self.isolated, 'rb') as f:
     isolated_format.load_isolated(f.read(), ALGO)
コード例 #7
0
 def test_load_isolated_bad(self):
   data = {
     u'files': {
       u'a': {
         u'l': u'somewhere',
         u'h': u'0123456789abcdef0123456789abcdef01234567'
       }
     },
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   with self.assertRaises(isolated_format.IsolatedError):
     isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #8
0
 def test_load_isolated_bad(self):
   data = {
     u'files': {
       u'a': {
         u'l': u'somewhere',
         u'h': u'0123456789abcdef0123456789abcdef01234567'
       }
     },
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   with self.assertRaises(isolated_format.IsolatedError):
     isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
コード例 #9
0
 def test_load_isolated_os_only(self):
   # Tolerate 'os' on older version.
   data = {
     u'os': 'HP/UX',
     u'version': '1.3',
   }
   m = isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
   self.assertEqual(data, m)
コード例 #10
0
 def test_load_isolated_os_only(self):
   # Tolerate 'os' on older version.
   data = {
     u'os': 'HP/UX',
     u'version': '1.3',
   }
   m = isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
   self.assertEqual(data, m)
コード例 #11
0
  def test_load_isolated_path(self):
    # Automatically convert the path case.
    wrong_path_sep = u'\\' if os.path.sep == '/' else u'/'
    def gen_data(path_sep):
      return {
        u'command': [u'foo', u'bar'],
        u'files': {
          path_sep.join(('a', 'b')): {
            u'l': path_sep.join(('..', 'somewhere')),
          },
        },
        u'relative_cwd': path_sep.join(('somewhere', 'else')),
        u'version': isolated_format.ISOLATED_FILE_VERSION,
      }

    data = gen_data(wrong_path_sep)
    actual = isolated_format.load_isolated(
        json.dumps(data), isolateserver_mock.ALGO)
    expected = gen_data(os.path.sep)
    self.assertEqual(expected, actual)
コード例 #12
0
 def test_load_isolated_good(self):
   data = {
     u'command': [u'foo', u'bar'],
     u'files': {
       u'a': {
         u'l': u'somewhere',
       },
       u'b': {
         u'm': 123,
         u'h': u'0123456789abcdef0123456789abcdef01234567',
         u's': 3,
       }
     },
     u'includes': [u'0123456789abcdef0123456789abcdef01234567'],
     u'read_only': 1,
     u'relative_cwd': u'somewhere_else',
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   m = isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
   self.assertEqual(data, m)
コード例 #13
0
  def test_load_isolated_path(self):
    # Automatically convert the path case.
    wrong_path_sep = u'\\' if os.path.sep == '/' else u'/'
    def gen_data(path_sep):
      return {
        u'command': [u'foo', u'bar'],
        u'files': {
          path_sep.join(('a', 'b')): {
            u'l': path_sep.join(('..', 'somewhere')),
          },
        },
        u'relative_cwd': path_sep.join(('somewhere', 'else')),
        u'version': isolated_format.ISOLATED_FILE_VERSION,
      }

    data = gen_data(wrong_path_sep)
    actual = isolated_format.load_isolated(
        json.dumps(data), isolateserver_mock.ALGO)
    expected = gen_data(os.path.sep)
    self.assertEqual(expected, actual)
コード例 #14
0
 def test_load_isolated_good(self):
   data = {
     u'command': [u'foo', u'bar'],
     u'files': {
       u'a': {
         u'l': u'somewhere',
       },
       u'b': {
         u'm': 123,
         u'h': u'0123456789abcdef0123456789abcdef01234567',
         u's': 3,
       }
     },
     u'includes': [u'0123456789abcdef0123456789abcdef01234567'],
     u'read_only': 1,
     u'relative_cwd': u'somewhere_else',
     u'version': isolated_format.ISOLATED_FILE_VERSION,
   }
   m = isolated_format.load_isolated(json.dumps(data), isolateserver_mock.ALGO)
   self.assertEqual(data, m)
コード例 #15
0
 def test_load_isolated_empty(self):
     m = isolated_format.load_isolated('{}', isolateserver_mock.ALGO)
     self.assertEqual({}, m)
コード例 #16
0
 def test_load_isolated_empty(self):
   m = isolated_format.load_isolated('{}', isolateserver_mock.ALGO)
   self.assertEqual({}, m)