Antonio-RiveroMartnez commented on code in PR #23099:
URL: https://github.com/apache/superset/pull/23099#discussion_r1110260291
##########
superset/databases/schemas.py:
##########
@@ -719,6 +723,65 @@ def validate_password(self, data: Dict[str, Any],
**kwargs: Any) -> None:
if password == PASSWORD_MASK and data.get("password") is None:
raise ValidationError("Must provide a password for the database")
+ @validates_schema
+ def validate_ssh_tunnel_password(self, data: Dict[str, Any], **kwargs:
Any) -> None:
+ """If ssh_tunnel has a masked password, password is required"""
+ uuid = data["uuid"]
+ existing = db.session.query(Database).filter_by(uuid=uuid).first()
+ if existing:
+ return
+
+ # Our DB has a ssh_tunnel in it
+ if ssh_tunnel := data.get("ssh_tunnel"):
+ if not is_feature_enabled("SSH_TUNNELING"):
+ raise SSHTunnelingNotEnabledError()
+ password = ssh_tunnel.get("password")
+ if password == PASSWORD_MASK:
+ raise ValidationError("Must provide a password for the ssh
tunnel")
+ return
+
+ @validates_schema
+ def validate_ssh_tunnel_private_key(
+ self, data: Dict[str, Any], **kwargs: Any
+ ) -> None:
+ """If ssh_tunnel has a masked private key, private key is required"""
+ uuid = data["uuid"]
+ existing = db.session.query(Database).filter_by(uuid=uuid).first()
+ if existing:
+ return
+
+ # Our DB has a ssh_tunnel in it
+ if ssh_tunnel := data.get("ssh_tunnel"):
+ if not is_feature_enabled("SSH_TUNNELING"):
+ raise SSHTunnelingNotEnabledError()
+ private_key = ssh_tunnel.get("private_key")
+ if private_key == PASSWORD_MASK:
+ raise ValidationError("Must provide a private key for the ssh
tunnel")
Review Comment:
Hey! I added a few in the `api_tests` and `command_tests` files:
https://github.com/apache/superset/pull/23099/files#diff-023d03cc917d159e443cf0e947dda5e28cfdf7c5a26c592860e1d419fc5b317eR651
https://github.com/apache/superset/pull/23099/files#diff-b94e273d2b41d3fe8a552cbf34cfa59ab9495154d16823b411470ae782cea38aR2473
Let me know if you consider we need to cover other scenarios in other
places. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]