Beispiel #1
0
    def setUp(self):
        super(WebAPICapabilitiesHookTests, self).setUp()

        manager = ExtensionManager('')
        self.extension = WebAPICapabilitiesExtension(
            extension_manager=manager)
        self.url = get_root_url()
Beispiel #2
0
    def setUp(self):
        super(WebAPICapabilitiesHookTests, self).setUp()

        manager = ExtensionManager('')
        self.extension = WebAPICapabilitiesExtension(
            extension_manager=manager)
        self.url = get_root_url()
Beispiel #3
0
 def test_get(self):
     """Testing the GET / API"""
     rsp = self.apiGet(get_root_url(), expected_mimetype=root_item_mimetype)
     self.assertEqual(rsp['stat'], 'ok')
     self.assertTrue('uri_templates' in rsp)
     self.assertTrue('repository' in rsp['uri_templates'])
     self.assertEqual(
         rsp['uri_templates']['repository'],
         'http://testserver/api/repositories/{repository_id}/')
Beispiel #4
0
 def test_get(self):
     """Testing the GET / API"""
     rsp = self.apiGet(get_root_url(),
                       expected_mimetype=root_item_mimetype)
     self.assertEqual(rsp['stat'], 'ok')
     self.assertTrue('uri_templates' in rsp)
     self.assertTrue('repository' in rsp['uri_templates'])
     self.assertEqual(rsp['uri_templates']['repository'],
                      'http://testserver/api/repositories/{repository_id}/')
Beispiel #5
0
 def test_get_api_root_with_local_site(self):
     """Testing the GET / API with local sites"""
     self._login_user(local_site=True)
     rsp = self.apiGet(get_root_url('local-site-1'),
                       expected_mimetype=root_item_mimetype)
     self.assertEqual(rsp['stat'], 'ok')
     self.assertTrue('uri_templates' in rsp)
     self.assertTrue('repository' in rsp['uri_templates'])
     self.assertEqual(rsp['uri_templates']['repository'],
                      'http://testserver/s/local-site-1/api/'
                      'repositories/{repository_id}/')
Beispiel #6
0
    def test_get(self):
        """Testing the GET / API"""
        rsp = self.api_get(get_root_url(),
                           expected_mimetype=root_item_mimetype)
        self.assertEqual(rsp['stat'], 'ok')
        self.assertIn('uri_templates', rsp)
        self.assertIn('repository', rsp['uri_templates'])
        self.assertEqual(rsp['uri_templates']['repository'],
                         'http://testserver/api/repositories/{repository_id}/')

        self._check_common_root_fields(rsp)
Beispiel #7
0
 def test_get_with_site(self):
     """Testing the GET / API with local sites"""
     self._login_user(local_site=True)
     rsp = self.apiGet(get_root_url('local-site-1'),
                       expected_mimetype=root_item_mimetype)
     self.assertEqual(rsp['stat'], 'ok')
     self.assertTrue('uri_templates' in rsp)
     self.assertTrue('repository' in rsp['uri_templates'])
     self.assertEqual(
         rsp['uri_templates']['repository'],
         'http://testserver/s/local-site-1/api/'
         'repositories/{repository_id}/')
Beispiel #8
0
    def test_get(self):
        """Testing the GET / API"""
        rsp = self.api_get(get_root_url(),
                           expected_mimetype=root_item_mimetype)
        self.assertEqual(rsp['stat'], 'ok')
        self.assertIn('uri_templates', rsp)
        self.assertIn('repository', rsp['uri_templates'])
        self.assertEqual(
            rsp['uri_templates']['repository'],
            'http://testserver/api/repositories/{repository_id}/')

        self._check_common_root_fields(rsp)
Beispiel #9
0
    def test_get_capability_dvcs_disabled(self):
        """Testing the GET / API for capabilities with the DVCS feature
        disabled
        """
        with override_feature_check(dvcs_feature.feature_id, False):
            self.assertFalse(dvcs_feature.is_enabled())
            rsp = self.api_get(get_root_url(),
                               expected_mimetype=root_item_mimetype)

        self.assertEqual(rsp['stat'], 'ok')
        self.assertIn('capabilities', rsp)

        caps = rsp['capabilities']
        self.assertIn('review_requests', caps)
        self.assertNotIn('supports_history', caps['review_requests'])
Beispiel #10
0
    def test_get_with_site_and_cache(self):
        """Testing the GET / API with multiple local sites"""
        # djblets had a bug where the uri_templates were cached without any
        # consideration of the local site (or, more generally, the base uri).
        # In this case, fetching /s/<local_site>/api/ might return uri
        # templates for someone else's site. This was breaking rbt post.
        self.test_get_with_site()

        rsp = self.apiGet(get_root_url('local-site-2'),
                          expected_mimetype=root_item_mimetype)
        self.assertEqual(rsp['stat'], 'ok')
        self.assertTrue('uri_templates' in rsp)
        self.assertTrue('repository' in rsp['uri_templates'])
        self.assertEqual(rsp['uri_templates']['repository'],
                         'http://testserver/s/local-site-2/api/'
                         'repositories/{repository_id}/')
Beispiel #11
0
 def test_get_with_site_no_access(self):
     """Testing the GET / API without access to local site"""
     self.apiGet(get_root_url('local-site-1'), expected_status=403)
Beispiel #12
0
 def setup_http_not_allowed_list_test(self, user):
     return get_root_url()
 def test_get_with_site_no_access(self):
     """Testing the GET / API without access to local site"""
     self.apiGet(get_root_url('local-site-1'), expected_status=403)
 def setup_http_not_allowed_list_test(self, user):
     return get_root_url()
    def setUp(self):
        super(WebAPICapabilitiesHookTests, self).setUp()

        self.old_extension_id = self.extension.id
        self.url = get_root_url()