Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_denied_users(self):
denied_params = params.copy()
denied_params["user"] = "BLAFASEL"
try:
pyrfc.Connection(**denied_params)
except pyrfc.LogonError as ex:
error = get_error(ex)
assert error["code"] == 2
assert error["key"] == "RFC_LOGON_FAILURE"
assert error["message"][0] == "Name or password is incorrect (repeat logon)"
for key, width in zip(field_keys, field_widths):
sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ")
sys.stdout.write(u"\n")
for field_description in type_desc.fields:
for key, width in zip(field_keys, field_widths):
sys.stdout.write(u"{0}".format(field_description[key]).ljust(width) + u" ")
sys.stdout.write(u"\n")
sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} )-----------\n".format(type_desc))
sys.stdout.write(u"-" * sum(parameter_widths) + u"\n")
connection.close()
except CommunicationError:
print ("Could not connect to server.")
raise
except LogonError:
print ("Could not log in. Wrong credentials?")
raise
except (ABAPApplicationError, ABAPRuntimeError):
print ("An error occurred.")
raise