diff --git a/docs/src/installing/ametnes.md b/docs/src/installing/ametnes.md
index 182ec2d..3027a86 100644
--- a/docs/src/installing/ametnes.md
+++ b/docs/src/installing/ametnes.md
@@ -5,7 +5,7 @@ data-center, in AWS, GCP or Azure.
Nesis is available on the Ametnes Platform and can be deployed in your kubernetes cluster wherever you host it.
-The first step is to setup your kubernetes cluster as an Ametnes Application Location. See these detailed instructions.
+The first step is to set up your kubernetes cluster as an Ametnes Application Location. See these detailed instructions.
## Create the service
diff --git a/nesis/api/core/document_loaders/minio.py b/nesis/api/core/document_loaders/minio.py
index c8c5281..7e4064c 100644
--- a/nesis/api/core/document_loaders/minio.py
+++ b/nesis/api/core/document_loaders/minio.py
@@ -269,6 +269,23 @@ def validate_connection_info(connection: Dict[str, Any]) -> Dict[str, Any]:
assert not isblank(
connection.get("dataobjects")
), "One or more buckets must be supplied"
+
+ endpoint = connection.get("endpoint")
+ dataobjects = connection.get("dataobjects")
+
+ endpoint_parts = endpoint.split("://")
+ client = Minio(
+ endpoint=endpoint_parts[1].split("/")[0],
+ access_key=connection.get("user"),
+ secret_key=connection.get("password"),
+ secure=endpoint_parts[0] == "https",
+ )
+
+ try:
+ list(client.list_objects(dataobjects.split(",")[0], recursive=True))
+ except:
+ raise ValueError(f"Failed to connect to minio instance {endpoint}")
+
return {
key: val
for key, val in connection.items()
diff --git a/nesis/api/tests/core/document_loaders/test_minio.py b/nesis/api/tests/core/document_loaders/test_minio.py
index e2b8b02..b758f79 100644
--- a/nesis/api/tests/core/document_loaders/test_minio.py
+++ b/nesis/api/tests/core/document_loaders/test_minio.py
@@ -111,3 +111,35 @@ def test_fetch_documents(
"self_link": "https://s3.endpoint/buckets/SomeName",
},
)
+
+
+@mock.patch("nesis.api.core.document_loaders.minio.Minio")
+def test_validate_connection_info(
+ minio_instance: mock.MagicMock, cache: mock.MagicMock, session: Session
+) -> None:
+
+ connection = {
+ "endpoint": "https://s3.endpoint",
+ "user": "",
+ "password": "",
+ "dataobjects": "bucketname",
+ }
+
+ # Test missing endpoint
+ with pytest.raises(AssertionError) as ex_info:
+ minio.validate_connection_info(connection={})
+ assert "An endpoint must be supplied" in str(ex_info)
+
+ # Test missing bucket
+ with pytest.raises(AssertionError) as ex_info:
+ minio.validate_connection_info(connection={"endpoint": "some.endpoint"})
+ assert "One or more buckets must be supplied" in str(ex_info)
+
+ # Test connection to minio
+ minio_client = mock.MagicMock()
+ minio_instance.return_value = minio_client
+ minio_client.list_objects.side_effect = Exception("Connection failed")
+
+ with pytest.raises(ValueError) as ex_info:
+ minio.validate_connection_info(connection=connection)
+ assert "Failed to connect to minio instance" in str(ex_info)