Пример #1
0
    def testPostAndGet(self):
        testing_common.SetIpAllowlist(['remote_ip'])

        builder_name = 'Mac Builder'
        change = '{"commits": [{"repository": "chromium", "git_hash": "git hash"}]}'
        target = 'telemetry_perf_tests'
        cas_instance = 'https://isolate.server'
        cas_digest = 'a0c28d99182661887feac644317c94fa18eccbbb'

        params = {
            'builder_name': builder_name,
            'change': change,
            'cas_instance': cas_instance,
            'cas_map': json.dumps({target: cas_digest}),
        }
        self.testapp.post('/api/cas', params, status=200)

        params = {
            'builder_name': builder_name,
            'change': change,
            'target': target,
        }
        response = self.testapp.get('/api/cas', params, status=200)
        expected_body = json.dumps({
            'cas_instance': cas_instance,
            'cas_digest': cas_digest
        })
        self.assertEqual(response.normal_body, expected_body)
Пример #2
0
 def testGet_WithNonInternalUserAndAllowlistedIP(self):
   self._AddMockInternalData()
   self.UnsetCurrentUser()
   datastore_hooks.InstallHooks()
   testing_common.SetIpAllowlist(['123.45.67.89'])
   query = '/graph_csv?test_path=ChromiumPerf/win7/dromaeo/dom&num_points=3'
   expected = [['revision', 'value']]
   self._CheckGet(query, expected, status=500)
Пример #3
0
  def testPostInvalidChangeBecauseOfUnknownRepository(self):
    testing_common.SetIpAllowlist(['remote_ip'])

    params = {
        'builder_name': 'Mac Builder',
        'change': '{"commits": [{"repository": "foo", "git_hash": "hash"}]}',
        'isolate_map': '{"telemetry_perf_tests": "a0c28d9"}',
    }
    self.testapp.post('/api/isolate', params, status=400)
Пример #4
0
 def testGet_AllowlistedIPOnly(self):
   self.PatchDatastoreHooksRequest('123.45.67.89')
   self._AddMockInternalData()
   self.UnsetCurrentUser()
   datastore_hooks.InstallHooks()
   testing_common.SetIpAllowlist(['123.45.67.89'])
   query = '/graph_csv?test_path=ChromiumPerf/win7/dromaeo/dom&num_points=3'
   expected = [['revision', 'value'], ['47', '94.0'], ['48', '96.0'],
               ['49', '98.0']]
   self._CheckGet(query, expected, allowlisted_ip='123.45.67.89')
Пример #5
0
 def testPostPermissionDenied(self):
     testing_common.SetIpAllowlist([])
     self.testapp.post('/api/cas', status=401)
Пример #6
0
    def testPost_External_Oauth_Fails(self):
        testing_common.SetIpAllowlist(['invalid'])
        self.SetCurrentUserOAuth(testing_common.EXTERNAL_USER)
        self.SetCurrentClientIdOAuth(api_auth.OAUTH_CLIENT_ID_ALLOWLIST[0])

        self.Post('/api/cas', self._ValidParams(), status=403)
Пример #7
0
    def testPost_Anonymous_NotAllowlisted_Fails(self):
        testing_common.SetIpAllowlist(['invalid'])
        self.SetCurrentUserOAuth(None)

        self.Post('/api/cas', self._ValidParams(), status=401)
Пример #8
0
    def testPost_Anonymous_Allowlisted_Succeeds(self):
        testing_common.SetIpAllowlist(['remote_ip'])
        self.SetCurrentUserOAuth(None)

        self.Post('/api/cas', self._ValidParams(), status=200)
Пример #9
0
  def testPost_Internal_Oauth_Succeeds(self):
    testing_common.SetIpAllowlist(['invalid'])
    self.SetCurrentUserOAuth(testing_common.INTERNAL_USER)
    self.SetCurrentClientIdOAuth(api_auth.OAUTH_CLIENT_ID_ALLOWLIST[0])

    self.Post('/api/isolate', self._ValidParams(), status=200)
Пример #10
0
 def testGet_NoTestPathGiven_GivesError(self):
   testing_common.SetIpAllowlist(['123.45.67.89'])
   self.testapp.get(
       '/graph_csv', extra_environ={'REMOTE_ADDR': '123.45.67.89'}, status=400)