예제 #1
0
 def test_importer_config_post_bad(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual({'text': 'Invalid config format.'}, response.json)
   self.assertEqual([], importer.read_config())
예제 #2
0
 def test_importer_config_post_ok(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=200)
   self.assertEqual({'ok': True}, response.json)
   self.assertEqual(GOOD_IMPORTER_CONFIG, importer.read_config())
 def test_importer_config_post_locked(self):
   self.mock(handlers_frontend.config, 'is_remote_configured', lambda: True)
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=409)
   self.assertEqual(
       {'text': 'The configuration is managed elsewhere'}, response.json)
 def test_importer_config_post_bad(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual(
       {'text': '"url" field is required in TarballEntry'}, response.json)
   self.assertEqual('', importer.read_config())
 def test_importer_config_post_ok(self):
   self.mock_admin()
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=200)
   self.assertEqual({'ok': True}, response.json)
   self.assertEqual(GOOD_IMPORTER_CONFIG, importer.read_config())
예제 #6
0
 def test_importer_config_post_bad(self):
     response = self.app.post_json(
         '/auth_service/api/v1/importer/config',
         {'config': BAD_IMPORTER_CONFIG},
         headers={
             'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()
         },
         status=400)
     self.assertEqual({'text': 'Invalid config format.'}, response.json)
     self.assertEqual([], importer.read_config())
 def test_importer_config_post_locked(self):
   self.mock_admin()
   self.mock(handlers_frontend.config, 'is_remote_configured', lambda: True)
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=409)
   self.assertEqual(
       {'text': 'The configuration is managed elsewhere'}, response.json)
 def test_importer_config_post_bad(self):
   self.mock_admin()
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual(
       {'text': '"url" field is required in TarballEntry'}, response.json)
   self.assertEqual('', importer.read_config())