Exemple #1
0
def test_https_warning(token):
    """
    Test that connection object has the right properties.
    """
    with pytest.warns(UserWarning,
                      match="Communications with this server are NOT SECURE."):
        c = Connection(url="foo", token=token)
Exemple #2
0
def test_login(token):
    """
    Test that connection object has the right properties.
    """
    c = Connection(url="foo", token=token)
    assert "foo" == c.url
    assert token == c.token
    assert "bar" == c.user
    assert "Authorization" in c.session.headers
Exemple #3
0
def test_login(token):
    """
    Test that connection object has the right properties.
    """
    c = Connection(url="foo", token=token)
    assert "foo" == c.url
    assert token == c.token
    assert "bar" == c.user
    assert "Authorization" in c.session.headers
    assert isinstance(c.session.verify,
                      Mock)  # Shouldn't be set if no ssl_certificate passed
Exemple #4
0
def test_missing_ident_error():
    bad_token = jwt.encode({"not_identity": "bar"}, "secret")
    with pytest.raises(FlowclientConnectionError):
        Connection(url="foo", token=bad_token)
Exemple #5
0
def test_token_decode_error(token):
    broken_token = token[25:]
    with pytest.raises(FlowclientConnectionError):
        Connection(url="foo", token=broken_token)
Exemple #6
0
def test_connection_repr(token):
    """
    Test string representation of Connection object is correct.
    """
    c = Connection(url="foo", token=token)
    assert "bar@foo v0" == str(c)
Exemple #7
0
def test_no_warning_for_https(token, monkeypatch):
    """Test that no insecure warning is raised when connecting via https."""
    with pytest.warns(None) as warnings_record:
        c = Connection(url="https://foo", token=token)
    assert not warnings_record.list
Exemple #8
0
def test_ssl_cert_path_set(token):
    """
    Test that if a path to certificate is given it gets set on the session object.
    """
    c = Connection(url="foo", token=token, ssl_certificate="DUMMY_CERT_PATH")
    assert "DUMMY_CERT_PATH" == c.session.verify