Beispiel #1
0
def test_oauth_middleware_init_bad_response():
    fake_key_url = 'http://fake-url'
    responses.add(responses.GET, fake_key_url, status=404)

    auth_middleware = JwtMiddleware()
    with pytest.raises(UaaError):
        auth_middleware.initialize(fake_key_url)
Beispiel #2
0
def test_oauth_middleware_init_fail(mock_get):
    mock_get.side_effect = requests.exceptions.ConnectionError(
        'test exception')
    auth_middleware = JwtMiddleware()

    with pytest.raises(UaaError):
        auth_middleware.initialize('http://some-fake-url')
Beispiel #3
0
def test_oauth_middleware_init_bad_response():
    fake_key_url = "http://fake-url"
    responses.add(responses.GET, fake_key_url, status=404)

    auth_middleware = JwtMiddleware()
    with pytest.raises(UaaError):
        auth_middleware.initialize(fake_key_url)
Beispiel #4
0
def test_oauth_middleware_init_ok():
    fake_key_url = "http://fake-url"
    responses.add(responses.GET, fake_key_url, status=200, body=json.dumps({"value": RSA_2048_PUB_KEY}))

    auth_middleware = JwtMiddleware()
    auth_middleware.initialize(fake_key_url)

    assert auth_middleware._verification_key == RSA_2048_PUB_KEY
Beispiel #5
0
def test_oauth_middleware_init_ok():
    fake_key_url = 'http://fake-url'
    responses.add(responses.GET,
                  fake_key_url,
                  status=200,
                  body=json.dumps({'value': RSA_2048_PUB_KEY}))

    auth_middleware = JwtMiddleware()
    auth_middleware.initialize(fake_key_url)

    assert auth_middleware._verification_key == RSA_2048_PUB_KEY
Beispiel #6
0
def test_oauth_middleware_init_fail(mock_get):
    mock_get.side_effect = requests.exceptions.ConnectionError("test exception")
    auth_middleware = JwtMiddleware()

    with pytest.raises(UaaError):
        auth_middleware.initialize("http://some-fake-url")