def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()

    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'), pytest.raises(InvalidClientError):
        auth.authenticate()
def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()

    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'
                  ), pytest.raises(InvalidClientError):
        auth.authenticate()
def test_should_get_authenticated_session():
    mendeley = configure_mendeley()
    auth = mendeley.start_authorization_code_flow()

    with cassette('fixtures/auth/authorization_code/get_authenticated_session.yaml'):
        session = auth.authenticate('https://example.com?state=state1234&code=VE1PtGf81OnTA97S545_9a7GWCA')

        assert session.token['access_token']
        assert session.host == 'https://api.mendeley.com'
def test_should_get_authenticated_session():
    mendeley = configure_mendeley()
    auth = mendeley.start_client_credentials_flow()

    with cassette('fixtures/auth/client_credentials/get_authenticated_session.yaml'):
        session = auth.authenticate()

        assert session.token['access_token']
        assert session.host == 'https://api.mendeley.com'
def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()
    
    # We should never get an access token back
    # and the OAuth library should be unhappy about that
    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'), pytest.raises(MissingTokenError):
        auth.authenticate()
Example #6
0
def test_should_get_authenticated_session():
    mendeley = configure_mendeley()
    auth = mendeley.start_client_credentials_flow()

    with cassette(
            'fixtures/auth/client_credentials/get_authenticated_session.yaml'):
        session = auth.authenticate()

        assert session.token['access_token']
        assert session.host == 'https://api.mendeley.com'
Example #7
0
def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()

    # We should never get an access token back
    # and the OAuth library should be unhappy about that
    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'
                  ), pytest.raises(MissingTokenError):
        auth.authenticate()
def test_should_get_authenticated_session():
    mendeley = configure_mendeley()
    auth = mendeley.start_authorization_code_flow()

    with cassette(
            'fixtures/auth/authorization_code/get_authenticated_session.yaml'):
        session = auth.authenticate(
            'https://example.com?state=state1234&code=VE1PtGf81OnTA97S545_9a7GWCA'
        )

        assert session.token['access_token']
        assert session.host == 'https://api.mendeley.com'