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()
Example #3
0
    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")
Example #4
0
            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()
Example #7
0
    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")
Example #8
0
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'
Example #9
0
    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")
Example #10
0
    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")
Example #11
0
    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")
Example #12
0
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()
Example #13
0
 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)
Example #15
0
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()
Example #16
0
    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()
Example #17
0
    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.'}
Example #18
0
    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."}
Example #19
0
def test_index():
    assert index() == "hello world"
Example #20
0
 def should_response_hello_world_when_call_index(self):
     self.assertEqual(app.index(), "Hello, World!")
Example #21
0
def test():
    assert index() == "Hello world"
Example #22
0
def tests_index():
    assert index() == "hello, world"
def test_index():
    assert index() == "Test"
Example #24
0
def test_index():
    assert index() == "Hello, World "
    
def test_index():
    assert index() == "Hello, Jude!"
Example #26
0
def test_index():
    assert index() == "Hello, Nafisur!"
Example #27
0
def test_index():
    assert app.index()
Example #28
0
def test_index():
    assert index() == "Hi Sir"
Example #29
0
 def test_index(self):
     "Test the index page"
     assert app.index(self)
Example #30
0
def test_index():
    assert index()
def test_index():
    assert index() == "Hello, Incredible India!"
Example #32
0
def test_index():
	assert index() == "Sample Python flask project to understand Github actions!"
Example #33
0
def test_index():
    assert index() == "Hello, world!"
Example #34
0
 def test_index(self):
     content = app.index()
     
     for url in app.URLS:
         self.assertTrue(url in content)