def test_missing_event_type(self): app.current_request = Request( push, { 'X-Hub-Signature': 'sha=whatever', 'X-GitHub-Delivery': uuid.uuid4().hex, }) with pytest.raises(BadRequestError): index()
def test_no_signature(self): CONFIG['SECRET'] = 'very-secret' app.current_request = Request(push, { 'X-GitHub-Event': 'push', 'X-GitHub-Delivery': uuid.uuid4().hex, }) with pytest.raises(BadRequestError): index()
def test_no_signature(self): CONFIG["SECRET"] = "very-secret" app.current_request = Request(push, { "X-GitHub-Event": "push", "X-GitHub-Delivery": uuid.uuid4().hex }) with pytest.raises(BadRequestError): index("123")
def create_app(): app = Flask(__name__) with app.app_context(): print(index(test[INPUT])) actual = (index(test[INPUT])) expected = test[EXPECTED] print(expected) self.assertEqual(actual, expected)
def test_wrong_signature_format(self): CONFIG['SECRET'] = 'very-secret' app.current_request = Request( push, { 'X-GitHub-Event': 'push', 'X-Hub-Signature': 'whatever', 'X-GitHub-Delivery': uuid.uuid4().hex, }) with pytest.raises(BadRequestError): index('123')
def test_wrong_signature(self): CONFIG['SECRET'] = 'very-secret' app.current_request = Request( push, { 'X-GitHub-Event': 'push', 'X-Hub-Signature': 'sha=whatever', 'X-GitHub-Delivery': uuid.uuid4().hex, }) with pytest.raises(UnauthorizedError): index()
def test_missing_event_type(self): app.current_request = Request( push, { "X-Hub-Signature": "sha=whatever", "X-GitHub-Delivery": uuid.uuid4().hex }, ) with pytest.raises(BadRequestError): index("123")
def test_index_should_set_session_key_user(): """ This is a test example, please delete this test before starting the TP. This is a test example, please delete this test before starting the TP. This is a test example, please delete this test before starting the TP. This is a test example, please delete this test before starting the TP. """ # Call app.index() to fill the session app.index() # Assert that the session is well filled assert app.get_session()['dino'] == 'TREX'
def test_blacklist_checksum_default(self): CONFIG["SECRET"] = "very-secret" app.current_request = Request( push, { "X-GitHub-Event": "push", "X-Hub-Signature": "crc32=whatever", "X-GitHub-Delivery": uuid.uuid4().hex, }, ) with pytest.raises(BadRequestError): index("123")
def test_wrong_signature_format(self): CONFIG["SECRET"] = "very-secret" app.current_request = Request( push, { "X-GitHub-Event": "push", "X-Hub-Signature": "whatever", "X-GitHub-Delivery": uuid.uuid4().hex, }, ) with pytest.raises(BadRequestError): index("123")
def test_blacklist_checksum_custom(self): CONFIG["SECRET"] = "very-secret" CONFIG["HASHLIB_BLACKLIST"] = set(["poly1305-hmac"]) app.current_request = Request( push, { "X-GitHub-Event": "push", "X-Hub-Signature": "poly1305-hmac=whatever", "X-GitHub-Delivery": uuid.uuid4().hex, }, ) with pytest.raises(BadRequestError): index("123")
def do_setup(): """ :return: """ #todo: setup """ if bottle.request.method == 'GET': return bottle.template('setup') else: prms = bottle.request.POST aconfig = configparser.ConfigParser() aconfig['system'] = { 'login_required': prms.get('login_required', default = 0), } with open('%s/config.ini' % appconf.basepath, 'w+', encoding='utf-8') as f: aconfig.write(f) bottle.redirect('/setup_ok') """ aconfig = configparser.ConfigParser() aconfig['system'] = { 'login_required': 0, } with open('%s/config.ini' % appconf.basepath, 'w+', encoding='utf-8') as f: aconfig.write(f) from app import index init_app() baseApp.route('/', method=['GET', 'POST'], callback=index) return index()
def _render_candlestick(self, stock='', *args, **kwargs): from app import index, draw if args == '': response = index() else: response = draw(stock) return jinja2.Markup(response)
def test_index_multiple(self, event): self.logger.info('Running test: %s', get_function_name(__name__)) self.logger.info('Event: {}'.format(event)) lambda_context = FakeLambdaContext() response = app.index(event=event, context=lambda_context) self.assertTrue(response)
def do_login(): for u in sess.query(Users).filter_by(username=request.form['username']): m = hashlib.sha256() m.update(request.form['password'].encode("utf-8")) hashpwd = m.hexdigest() if u.password.strip() == hashpwd or u.password.strip( ) == hashpwd[0:59]: session['logged_in'] = True session['userid'] = u.userid else: return render_template('index.html', login='******') return app.index()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) label = tk.Label(self, text="Users (\U00002713 - Online, \U0000274C - Offline)") label.pack(side="top") users = app.index() usersBox = tk.Listbox(self, height=400, width=200) count = 0 for user in users: # Check if online usersBox.insert(count, "\U0000274C"+user['user']) usersBox.pack()
def test_no_secret(self): app.current_request = Request( push, { 'X-GitHub-Event': 'push', 'X-Hub-Signature': 'whatever', 'X-GitHub-Delivery': uuid.uuid4().hex, }) stubber = Stubber(SNS) stubber.add_response('list_topics', {'Topics': [{ 'TopicArn': 'arn:foo:bar:push' }]}) stubber.add_response('publish', {'MessageId': '1234'}) with stubber: response = index() assert response == {'Code': 'Ok', 'Message': 'Webhook received.'}
def test_no_secret(self): app.current_request = Request( push, { "X-GitHub-Event": "push", "X-Hub-Signature": "whatever", "X-GitHub-Delivery": uuid.uuid4().hex, }, ) stubber = Stubber(SNS) stubber.add_response( "list_topics", {"Topics": [{ "TopicArn": "arn:foo:bar:123_push" }]}) stubber.add_response("publish", {"MessageId": "1234"}) with stubber: response = index("123") assert response == {"Code": "Ok", "Message": "Webhook received."}
def test_index(): assert index() == "hello world"
def should_response_hello_world_when_call_index(self): self.assertEqual(app.index(), "Hello, World!")
def test(): assert index() == "Hello world"
def tests_index(): assert index() == "hello, world"
def test_index(): assert index() == "Test"
def test_index(): assert index() == "Hello, World "
def test_index(): assert index() == "Hello, Jude!"
def test_index(): assert index() == "Hello, Nafisur!"
def test_index(): assert app.index()
def test_index(): assert index() == "Hi Sir"
def test_index(self): "Test the index page" assert app.index(self)
def test_index(): assert index()
def test_index(): assert index() == "Hello, Incredible India!"
def test_index(): assert index() == "Sample Python flask project to understand Github actions!"
def test_index(): assert index() == "Hello, world!"
def test_index(self): content = app.index() for url in app.URLS: self.assertTrue(url in content)