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)
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
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
def test_missing_ident_error(): bad_token = jwt.encode({"not_identity": "bar"}, "secret") with pytest.raises(FlowclientConnectionError): Connection(url="foo", token=bad_token)
def test_token_decode_error(token): broken_token = token[25:] with pytest.raises(FlowclientConnectionError): Connection(url="foo", token=broken_token)
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)
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
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