コード例 #1
0
 def test_bad_body(self):
   env = machine_token_pb2.MachineTokenEnvelope()
   env.token_body = 'blah-blah-blah'
   env.key_id = 'signing_key'
   env.rsa_sha256 = 'signature'
   raw_token = base64.b64encode(env.SerializeToString())
   with self.assertRaises(machine_auth.BadTokenError):
     self.call(raw_token=raw_token)
   self.assertTrue(self.has_log('Failed to deserialize the token'))
コード例 #2
0
 def call(self, body=None, raw_token=None):
   if body:
     env = machine_token_pb2.MachineTokenEnvelope()
     env.token_body = body.SerializeToString()
     env.key_id = 'signing_key'
     env.rsa_sha256 = 'signature'
     raw_token = base64.b64encode(env.SerializeToString())
   req = webapp2.Request({})
   if raw_token:
     req.headers['X-Luci-Machine-Token'] = raw_token
   return machine_auth.machine_authentication(req)