def call(tok=None):
   headers = {'X-Delegation-Token-V1': tok} if tok else None
   self.call('127.0.0.1', '*****@*****.**', headers)
   return {
     'cur_id': api.get_current_identity().to_bytes(),
     'peer_id': api.get_current_identity().to_bytes(),
   }
 def call(tok=None):
     headers = {'X-Delegation-Token-V1': tok} if tok else None
     self.call('127.0.0.1', '*****@*****.**', headers)
     return {
         'cur_id': api.get_current_identity().to_bytes(),
         'peer_id': api.get_current_identity().to_bytes(),
     }
Example #3
0
 def continuation(request, context, call_details):
   state.append(CapturedState(
       current_identity=api.get_current_identity().to_bytes(),
       is_superuser=api.is_superuser(),
       peer_identity=api.get_peer_identity().to_bytes(),
       peer_ip=api.get_peer_ip(),
       delegation_token=api.get_delegation_token(),
   ))
   return empty_pb2.Empty()
 def call_with_tokens(self, delegation_tok=None, luci_project=None):
     headers = {}
     if delegation_tok:
         headers['X-Delegation-Token-V1'] = delegation_tok
     if luci_project:
         headers[check.X_LUCI_PROJECT] = luci_project
     self.call('127.0.0.1', '*****@*****.**', headers)
     return {
         'cur_id': api.get_current_identity().to_bytes(),
         'peer_id': api.get_peer_identity().to_bytes(),
     }
  def call(self, remote_address, email, headers=None):
    """Mocks current user calls initialize_request_auth."""

    class User(object):
      def email(self):
        return email
    self.mock(
        endpoints_support.endpoints, 'get_current_user',
        lambda: User() if email else None)

    api.reset_local_state()
    endpoints_support.initialize_request_auth(remote_address, headers or {})
    return api.get_current_identity().to_bytes()
Example #6
0
    def call(self, remote_address, email, headers=None):
        """Mocks current user calls initialize_request_auth."""
        class User(object):
            def email(self):
                return email

        self.mock(endpoints_support.endpoints, 'get_current_user',
                  lambda: User() if email else None)

        api.reset_local_state()
        endpoints_support.initialize_request_auth(remote_address, headers
                                                  or {})
        return api.get_current_identity().to_bytes()
    def call(self, remote_address, email, headers=None):
        """Mocks current user in initialize_request_auth."""
        headers = (headers or {}).copy()
        if email:
            headers['Authorization'] = 'Bearer %s' % email

        # Mock ours auth.
        ident = model.Anonymous
        if email:
            ident = model.Identity(model.IDENTITY_USER, email)
        self.mock(api, 'check_oauth_access_token', lambda _: (ident, False))

        # Mock auth implemented by the Cloud Endpoints.
        class User(object):
            def email(self):
                return email

        self.mock(endpoints_support.endpoints, 'get_current_user',
                  lambda: User() if email else None)

        api.reset_local_state()
        endpoints_support.initialize_request_auth(remote_address, headers)
        return api.get_current_identity().to_bytes()
Example #8
0
 def get(self):
     test.assertEqual(model.Anonymous, api.get_current_identity())
     self.response.write('OK')
Example #9
0
 def get(self):
     self.response.write(
         json.dumps({
             'peer_id': api.get_peer_identity().to_bytes(),
             'cur_id': api.get_current_identity().to_bytes(),
         }))
Example #10
0
 def get(self):
     test.assertEqual(ident, api.get_current_identity())
     self.response.write('OK')
Example #11
0
 def get(self):
     self.response.write(api.get_current_identity().to_bytes())
Example #12
0
 def test_get_current_identity(self):
   """Ensure get_current_identity returns whatever was put in request cache."""
   api.get_request_cache().set_current_identity(model.Anonymous)
   self.assertEqual(model.Anonymous, api.get_current_identity())
Example #13
0
 def get(self):
   self.response.write(json.dumps({
     'peer_id': api.get_peer_identity().to_bytes(),
     'cur_id': api.get_current_identity().to_bytes(),
   }))
Example #14
0
 def test_get_current_identity_unitialized(self):
     """If request cache is not initialized, returns Anonymous."""
     self.assertEqual(api.get_current_identity(), model.Anonymous)
Example #15
0
 def test_get_current_identity_unitialized(self):
   """If set_current_identity wasn't called raises an exception."""
   with self.assertRaises(api.UninitializedError):
     api.get_current_identity()
Example #16
0
 def get(self):
   test.assertEqual(model.Anonymous, api.get_current_identity())
   self.response.write('OK')
Example #17
0
 def get(self):
   test.assertEqual(ident, api.get_current_identity())
   self.response.write('OK')
Example #18
0
 def get(self):
   self.response.write(api.get_current_identity().to_bytes())
Example #19
0
 def test_get_current_identity(self):
     """Ensure get_current_identity returns whatever was put in request cache."""
     ident = model.Identity.from_bytes("user:[email protected]")
     api.get_request_cache().current_identity = ident
     self.assertEqual(ident, api.get_current_identity())
Example #20
0
 def test_get_current_identity_unitialized(self):
     """If request cache is not initialized, returns Anonymous."""
     self.assertEqual(api.get_current_identity(), model.Anonymous)
Example #21
0
 def test_get_current_identity(self):
     """Ensure get_current_identity returns whatever was put in request cache."""
     ident = model.Identity.from_bytes('user:[email protected]')
     api.get_request_cache().current_identity = ident
     self.assertEqual(ident, api.get_current_identity())
Example #22
0
 def get(self):
     test.assertEqual(ident, api.get_current_identity())
     test.assertIs(auth_details, api.get_auth_details())
     self.response.write('OK')