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.')
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.')
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())
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())
def test_password_sha1(self): self.assertEquals('018d644a17b71b65cef51fa0a523a293f2b3266f', utils.password_sha1('cq'))
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
def test_password_sha1(self): self.assertEquals( '018d644a17b71b65cef51fa0a523a293f2b3266f', utils.password_sha1('cq'))