コード例 #1
0
 def check_login(self, user, password, super_password):
     self.logger.debug("Checking %s/%s/%s", user, password, super_password)
     self.logger.info(
         "Checking %s/%s/%s",
         safe_shadow(user),
         safe_shadow(password),
         safe_shadow(super_password),
     )
     try:
         r = open_sync_rpc(
             "activator",
             pool=self.object.pool.name,
             calling_service="discovery").script(
                 "%s.login" % self.object.profile.name,
                 {
                     "cli_protocol":
                     "ssh" if self.object.scheme == SSH else "telnet",
                     "address": self.object.address,
                     "user": user,
                     "password": password,
                     "super_password": super_password,
                     "path": None,
                     "raise_privileges": self.object.to_raise_privileges,
                     "access_preference":
                     self.object.get_access_preference(),
                 },
             )
         self.logger.info("Result: %s, %s", r, r["message"])
         return bool(r["result"]), r["message"]  # bool(False) == bool(None)
     except RPCError as e:
         self.logger.debug("RPC Error: %s", e)
         return False, ""
コード例 #2
0
def test_safe_shadow(config, expected):
    assert safe_shadow(config) == expected