Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
privacyidea
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Perun
Perun ProxyIdP
privacyidea
Commits
667f9341
Unverified
Commit
667f9341
authored
7 months ago
by
Nils Behlen
Committed by
GitHub
7 months ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4173 from privacyidea/fix_cron_commands
Fix command names in cron runner
parents
4fe73d3b
42fde41e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
privacyidea/cli/tools/cron.py
+3
-10
3 additions, 10 deletions
privacyidea/cli/tools/cron.py
tests/cli/test_cli_cron.py
+41
-11
41 additions, 11 deletions
tests/cli/test_cli_cron.py
with
44 additions
and
21 deletions
privacyidea/cli/tools/cron.py
+
3
−
10
View file @
667f9341
...
...
@@ -117,17 +117,10 @@ def cli():
This script is meant to be invoked periodically by the system cron daemon.
It runs periodic tasks that are specified in the database.
"""
click
.
echo
(
r
"""
_ _______ _______
___ ____(_) _____ _______ __/ _/ _ \/ __/ _ |
/ _ \/ __/ / |/ / _ `/ __/ // // // // / _// __ |
/ .__/_/ /_/|___/\_,_/\__/\_, /___/____/___/_/ |_| Cron
/_/ /___/
{0!s:>51}
"""
.
format
(
'
v{0!s}
'
.
format
(
get_version_number
())))
pass
@cli.command
()
@cli.command
(
"
run_manually
"
)
@click.option
(
"
-n
"
,
"
--node
"
,
"
node_string
"
,
help
=
"
Override the node name (read from privacyIDEA config by default)
"
)
@click.option
(
"
-t
"
,
"
--task
"
,
"
task_name
"
,
...
...
@@ -168,7 +161,7 @@ def list_tasks():
**
ptask
))
@cli.command
()
@cli.command
(
"
run_scheduled
"
)
@click.option
(
"
-d
"
,
"
--dryrun
"
,
is_flag
=
True
,
help
=
"
Do not run any tasks, only show what would be done
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/cli/test_cli_cron.py
+
41
−
11
View file @
667f9341
...
...
@@ -17,17 +17,47 @@
# You should have received a copy of the GNU Affero General Public
# License along with this program. If not, see <http://www.gnu.org/licenses/>.
from
.base
import
CliTestCase
import
pytest
from
sqlalchemy.orm.session
import
close_all_sessions
from
privacyidea.app
import
create_app
from
privacyidea.models
import
db
from
privacyidea.lib.lifecycle
import
call_finalizers
from
privacyidea.cli.tools.cron
import
cli
as
privacyidea_cron
class
PICronTestCase
(
CliTestCase
):
def
test_01_picron_help
(
self
):
runner
=
self
.
app
.
test_cli_runner
()
result
=
runner
.
invoke
(
privacyidea_cron
,
[
"
-h
"
])
self
.
assertIn
(
"
Execute all periodic tasks that are scheduled to run.
"
,
result
.
output
,
result
)
self
.
assertIn
(
"
Show a list of available tasks that could be run.
"
,
result
.
output
,
result
)
self
.
assertIn
(
"
Manually run a periodic task
"
,
result
.
output
,
result
)
@pytest.fixture
(
scope
=
"
class
"
)
def
app
():
"""
Create and configure app instance for testing
"""
app
=
create_app
(
config_name
=
"
testing
"
,
config_file
=
""
,
silent
=
True
)
with
app
.
app_context
():
db
.
create_all
()
yield
app
with
app
.
app_context
():
call_finalizers
()
close_all_sessions
()
db
.
drop_all
()
db
.
engine
.
dispose
()
class
TestPICronExec
:
def
test_01_picron_exec
(
self
,
app
):
runner
=
app
.
test_cli_runner
()
result
=
runner
.
invoke
(
privacyidea_cron
,
[])
assert
"
Usage: cli [OPTIONS] COMMAND [ARGS]...
"
in
result
.
output
,
result
assert
"
Execute all periodic tasks that are scheduled to run.
"
in
result
.
output
,
result
assert
"
run_scheduled
"
in
result
.
output
,
result
assert
"
Show a list of available tasks that could be run.
"
in
result
.
output
,
result
assert
"
Manually run a periodic task
"
in
result
.
output
,
result
assert
"
run_manually
"
in
result
.
output
,
result
result
=
runner
.
invoke
(
privacyidea_cron
,
[
"
list
"
])
assert
"
Active ID Name
"
in
result
.
output
,
result
.
output
result
=
runner
.
invoke
(
privacyidea_cron
,
[
"
run_scheduled
"
])
assert
"
There are no tasks scheduled on node Node1.
"
in
result
.
output
,
result
.
output
result
=
runner
.
invoke
(
privacyidea_cron
,
[
"
run_scheduled
"
,
"
-c
"
])
assert
not
result
.
output
,
result
.
output
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment