Exemplo n.º 1
0
def post(handler):  # pragma: no cover
    password = handler.request.get('password')
    if not password:
        handler.response.write('"password" field missing.')
        return

    Password.get_or_insert(CQ_BOT_PASSWORD_KEY,
                           sha1=utils.password_sha1(password)).put()
    handler.response.write('Bot password successfully updated.')
Exemplo n.º 2
0
def post(handler): # pragma: no cover
  password = handler.request.get('password')
  if not password:
    handler.response.write('"password" field missing.')
    return

  Password.get_or_insert(
      CQ_BOT_PASSWORD_KEY,
      sha1=utils.password_sha1(password)
  ).put()
  handler.response.write('Bot password successfully updated.')
Exemplo n.º 3
0
  def test_post_multiple_empty(self):
    self.mock_current_user(is_admin=False)
    password = '******'
    Password(id=CQ_BOT_PASSWORD_KEY, sha1=utils.password_sha1(password)).put()

    old_count = Record.query().count()
    response = self.test_app.post('/post', params={'password': password})
    self.assertEquals('', response.body)
    self.assertEquals(old_count, Record.query().count())

    response = self.test_app.post('/post', params={
        'p': '{}', 'password': password})
    self.assertEquals('Empty record entries disallowed', response.body)
    self.assertEquals(old_count, Record.query().count())
Exemplo n.º 4
0
    def test_post_multiple_empty(self):
        self.mock_current_user(is_admin=False)
        password = '******'
        Password(id=CQ_BOT_PASSWORD_KEY,
                 sha1=utils.password_sha1(password)).put()

        old_count = Record.query().count()
        response = self.test_app.post('/post', params={'password': password})
        self.assertEquals('', response.body)
        self.assertEquals(old_count, Record.query().count())

        response = self.test_app.post('/post',
                                      params={
                                          'p': '{}',
                                          'password': password
                                      })
        self.assertEquals('Empty record entries disallowed', response.body)
        self.assertEquals(old_count, Record.query().count())
Exemplo n.º 5
0
 def test_password_sha1(self):
     self.assertEquals('018d644a17b71b65cef51fa0a523a293f2b3266f',
                       utils.password_sha1('cq'))
Exemplo n.º 6
0
 def _is_cq_bot(self):
   password = self.request.get('password')
   if not password:
     return False
   sha1 = utils.password_sha1(password)
   return sha1 == Password.get_by_id(CQ_BOT_PASSWORD_KEY).sha1
Exemplo n.º 7
0
 def _is_cq_bot(self):
     password = self.request.get('password')
     if not password:
         return False
     sha1 = utils.password_sha1(password)
     return sha1 == Password.get_by_id(CQ_BOT_PASSWORD_KEY).sha1
Exemplo n.º 8
0
 def test_password_sha1(self):
   self.assertEquals(
       '018d644a17b71b65cef51fa0a523a293f2b3266f',
       utils.password_sha1('cq'))