plugins/python/regress: update tests for show_version changes
- plugin->show_version is not marked NULL any more. - if verbose, it also displays which python class was loaded from which file
This commit is contained in:

committed by
Todd C. Miller

parent
f387cdf53f
commit
9cc46f115d
@@ -175,7 +175,8 @@ check_example_io_plugin_version_display(int is_verbose)
|
||||
if (is_verbose) {
|
||||
// Note: the exact python version is environment dependant
|
||||
VERIFY_STR_CONTAINS(data.stdout_str, "Python interpreter version:");
|
||||
VERIFY_STR_CONTAINS(data.stdout_str, "Python io plugin API version");
|
||||
*strstr(data.stdout_str, "Python interpreter version:") = '\0';
|
||||
VERIFY_STDOUT(expected_path("check_example_io_plugin_version_display_full.stdout"));
|
||||
} else {
|
||||
VERIFY_STDOUT(expected_path("check_example_io_plugin_version_display.stdout"));
|
||||
}
|
||||
@@ -687,7 +688,8 @@ check_example_policy_plugin_version_display(int is_verbose)
|
||||
if (is_verbose) {
|
||||
// Note: the exact python version is environment dependant
|
||||
VERIFY_STR_CONTAINS(data.stdout_str, "Python interpreter version:");
|
||||
VERIFY_STR_CONTAINS(data.stdout_str, "Python policy plugin API version");
|
||||
*strstr(data.stdout_str, "Python interpreter version:") = '\0';
|
||||
VERIFY_STDOUT(expected_path("check_example_policy_plugin_version_display_full.stdout"));
|
||||
} else {
|
||||
VERIFY_STDOUT(expected_path("check_example_policy_plugin_version_display.stdout"));
|
||||
}
|
||||
@@ -928,7 +930,10 @@ check_policy_plugin_callbacks_are_optional(void)
|
||||
VERIFY_PTR(python_policy->invalidate, NULL);
|
||||
VERIFY_PTR_NE(python_policy->check_policy, NULL); // (not optional)
|
||||
VERIFY_PTR(python_policy->init_session, NULL);
|
||||
VERIFY_PTR(python_policy->show_version, NULL);
|
||||
|
||||
// show_version always displays the plugin, but it is optional in the python layer
|
||||
VERIFY_PTR_NE(python_policy->show_version, NULL);
|
||||
VERIFY_INT(python_policy->show_version(1), SUDO_RC_OK);
|
||||
|
||||
python_policy->close(0, 0);
|
||||
return true;
|
||||
@@ -1014,9 +1019,12 @@ check_io_plugin_callbacks_are_optional(void)
|
||||
VERIFY_PTR(python_io->log_stderr, NULL);
|
||||
VERIFY_PTR(python_io->log_ttyin, NULL);
|
||||
VERIFY_PTR(python_io->log_ttyout, NULL);
|
||||
VERIFY_PTR(python_io->show_version, NULL);
|
||||
VERIFY_PTR(python_io->change_winsize, NULL);
|
||||
|
||||
// show_version always displays the plugin, but it is optional in the python layer
|
||||
VERIFY_PTR_NE(python_io->show_version, NULL);
|
||||
VERIFY_INT(python_io->show_version(1), SUDO_RC_OK);
|
||||
|
||||
python_io->close(0, 0);
|
||||
return true;
|
||||
}
|
||||
@@ -1261,7 +1269,10 @@ check_audit_plugin_callbacks_are_optional(void)
|
||||
VERIFY_PTR(python_audit->accept, NULL);
|
||||
VERIFY_PTR(python_audit->reject, NULL);
|
||||
VERIFY_PTR(python_audit->error, NULL);
|
||||
VERIFY_PTR(python_audit->show_version, NULL);
|
||||
|
||||
// show_version always displays the plugin, but it is optional in the python layer
|
||||
VERIFY_PTR_NE(python_audit->show_version, NULL);
|
||||
VERIFY_INT(python_audit->show_version(1), SUDO_RC_OK);
|
||||
|
||||
python_audit->close(SUDO_PLUGIN_NO_STATUS, 0);
|
||||
return true;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
(AUDIT) -- Started by user root (0) --
|
||||
Python Example Audit Plugin
|
||||
Python audit plugin API version 1.0
|
||||
Python audit plugin (API 1.0): SudoAuditPlugin (loaded from 'SRC_DIR/example_audit_plugin.py')
|
||||
Python Example Audit Plugin (version=1.0)
|
||||
(AUDIT) Sudo has run into an error: 222
|
||||
(AUDIT) -- Finished --
|
||||
|
@@ -1,6 +1,5 @@
|
||||
DebugDemoPlugin.__init__ was called with arguments: () {'version': '1.0', 'settings': ('debug_flags=/tmp/sudo_check_python_exampleXXXXXX/debug.log py_calls@info', 'plugin_path=python_plugin.so'), 'user_env': (), 'user_info': (), 'plugin_options': ('ModulePath=SRC_DIR/example_debugging.py', 'ClassName=DebugDemoPlugin')}
|
||||
DebugDemoPlugin.__init__ returned result: <example_debugging.DebugDemoPlugin object>
|
||||
DebugDemoPlugin function 'show_version' is not implemented
|
||||
DebugDemoPlugin function 'log_ttyin' is not implemented
|
||||
DebugDemoPlugin function 'log_ttyout' is not implemented
|
||||
DebugDemoPlugin function 'log_stdin' is not implemented
|
||||
|
3
plugins/python/regress/testdata/check_example_io_plugin_version_display_full.stdout
vendored
Normal file
3
plugins/python/regress/testdata/check_example_io_plugin_version_display_full.stdout
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Example sudo python plugin will log to /tmp/sudo_check_python_exampleXXXXXX/sudo.log
|
||||
Python io plugin (API 1.0): SudoIOPlugin (loaded from 'SRC_DIR/example_io_plugin.py')
|
||||
Python Example IO Plugin version: 1.0
|
2
plugins/python/regress/testdata/check_example_policy_plugin_version_display_full.stdout
vendored
Normal file
2
plugins/python/regress/testdata/check_example_policy_plugin_version_display_full.stdout
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Python policy plugin (API 1.0): SudoPolicyPlugin (loaded from 'SRC_DIR/example_policy_plugin.py')
|
||||
Python Example Policy Plugin version: 1.0
|
@@ -59,7 +59,7 @@
|
||||
"_id": "(APPROVAL 2)"
|
||||
}
|
||||
(APPROVAL 1) Show version was called with arguments: (0,)
|
||||
Python approval plugin API version 1.0
|
||||
Python approval plugin (API 1.0): ApprovalTestPlugin (loaded from 'SRC_DIR/regress/plugin_approval_test.py')
|
||||
(APPROVAL 2) Show version was called with arguments: (1,)
|
||||
(APPROVAL 1) Check was called with arguments: (('CMDINFO1=value1', 'CMDINFO2=VALUE2'), ('whoami', '--help'), ('USER_ENV1=VALUE1', 'USER_ENV2=value2'))
|
||||
(APPROVAL 2) Check was called with arguments: (('CMDINFO1=value1', 'CMDINFO2=VALUE2'), ('whoami', '--help'), ('USER_ENV1=VALUE1', 'USER_ENV2=value2'))
|
||||
|
Reference in New Issue
Block a user