Beispiel #1
0
def test_authenticate_with_refresh_token():
    nubank_client = Nubank(client=MockHttpClient())
    nubank_client.authenticate_with_refresh_token('token', 'some-file.p12')

    assert nubank_client._feed_url == 'https://mocked-proxy-url/api/proxy/events_123'
    assert nubank_client._client.get_header(
        'Authorization') == 'Bearer access_token_123'
def test_authentication_with_refresh_token_failure_raise_exception(monkeypatch):
    response = create_fake_response({}, 401)

    monkeypatch.setattr('requests.post', MagicMock(return_value=response))
    with pytest.raises(NuException):
        nu = Nubank()
        nu.authenticate_with_refresh_token('some-token')
def test_authenticate_with_refresh_token(monkeypatch, authentication_return):
    monkeypatch.setattr(Discovery, '_update_proxy_urls', fake_update_proxy)
    monkeypatch.setattr(HttpClient, 'post', MagicMock(return_value=authentication_return))

    nubank_client = Nubank()

    nubank_client.authenticate_with_refresh_token('token', 'some-file.p12')

    assert nubank_client.feed_url == 'https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/events_123'
    assert nubank_client.client.get_header('Authorization') == 'Bearer access_token_123'
def test_authenticate_with_refresh_token_succeeds(monkeypatch, authentication_return, proxy_list_return):
    proxy_list = create_fake_response(proxy_list_return)
    monkeypatch.setattr('requests.get', MagicMock(return_value=proxy_list))
    response = create_fake_response(authentication_return)
    monkeypatch.setattr('requests.post', MagicMock(return_value=response))

    nubank_client = Nubank()
    nubank_client.authenticate_with_refresh_token('some-token')

    assert nubank_client.feed_url == 'https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/events_123'
    assert nubank_client.headers['Authorization'] == 'Bearer access_token_123'