Beispiel #1
0
def test_launch():
    consumer_key = 'key1'
    consumer_secret = 'secret1'
    launch_url = 'http://localhost:8000/hub/lti/launch'
    headers = {}
    oauth_timestamp = time.time()
    oauth_nonce = str(time.time())
    extra_args = {'arg1': 'value1'}

    args = make_args(consumer_key, consumer_secret, launch_url,
                     oauth_timestamp, oauth_nonce, extra_args)

    validator = LTILaunchValidator({consumer_key: consumer_secret})

    assert validator.validate_launch_request(launch_url, headers, args)
Beispiel #2
0
def test_wrong_secret():
    consumer_key = 'key1'
    consumer_secret = 'secret1'
    launch_url = 'http://localhost:8000/hub/lti/launch'
    headers = {}
    oauth_timestamp = time.time()
    oauth_nonce = str(time.time())
    extra_args = {'arg1': 'value1'}

    args = make_args(consumer_key, consumer_secret, launch_url,
                     oauth_timestamp, oauth_nonce, extra_args)

    validator = LTILaunchValidator({consumer_key: 'wrongsecret'})

    with pytest.raises(web.HTTPError):
        validator.validate_launch_request(launch_url, headers, args)
Beispiel #3
0
def test_dubious_extra_args():
    consumer_key = 'key1'
    consumer_secret = 'secret1'
    launch_url = 'http://localhost:8000/hub/lti/launch'
    headers = {}
    oauth_timestamp = time.time()
    oauth_nonce = str(time.time())
    extra_args = {'arg1': 'value1'}

    args = make_args(consumer_key, consumer_secret, launch_url,
                     oauth_timestamp, oauth_nonce, extra_args)

    validator = LTILaunchValidator({consumer_key: consumer_secret})

    assert validator.validate_launch_request(launch_url, headers, args)

    args['extra_credential'] = 'i have admin powers'
    with pytest.raises(web.HTTPError):
        validator.validate_launch_request(launch_url, headers, args)
Beispiel #4
0
def test_partial_replay_timestamp():
    consumer_key = 'key1'
    consumer_secret = 'secret1'
    launch_url = 'http://localhost:8000/hub/lti/launch'
    headers = {}
    oauth_timestamp = time.time()
    oauth_nonce = str(time.time())
    extra_args = {'arg1': 'value1'}

    args = make_args(consumer_key, consumer_secret, launch_url,
                     oauth_timestamp, oauth_nonce, extra_args)

    validator = LTILaunchValidator({consumer_key: consumer_secret})

    assert validator.validate_launch_request(launch_url, headers, args)

    args['oauth_timestamp'] = str(int(float(args['oauth_timestamp'])) - 1)
    with pytest.raises(web.HTTPError):
        validator.validate_launch_request(launch_url, headers, args)